當前位置: 首頁>>代碼示例>>Java>>正文


Java Repository.lockDirCache方法代碼示例

本文整理匯總了Java中org.eclipse.jgit.lib.Repository.lockDirCache方法的典型用法代碼示例。如果您正苦於以下問題:Java Repository.lockDirCache方法的具體用法?Java Repository.lockDirCache怎麽用?Java Repository.lockDirCache使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.eclipse.jgit.lib.Repository的用法示例。


在下文中一共展示了Repository.lockDirCache方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: run

import org.eclipse.jgit.lib.Repository; //導入方法依賴的package包/類
@Override
protected void run() throws GitException {
    Repository repository = getRepository();
    DirCache cache = null;
    try {
        // cache must be locked because checkout index may modify its entries
        cache = repository.lockDirCache();
        DirCacheBuilder builder = cache.builder();
        if (cache.getEntryCount() > 0) {
            builder.keep(0, cache.getEntryCount());
        }
        builder.finish();
        new CheckoutIndex(repository, cache, roots, recursively, listener, monitor, true).checkout();
        // cache must be saved to disk because checkout index may modify its entries
        builder.commit();
    } catch (IOException ex) {
        throw new GitException(ex);
    } finally {
        if (cache != null) {
            cache.unlock();
        }
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:24,代碼來源:CheckoutIndexCommand.java

示例2: assertDirCacheEntry

import org.eclipse.jgit.lib.Repository; //導入方法依賴的package包/類
protected static void assertDirCacheEntry (Repository repository, File workDir, Collection<File> files) throws IOException {
    DirCache cache = repository.lockDirCache();
    for (File f : files) {
        String relativePath = Utils.getRelativePath(workDir, f);
        DirCacheEntry e = cache.getEntry(relativePath);
        assertNotNull(e);
        assertEquals(relativePath, e.getPathString());
        if (f.lastModified() != e.getLastModified()) {
            assertEquals((f.lastModified() / 1000) * 1000, (e.getLastModified() / 1000) * 1000);
        }
        try (InputStream in = new FileInputStream(f)) {
            assertEquals(e.getObjectId(), repository.newObjectInserter().idFor(Constants.OBJ_BLOB, f.length(), in));
        }
        if (e.getLength() == 0 && f.length() != 0) {
            assertTrue(e.isSmudged());
        } else {
            assertEquals(f.length(), e.getLength());
        }
    }
    cache.unlock();
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:22,代碼來源:AbstractGitTestCase.java


注:本文中的org.eclipse.jgit.lib.Repository.lockDirCache方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。