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


Java ResolveMerger类代码示例

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


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

示例1: getFailures

import org.eclipse.jgit.merge.ResolveMerger; //导入依赖的package包/类
private List<File> getFailures (MergeResult result) {
    List<File> files = new LinkedList<File>();
    Map<String, ResolveMerger.MergeFailureReason> obstructions = result.getFailingPaths();
    if (obstructions != null) {
        for (Map.Entry<String, ResolveMerger.MergeFailureReason> failure : obstructions.entrySet()) {
            files.add(new File(workDir, failure.getKey()));
        }
    }
    return Collections.unmodifiableList(files);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:GitMergeResult.java

示例2: getFailures

import org.eclipse.jgit.merge.ResolveMerger; //导入依赖的package包/类
private List<File> getFailures (CherryPickResult result) {
    List<File> files = new ArrayList<>();
    File workDir = getRepository().getWorkTree();
    if (result.getStatus() == CherryPickResult.CherryPickStatus.FAILED) {
        Map<String, ResolveMerger.MergeFailureReason> obstructions = result.getFailingPaths();
        if (obstructions != null) {
            for (Map.Entry<String, ResolveMerger.MergeFailureReason> failure : obstructions.entrySet()) {
                files.add(new File(workDir, failure.getKey()));
            }
        }
    }
    return Collections.unmodifiableList(files);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:14,代码来源:CherryPickCommand.java

示例3: rebase

import org.eclipse.jgit.merge.ResolveMerger; //导入依赖的package包/类
@Nullable
  public static ObjectId rebase(Repository repository, ObjectId source, ObjectId target, PersonIdent committer) {
  	try (	RevWalk revWalk = new RevWalk(repository);
  			ObjectInserter inserter = repository.newObjectInserter();) {
  		RevCommit sourceCommit = revWalk.parseCommit(source);
  		RevCommit targetCommit = revWalk.parseCommit(target);
  		revWalk.setRevFilter(RevFilter.NO_MERGES);
  		List<RevCommit> commits = RevWalkUtils.find(revWalk, sourceCommit, targetCommit);
  		Collections.reverse(commits);
  		RevCommit headCommit = targetCommit;
  		for (RevCommit commit: commits) {
      		ResolveMerger merger = (ResolveMerger) MergeStrategy.RECURSIVE.newMerger(repository, true);
      		merger.setBase(commit.getParent(0));
      		if (merger.merge(headCommit, commit)) {
			if (!headCommit.getTree().getId().equals(merger.getResultTreeId())) {
		        CommitBuilder newCommit = new CommitBuilder();
		        newCommit.setAuthor(commit.getAuthorIdent());
		        newCommit.setCommitter(committer);
		        newCommit.setParentId(headCommit);
		        newCommit.setMessage(commit.getFullMessage());
		        newCommit.setTreeId(merger.getResultTreeId());
		        headCommit = revWalk.parseCommit(inserter.insert(newCommit));
			}
      		} else {
      			return null;
      		}
  		}
  		inserter.flush();
  		return headCommit.copy();
  	} catch (IOException e) {
  		throw new RuntimeException(e);
}
  }
 
开发者ID:jmfgdev,项目名称:gitplex-mit,代码行数:34,代码来源:GitUtils.java

示例4: readConflicts

import org.eclipse.jgit.merge.ResolveMerger; //导入依赖的package包/类
@Nonnull
public static Map<String, MergeConflict> readConflicts(ResolveMerger merger) {
  Map<String, MergeConflict> ret = new HashMap<>();
  for(Map.Entry<String, MergeResult<? extends Sequence>> conflict : merger.getMergeResults().entrySet())
    ret.put(toAbsolutePath(conflict.getKey()), new MergeConflict(conflict.getValue(), merger.getCommitNames()));
  return unmodifiableMap(ret);
}
 
开发者ID:beijunyi,项目名称:ParallelGit,代码行数:8,代码来源:MergeConflict.java

示例5: createMergeCommit

import org.eclipse.jgit.merge.ResolveMerger; //导入依赖的package包/类
public static RevCommit createMergeCommit(
    ObjectInserter inserter,
    Config repoConfig,
    RevCommit mergeTip,
    RevCommit originalCommit,
    String mergeStrategy,
    PersonIdent committerIndent,
    String commitMsg,
    RevWalk rw)
    throws IOException, MergeIdenticalTreeException, MergeConflictException {

  if (!MergeStrategy.THEIRS.getName().equals(mergeStrategy)
      && rw.isMergedInto(originalCommit, mergeTip)) {
    throw new ChangeAlreadyMergedException(
        "'" + originalCommit.getName() + "' has already been merged");
  }

  Merger m = newMerger(inserter, repoConfig, mergeStrategy);
  if (m.merge(false, mergeTip, originalCommit)) {
    ObjectId tree = m.getResultTreeId();

    CommitBuilder mergeCommit = new CommitBuilder();
    mergeCommit.setTreeId(tree);
    mergeCommit.setParentIds(mergeTip, originalCommit);
    mergeCommit.setAuthor(committerIndent);
    mergeCommit.setCommitter(committerIndent);
    mergeCommit.setMessage(commitMsg);
    return rw.parseCommit(inserter.insert(mergeCommit));
  }
  List<String> conflicts = ImmutableList.of();
  if (m instanceof ResolveMerger) {
    conflicts = ((ResolveMerger) m).getUnmergedPaths();
  }
  throw new MergeConflictException(createConflictMessage(conflicts));
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:36,代码来源:MergeUtil.java

示例6: mergeApi

import org.eclipse.jgit.merge.ResolveMerger; //导入依赖的package包/类
/**
 * Merge the check-in into the destination branch using an API call.
 *
 * @param   src        Source branch
 * @param   dest       Destination branch
 * @param   id         Check-in ID of the change to be merged
 * @return  Result of the merge operation
 */
public MergeResult mergeApi(String src, String dest, String id) throws Exception {
    MergeResult result = null;

    Date startCherryPick = new Date();
    CherryPickCommand cpCmd = repository.cherryPick();
    logger.info("Attempting to locate commit object " + id);
    cpCmd.include(getCommit(id));
    logger.info("Performing cherry-pick of " + id);
    CherryPickResult cmdResult = cpCmd.call();
    CMnCmdLineTool.logElapsedTime(logger, startCherryPick, new Date(), "Cherry-pick: ");

    // Check the results of the merge operation
    CherryPickResult.CherryPickStatus cpStatus = cmdResult.getStatus();
    switch (cpStatus) {
        case CONFLICTING:
            result = MergeResult.CONFLICT;
            break;
        case OK:
            result = MergeResult.SUCCESS;
            break;
        case FAILED:
            result = MergeResult.FAILURE;
            Date startFailureResults = new Date();
            Map<String, ResolveMerger.MergeFailureReason> failures = cmdResult.getFailingPaths();
            Set<String> keys = failures.keySet();
            Iterator keyIter = keys.iterator();
            while (keyIter.hasNext()) {
                String key = (String) keyIter.next();
                ResolveMerger.MergeFailureReason reason = (ResolveMerger.MergeFailureReason) failures.get(key);
                logger.severe("Merge failure: " + key + ": " + reason);
            }
            CMnCmdLineTool.logElapsedTime(logger, startFailureResults, new Date(), "Fetch failing paths: ");
            break;
    }

    return result;
}
 
开发者ID:ModelN,项目名称:build-management,代码行数:46,代码来源:CMnGitServer.java

示例7: apply

import org.eclipse.jgit.merge.ResolveMerger; //导入依赖的package包/类
@Override
public MergeableInfo apply(BranchResource resource)
    throws IOException, BadRequestException, ResourceNotFoundException {
  if (!(submitType.equals(SubmitType.MERGE_ALWAYS)
      || submitType.equals(SubmitType.MERGE_IF_NECESSARY))) {
    throw new BadRequestException("Submit type: " + submitType + " is not supported");
  }

  MergeableInfo result = new MergeableInfo();
  result.submitType = submitType;
  result.strategy = strategy;
  try (Repository git = gitManager.openRepository(resource.getNameKey());
      RevWalk rw = new RevWalk(git);
      ObjectInserter inserter = new InMemoryInserter(git)) {
    Merger m = MergeUtil.newMerger(inserter, git.getConfig(), strategy);

    Ref destRef = git.getRefDatabase().exactRef(resource.getRef());
    if (destRef == null) {
      throw new ResourceNotFoundException(resource.getRef());
    }

    RevCommit targetCommit = rw.parseCommit(destRef.getObjectId());
    RevCommit sourceCommit = MergeUtil.resolveCommit(git, rw, source);

    if (!commits.canRead(resource.getProjectState(), git, sourceCommit)) {
      throw new BadRequestException("do not have read permission for: " + source);
    }

    if (rw.isMergedInto(sourceCommit, targetCommit)) {
      result.mergeable = true;
      result.commitMerged = true;
      result.contentMerged = true;
      return result;
    }

    if (m.merge(false, targetCommit, sourceCommit)) {
      result.mergeable = true;
      result.commitMerged = false;
      result.contentMerged = m.getResultTreeId().equals(targetCommit.getTree());
    } else {
      result.mergeable = false;
      if (m instanceof ResolveMerger) {
        result.conflicts = ((ResolveMerger) m).getUnmergedPaths();
      }
    }
  } catch (IllegalArgumentException e) {
    throw new BadRequestException(e.getMessage());
  }
  return result;
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:51,代码来源:CheckMergeability.java


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