当前位置: 首页>>代码示例>>Java>>正文


Java DirCacheEntry类代码示例

本文整理汇总了Java中org.eclipse.jgit.dircache.DirCacheEntry的典型用法代码示例。如果您正苦于以下问题:Java DirCacheEntry类的具体用法?Java DirCacheEntry怎么用?Java DirCacheEntry使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


DirCacheEntry类属于org.eclipse.jgit.dircache包,在下文中一共展示了DirCacheEntry类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: checkoutEntry

import org.eclipse.jgit.dircache.DirCacheEntry; //导入依赖的package包/类
public void checkoutEntry (Repository repository, File file, DirCacheEntry e, ObjectReader od) throws IOException, GitException {
    // ... create/overwrite this file ...
    if (!ensureParentFolderExists(file.getParentFile())) {
        return;
    }

    boolean exists = file.exists();
    if (exists && e.getFileMode() == FileMode.SYMLINK) {
        monitor.notifyWarning(MessageFormat.format(Utils.getBundle(CheckoutIndex.class).getString("MSG_Warning_SymLink"), file.getAbsolutePath())); //NOI18N
        return;
    }

    if (Utils.isFromNested(e.getFileMode().getBits())) {
        if (!exists) {
            file.mkdirs();
        }
    } else {
        if (exists && file.isDirectory()) {
            monitor.notifyWarning(MessageFormat.format(Utils.getBundle(CheckoutIndex.class).getString("MSG_Warning_ReplacingDirectory"), file.getAbsolutePath())); //NOI18N
            Utils.deleteRecursively(file);
        }
        file.createNewFile();
        if (file.isFile()) {
            DirCacheCheckout.checkoutEntry(repository, file, e, od);
        } else {
            monitor.notifyError(MessageFormat.format(Utils.getBundle(CheckoutIndex.class).getString("MSG_Warning_CannotCreateFile"), file.getAbsolutePath())); //NOI18N
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:30,代码来源:CheckoutIndex.java

示例2: testAddMissingSymlink

import org.eclipse.jgit.dircache.DirCacheEntry; //导入依赖的package包/类
public void testAddMissingSymlink () throws Exception {
    if (isWindows()) {
        return;
    }
    String path = "folder/file";
    File f = new File(workDir, path);
    
    // try with commandline client
    File link = new File(workDir, "link");
    Files.createSymbolicLink(Paths.get(link.getAbsolutePath()), Paths.get(path));
    getClient(workDir).add(new File[] { link }, NULL_PROGRESS_MONITOR);
    DirCacheEntry e = repository.readDirCache().getEntry(link.getName());
    assertEquals(FileMode.SYMLINK, e.getFileMode());
    assertEquals(0, e.getLength());
    ObjectReader reader = repository.getObjectDatabase().newReader();
    assertTrue(reader.has(e.getObjectId()));
    byte[] bytes = reader.open(e.getObjectId()).getBytes();
    assertEquals(path, RawParseUtils.decode(bytes));
    reader.release();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:AddTest.java

示例3: assertDirCacheEntryModified

import org.eclipse.jgit.dircache.DirCacheEntry; //导入依赖的package包/类
private void assertDirCacheEntryModified (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());
        InputStream in = new FileInputStream(f);
        try {
            assertNotSame(e.getObjectId(), repository.newObjectInserter().idFor(Constants.OBJ_BLOB, f.length(), in));
        } finally {
            in.close();
        }
    }
    cache.unlock();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:AddTest.java

示例4: assertDirCacheEntry

import org.eclipse.jgit.dircache.DirCacheEntry; //导入依赖的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

示例5: findEntrys

import org.eclipse.jgit.dircache.DirCacheEntry; //导入依赖的package包/类
private DirCacheEntry[] findEntrys(Repository repository, String path) throws IOException {
    DirCache dirCache = repository.readDirCache();

    int eIdx = dirCache.findEntry(path);
    if (eIdx < 0) {
        throw new GitInvalidPathException(format("%s is not found in git index", path));
    }

    int lastIdx = dirCache.nextEntry(eIdx);

    final DirCacheEntry[] entries = new DirCacheEntry[lastIdx - eIdx];
    for (int i=0; i<entries.length; i++) {
        entries[i] = dirCache.getEntry(eIdx + i);
    }

    return entries;
}
 
开发者ID:Coding,项目名称:WebIDE-Backend,代码行数:18,代码来源:GitManagerImpl.java

示例6: buildDirCache

import org.eclipse.jgit.dircache.DirCacheEntry; //导入依赖的package包/类
private void buildDirCache(TreeWalk walk, DirCacheBuilder builder)
		throws MissingObjectException, IncorrectObjectTypeException,
		CorruptObjectException, IOException {
	while (walk.next()) {
		AbstractTreeIterator cIter = walk.getTree(0,
				AbstractTreeIterator.class);
		if (cIter == null) {
			// Not in commit, don't add to new index
			continue;
		}

		final DirCacheEntry entry = new DirCacheEntry(walk.getRawPath());
		entry.setFileMode(cIter.getEntryFileMode());
		entry.setObjectIdFromRaw(cIter.idBuffer(), cIter.idOffset());

		DirCacheIterator dcIter = walk.getTree(1, DirCacheIterator.class);
		if (dcIter != null && dcIter.idEqual(cIter)) {
			DirCacheEntry indexEntry = dcIter.getDirCacheEntry();
			entry.setLastModified(indexEntry.getLastModified());
			entry.setLength(indexEntry.getLength());
		}

		builder.add(entry);
	}
}
 
开发者ID:link-intersystems,项目名称:GitDirStat,代码行数:26,代码来源:IndexUpdate.java

示例7: findNext

import org.eclipse.jgit.dircache.DirCacheEntry; //导入依赖的package包/类
public boolean findNext() {
  while(index < entries.length) {
    DirCacheEntry entry = entries[index++];
    String nextPath = "/" + entry.getPathString();
    if(directParentLength == -1)
      next = CacheNode.file(nextPath, entry);
    else {
      if(prev != null && prev.hasChild(nextPath))
        continue;
      int end = nextPath.indexOf('/', directParentLength);
      next = end != -1 ? CacheNode.directory(nextPath.substring(0, end)) : CacheNode.file(nextPath, entry);
    }
    return true;
  }
  return false;
}
 
开发者ID:beijunyi,项目名称:ParallelGit,代码行数:17,代码来源:CacheIterator.java

示例8: saveFile

import org.eclipse.jgit.dircache.DirCacheEntry; //导入依赖的package包/类
protected void saveFile(String fileName, byte[] raw) throws IOException {
  DirCacheEditor editor = newTree.editor();
  if (raw != null && 0 < raw.length) {
    final ObjectId blobId = inserter.insert(Constants.OBJ_BLOB, raw);
    editor.add(
        new PathEdit(fileName) {
          @Override
          public void apply(DirCacheEntry ent) {
            ent.setFileMode(FileMode.REGULAR_FILE);
            ent.setObjectId(blobId);
          }
        });
  } else {
    editor.add(new DeletePath(fileName));
  }
  editor.finish();
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:18,代码来源:VersionedMetaData.java

示例9: execute

import org.eclipse.jgit.dircache.DirCacheEntry; //导入依赖的package包/类
public Optional<ObjectId> execute() {
    final Map<String, String> content = commitContent.getContent();
    final DirCacheEditor editor = DirCache.newInCore().editor();
    final List<String> pathsAdded = new ArrayList<>();

    try {
        iterateOverTreeWalk(git,
                            headId,
                            (walkPath, hTree) -> {
                                final String toPath = content.get(walkPath);
                                final DirCacheEntry dcEntry = new DirCacheEntry((toPath == null) ? walkPath : toPath);
                                if (!pathsAdded.contains(dcEntry.getPathString())) {
                                    addToTemporaryInCoreIndex(editor,
                                                              dcEntry,
                                                              hTree.getEntryObjectId(),
                                                              hTree.getEntryFileMode());
                                    pathsAdded.add(dcEntry.getPathString());
                                }
                            });
        editor.finish();
    } catch (final Exception e) {
        throw new RuntimeException(e);
    }

    return buildTree(editor);
}
 
开发者ID:kiegroup,项目名称:appformer,代码行数:27,代码来源:CreateMoveCommitTree.java

示例10: execute

import org.eclipse.jgit.dircache.DirCacheEntry; //导入依赖的package包/类
public Optional<ObjectId> execute() {
    final DirCacheEditor editor = DirCache.newInCore().editor();

    try {
        iterateOverTreeWalk(git,
                            headId,
                            (walkPath, hTree) -> {
                                addToTemporaryInCoreIndex(editor,
                                                          new DirCacheEntry(walkPath),
                                                          hTree.getEntryObjectId(),
                                                          hTree.getEntryFileMode());
                            });

        editor.finish();
    } catch (final Exception e) {
        throw new RuntimeException(e);
    }

    return buildTree(editor);
}
 
开发者ID:kiegroup,项目名称:appformer,代码行数:21,代码来源:CreateRevertCommitTree.java

示例11: main

import org.eclipse.jgit.dircache.DirCacheEntry; //导入依赖的package包/类
public static void main(String[] args) throws IOException {
    try (Repository repository = CookbookHelper.openJGitCookbookRepository()) {
        // DirCache contains all files of the repository
        DirCache index = DirCache.read(repository);
        System.out.println("DirCache has " + index.getEntryCount() + " items");
        for (int i = 0; i < index.getEntryCount(); i++) {
            // the number after the AnyObjectId is the "stage", see the constants in DirCacheEntry
            System.out.println("Item " + i + ": " + index.getEntry(i));
        }

        //
        System.out.println("Now printing staged items...");
        for (int i = 0; i < index.getEntryCount(); i++) {
            DirCacheEntry entry = index.getEntry(i);
            if (entry.getStage() != DirCacheEntry.STAGE_0) {
                System.out.println("Item " + i + ": " + entry);
            }
        }
    }
}
 
开发者ID:centic9,项目名称:jgit-cookbook,代码行数:21,代码来源:ListIndex.java

示例12: call

import org.eclipse.jgit.dircache.DirCacheEntry; //导入依赖的package包/类
@Override
public String call() throws GitAPIException {
	try {
		DirCache index = repo.lockDirCache();
		DirCacheEntry entry = index.getEntry(fileName);

		if (entry != null) {
			entry.setAssumeValid(assumeUnchanged);
			index.write();
			index.commit();
			return entry.getPathString();
		}
	} catch (IOException e) {
		throw new JGitInternalException(e.getMessage(), e);
	}

	return null;
}
 
开发者ID:centic9,项目名称:jgit-cookbook,代码行数:19,代码来源:UpdateIndex.java

示例13: createTreeDirCache

import org.eclipse.jgit.dircache.DirCacheEntry; //导入依赖的package包/类
private DirCache createTreeDirCache(Map<SubtreeConfig, RevCommit> parentCommits,
		String commitMessage) throws IOException {

	try (TreeWalk treeWalk = new TreeWalk(repository)) {
		treeWalk.setRecursive(true);
		addTrees(parentCommits, treeWalk);

		DirCacheBuilder builder = DirCache.newInCore().builder();
		while (treeWalk.next()) {
			AbstractTreeIterator iterator = getSingleTreeIterator(treeWalk, commitMessage);
			if (iterator == null) {
				throw new IllegalStateException(
						"Tree walker did not return a single tree (should not happen): "
								+ treeWalk.getPathString());
			}
			byte[] path = Arrays.copyOf(iterator.getEntryPathBuffer(),
					iterator.getEntryPathLength());
			DirCacheEntry entry = new DirCacheEntry(path);
			entry.setFileMode(iterator.getEntryFileMode());
			entry.setObjectId(iterator.getEntryObjectId());
			builder.add(entry);
		}
		builder.finish();
		return builder.getDirCache();
	}
}
 
开发者ID:robinst,项目名称:git-merge-repos,代码行数:27,代码来源:SubtreeMerger.java

示例14: assertNullDirCacheEntry

import org.eclipse.jgit.dircache.DirCacheEntry; //导入依赖的package包/类
private void assertNullDirCacheEntry (Collection<File> files) throws Exception {
    DirCache cache = repository.lockDirCache();
    for (File f : files) {
        DirCacheEntry e = cache.getEntry(Utils.getRelativePath(workDir, f));
        assertNull(e);
    }
    cache.unlock();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:9,代码来源:CleanTest.java

示例15: testLargeFile

import org.eclipse.jgit.dircache.DirCacheEntry; //导入依赖的package包/类
public void testLargeFile () throws Exception {
    unpack("large.dat.zip");
    File large = new File(workDir, "large.dat");
    assertTrue(large.exists());
    assertEquals(2158310, large.length());
    add();
    DirCache cache = repository.readDirCache();
    DirCacheEntry e = cache.getEntry("large.dat");
    WindowCacheConfig cfg = new WindowCacheConfig();
    cfg.setStreamFileThreshold((int) large.length() - 1);
    cfg.install();
    DirCacheCheckout.checkoutEntry(repository, large, e);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:14,代码来源:CheckoutTest.java


注:本文中的org.eclipse.jgit.dircache.DirCacheEntry类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。