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


Java DirCacheEditor.finish方法代码示例

本文整理汇总了Java中org.eclipse.jgit.dircache.DirCacheEditor.finish方法的典型用法代码示例。如果您正苦于以下问题:Java DirCacheEditor.finish方法的具体用法?Java DirCacheEditor.finish怎么用?Java DirCacheEditor.finish使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.jgit.dircache.DirCacheEditor的用法示例。


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

示例1: apply

import org.eclipse.jgit.dircache.DirCacheEditor; //导入方法依赖的package包/类
/**
 * Apply the changes that this {@link TreeUpdate} represents to the given
 * {@link DirCache}. The {@link DirCache} will be unlocked if was modified.
 *
 * @param dirCache
 * @return true if updates are applied to the {@link DirCache}, false if the
 *         {@link DirCache} has not been modified.
 */
public ObjectId apply(ObjectInserter objectInserter) {
	ObjectId newTreeId = null;
	if (hasUpdates()) {
		DirCacheEditor editor = index.editor();

		for (PathEdit pathEdit : pathEdits) {
			editor.add(pathEdit);
		}

		editor.finish();

		try {
			// Write the index as tree to the object database. This may
			// fail for example when the index contains unmerged paths
			// (unresolved conflicts)
			newTreeId = index.writeTree(objectInserter);
		} catch (IOException e) {
			throw new GitRepositoryException(e);
		}
	}
	return newTreeId;
}
 
开发者ID:link-intersystems,项目名称:GitDirStat,代码行数:31,代码来源:CacheTreeUpdate.java

示例2: deleteFilesWithDirCacheEditorTest

import org.eclipse.jgit.dircache.DirCacheEditor; //导入方法依赖的package包/类
@Test
public void deleteFilesWithDirCacheEditorTest() {
  DirCache cache = setupCache("a/b/c1.txt",
                               "a/b/c2.txt",
                               "a/c3.txt",
                               "a/c4.txt",
                               "a/c5.txt",
                               "a/c6.txt");

  DirCacheEditor editor = cache.editor();
  CacheUtils.deleteFile("a/b/c1.txt", editor);
  CacheUtils.deleteFile("a/c3.txt", editor);
  CacheUtils.deleteFile("a/c4.txt", editor);
  CacheUtils.deleteFile("a/c6.txt", editor);
  editor.finish();

  assertEquals(2, cache.getEntryCount());
  assertNull(cache.getEntry("a/b/c1.txt"));
  assertNotNull(cache.getEntry("a/b/c2.txt"));
  assertNotNull(cache.getEntry("a/c5.txt"));
}
 
开发者ID:beijunyi,项目名称:ParallelGit,代码行数:22,代码来源:CacheUtilsEditTest.java

示例3: deleteMultipleTreesTest

import org.eclipse.jgit.dircache.DirCacheEditor; //导入方法依赖的package包/类
@Test
public void deleteMultipleTreesTest() {
  DirCache cache = setupCache("a/b/c1.txt",
                               "a/b/c2.txt",
                               "a/d/c3.txt",
                               "a/d/c4.txt",
                               "a/c5.txt",
                               "a/c6.txt");

  DirCacheEditor editor = cache.editor();
  CacheUtils.deleteDirectory("a/b", editor);
  CacheUtils.deleteDirectory("a/d", editor);
  editor.finish();

  assertEquals(2, cache.getEntryCount());
  assertNotNull(cache.getEntry("a/c5.txt"));
  assertNotNull(cache.getEntry("a/c6.txt"));
}
 
开发者ID:beijunyi,项目名称:ParallelGit,代码行数:19,代码来源:CacheUtilsEditTest.java

示例4: saveFile

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

示例5: execute

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

示例6: execute

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

示例7: execute

import org.eclipse.jgit.dircache.DirCacheEditor; //导入方法依赖的package包/类
public Optional<ObjectId> execute() {
    final Map<String, String> content = commitContent.getContent();

    final DirCacheEditor editor = DirCache.newInCore().editor();

    try {
        iterateOverTreeWalk(git,
                            headId,
                            (walkPath, hTree) -> {
                                final String toPath = content.get(walkPath);
                                addToTemporaryInCoreIndex(editor,
                                                          new DirCacheEntry(walkPath),
                                                          hTree.getEntryObjectId(),
                                                          hTree.getEntryFileMode());
                                if (toPath != null) {
                                    addToTemporaryInCoreIndex(editor,
                                                              new DirCacheEntry(toPath),
                                                              hTree.getEntryObjectId(),
                                                              hTree.getEntryFileMode());
                                }
                            });

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

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

示例8: applyPathEdit

import org.eclipse.jgit.dircache.DirCacheEditor; //导入方法依赖的package包/类
private static void applyPathEdit(DirCache dirCache, PathEdit edit) {
    final DirCacheEditor e = dirCache.editor();
    e.add(edit);
    e.finish();
}
 
开发者ID:line,项目名称:centraldogma,代码行数:6,代码来源:GitRepository.java

示例9: insert

import org.eclipse.jgit.dircache.DirCacheEditor; //导入方法依赖的package包/类
public void insert(Account account) throws IOException {
  File path = getPath();
  if (path != null) {
    try (Repository repo = new FileRepository(path);
        ObjectInserter oi = repo.newObjectInserter()) {
      PersonIdent ident =
          new PersonIdent(
              new GerritPersonIdentProvider(flags.cfg).get(), account.getRegisteredOn());

      Config accountConfig = new Config();
      AccountConfig.writeToConfig(account, accountConfig);

      DirCache newTree = DirCache.newInCore();
      DirCacheEditor editor = newTree.editor();
      final ObjectId blobId =
          oi.insert(Constants.OBJ_BLOB, accountConfig.toText().getBytes(UTF_8));
      editor.add(
          new PathEdit(AccountConfig.ACCOUNT_CONFIG) {
            @Override
            public void apply(DirCacheEntry ent) {
              ent.setFileMode(FileMode.REGULAR_FILE);
              ent.setObjectId(blobId);
            }
          });
      editor.finish();

      ObjectId treeId = newTree.writeTree(oi);

      CommitBuilder cb = new CommitBuilder();
      cb.setTreeId(treeId);
      cb.setCommitter(ident);
      cb.setAuthor(ident);
      cb.setMessage("Create Account");
      ObjectId id = oi.insert(cb);
      oi.flush();

      String refName = RefNames.refsUsers(account.getId());
      RefUpdate ru = repo.updateRef(refName);
      ru.setExpectedOldObjectId(ObjectId.zeroId());
      ru.setNewObjectId(id);
      ru.setRefLogIdent(ident);
      ru.setRefLogMessage("Create Account", false);
      Result result = ru.update();
      if (result != Result.NEW) {
        throw new IOException(
            String.format("Failed to update ref %s: %s", refName, result.name()));
      }
      account.setMetaId(id.name());
    }
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:52,代码来源:AccountsOnInit.java

示例10: applyPathEdits

import org.eclipse.jgit.dircache.DirCacheEditor; //导入方法依赖的package包/类
private static void applyPathEdits(DirCache tree, List<DirCacheEditor.PathEdit> pathEdits) {
  DirCacheEditor dirCacheEditor = tree.editor();
  pathEdits.forEach(dirCacheEditor::add);
  dirCacheEditor.finish();
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:6,代码来源:TreeCreator.java

示例11: composeGitlinksCommit

import org.eclipse.jgit.dircache.DirCacheEditor; //导入方法依赖的package包/类
/** Create a separate gitlink commit */
public CodeReviewCommit composeGitlinksCommit(Branch.NameKey subscriber)
    throws IOException, SubmoduleException {
  OpenRepo or;
  try {
    or = orm.getRepo(subscriber.getParentKey());
  } catch (NoSuchProjectException | IOException e) {
    throw new SubmoduleException("Cannot access superproject", e);
  }

  CodeReviewCommit currentCommit;
  if (branchTips.containsKey(subscriber)) {
    currentCommit = branchTips.get(subscriber);
  } else {
    Ref r = or.repo.exactRef(subscriber.get());
    if (r == null) {
      throw new SubmoduleException(
          "The branch was probably deleted from the subscriber repository");
    }
    currentCommit = or.rw.parseCommit(r.getObjectId());
    addBranchTip(subscriber, currentCommit);
  }

  StringBuilder msgbuf = new StringBuilder("");
  PersonIdent author = null;
  DirCache dc = readTree(or.rw, currentCommit);
  DirCacheEditor ed = dc.editor();
  for (SubmoduleSubscription s : targets.get(subscriber)) {
    RevCommit newCommit = updateSubmodule(dc, ed, msgbuf, s);
    if (newCommit != null) {
      if (author == null) {
        author = newCommit.getAuthorIdent();
      } else if (!author.equals(newCommit.getAuthorIdent())) {
        author = myIdent;
      }
    }
  }
  ed.finish();
  ObjectId newTreeId = dc.writeTree(or.ins);

  // Gitlinks are already in the branch, return null
  if (newTreeId.equals(currentCommit.getTree())) {
    return null;
  }
  CommitBuilder commit = new CommitBuilder();
  commit.setTreeId(newTreeId);
  commit.setParentId(currentCommit);
  StringBuilder commitMsg = new StringBuilder("Update git submodules\n\n");
  if (verboseSuperProject != VerboseSuperprojectUpdate.FALSE) {
    commitMsg.append(msgbuf);
  }
  commit.setMessage(commitMsg.toString());
  commit.setAuthor(author);
  commit.setCommitter(myIdent);
  ObjectId id = or.ins.insert(commit);
  return or.rw.parseCommit(id);
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:58,代码来源:SubmoduleOp.java

示例12: execute

import org.eclipse.jgit.dircache.DirCacheEditor; //导入方法依赖的package包/类
public Optional<ObjectId> execute() {
    final Map<String, File> content = commitContent.getContent();
    final Map<String, Pair<File, ObjectId>> paths = new HashMap<>(content.size());
    final Set<String> path2delete = new HashSet<>();

    final DirCacheEditor editor = DirCache.newInCore().editor();

    try {
        for (final Map.Entry<String, File> pathAndContent : content.entrySet()) {
            final String gPath = PathUtil.normalize(pathAndContent.getKey());
            if (pathAndContent.getValue() == null) {
                path2delete.addAll(searchPathsToDelete(git,
                                                       headId,
                                                       gPath));
            } else {
                paths.putAll(storePathsIntoHashMap(odi,
                                                   pathAndContent,
                                                   gPath));
            }
        }

        iterateOverTreeWalk(git,
                            headId,
                            (walkPath, hTree) -> {
                                if (paths.containsKey(walkPath) && paths.get(walkPath).getK2().equals(hTree.getEntryObjectId())) {
                                    paths.remove(walkPath);
                                }

                                if (paths.get(walkPath) == null && !path2delete.contains(walkPath)) {
                                    addToTemporaryInCoreIndex(editor,
                                                              new DirCacheEntry(walkPath),
                                                              hTree.getEntryObjectId(),
                                                              hTree.getEntryFileMode());
                                }
                            });

        paths.forEach((key, value) -> {
            if (value.getK1() != null) {
                editor.add(new DirCacheEditor.PathEdit(new DirCacheEntry(key)) {
                    @Override
                    public void apply(final DirCacheEntry ent) {
                        ent.setLength(value.getK1().length());
                        ent.setLastModified(value.getK1().lastModified());
                        ent.setFileMode(REGULAR_FILE);
                        ent.setObjectId(value.getK2());
                    }
                });
            }
        });

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

    if (path2delete.isEmpty() && paths.isEmpty()) {
        editor.getDirCache().clear();
        return Optional.empty();
    }

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


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