Package org.eclipse.jgit.merge

Examples of org.eclipse.jgit.merge.Merger


        String mergeMessage = new MergeMessageFormatter().format(
            commits, head);
        repo.writeMergeCommitMsg(mergeMessage);
        repo.writeMergeHeads(Arrays.asList(ref.getObjectId()));
        Merger merger = mergeStrategy.newMerger(repo);
        boolean noProblems;
        Map<String, org.eclipse.jgit.merge.MergeResult<?>> lowLevelResults = null;
        Map<String, MergeFailureReason> failingPaths = null;
        List<String> unmergedPaths = null;
        if (merger instanceof ResolveMerger) {
          ResolveMerger resolveMerger = (ResolveMerger) merger;
          resolveMerger.setCommitNames(new String[] {
              "BASE", "HEAD", ref.getName() });
          resolveMerger.setWorkingTreeIterator(new FileTreeIterator(repo));
          noProblems = merger.merge(headCommit, srcCommit);
          lowLevelResults = resolveMerger
              .getMergeResults();
          failingPaths = resolveMerger.getFailingPaths();
          unmergedPaths = resolveMerger.getUnmergedPaths();
        } else
          noProblems = merger.merge(headCommit, srcCommit);
        refLogMessage.append(": Merge made by ");
        refLogMessage.append(mergeStrategy.getName());
        refLogMessage.append('.');
        if (noProblems) {
          dco = new DirCacheCheckout(repo,
              headCommit.getTree(), repo.lockDirCache(),
              merger.getResultTreeId());
          dco.setFailOnConflict(true);
          dco.checkout();

          RevCommit newHead = new Git(getRepository()).commit()
              .setReflogComment(refLogMessage.toString()).call();
          return new MergeResult(newHead.getId(),
              null, new ObjectId[] {
                  headCommit.getId(), srcCommit.getId() },
              MergeStatus.MERGED, mergeStrategy, null, null);
        } else {
          if (failingPaths != null) {
            repo.writeMergeCommitMsg(null);
            repo.writeMergeHeads(null);
            return new MergeResult(null,
                merger.getBaseCommit(0, 1),
                new ObjectId[] {
                    headCommit.getId(), srcCommit.getId() },
                MergeStatus.FAILED, mergeStrategy,
                lowLevelResults, failingPaths, null);
          } else {
            String mergeMessageWithConflicts = new MergeMessageFormatter()
                .formatWithConflicts(mergeMessage,
                    unmergedPaths);
            repo.writeMergeCommitMsg(mergeMessageWithConflicts);
            return new MergeResult(null,
                merger.getBaseCommit(0, 1),
                new ObjectId[] { headCommit.getId(),
                    srcCommit.getId() },
                MergeStatus.CONFLICTING, mergeStrategy,
                lowLevelResults, null);
          }
View Full Code Here


              revWalk, srcCommit, headCommit);
          String squashMessage = new SquashMessageFormatter().format(
              squashedCommits, head);
          repo.writeSquashCommitMsg(squashMessage);
        }
        Merger merger = mergeStrategy.newMerger(repo);
        boolean noProblems;
        Map<String, org.eclipse.jgit.merge.MergeResult<?>> lowLevelResults = null;
        Map<String, MergeFailureReason> failingPaths = null;
        List<String> unmergedPaths = null;
        if (merger instanceof ResolveMerger) {
          ResolveMerger resolveMerger = (ResolveMerger) merger;
          resolveMerger.setCommitNames(new String[] {
              "BASE", "HEAD", ref.getName() });
          resolveMerger.setWorkingTreeIterator(new FileTreeIterator(repo));
          noProblems = merger.merge(headCommit, srcCommit);
          lowLevelResults = resolveMerger
              .getMergeResults();
          failingPaths = resolveMerger.getFailingPaths();
          unmergedPaths = resolveMerger.getUnmergedPaths();
        } else
          noProblems = merger.merge(headCommit, srcCommit);
        refLogMessage.append(": Merge made by ");
        if (!revWalk.isMergedInto(headCommit, srcCommit))
          refLogMessage.append(mergeStrategy.getName());
        else
          refLogMessage.append("recursive");
        refLogMessage.append('.');
        if (noProblems) {
          dco = new DirCacheCheckout(repo,
              headCommit.getTree(), repo.lockDirCache(),
              merger.getResultTreeId());
          dco.setFailOnConflict(true);
          dco.checkout();

          String msg = null;
          RevCommit newHead = null;
          MergeStatus mergeStatus = null;
          if (!squash) {
            newHead = new Git(getRepository()).commit()
              .setReflogComment(refLogMessage.toString()).call();
            mergeStatus = MergeStatus.MERGED;
          } else {
            msg = JGitText.get().squashCommitNotUpdatingHEAD;
            newHead = headCommit;
            mergeStatus = MergeStatus.MERGED_SQUASHED;
          }
          return new MergeResult(newHead.getId(), null,
              new ObjectId[] { headCommit.getId(),
                  srcCommit.getId() }, mergeStatus,
              mergeStrategy, null, msg);
        } else {
          if (failingPaths != null) {
            repo.writeMergeCommitMsg(null);
            repo.writeMergeHeads(null);
            return new MergeResult(null,
                merger.getBaseCommit(0, 1),
                new ObjectId[] {
                    headCommit.getId(), srcCommit.getId() },
                MergeStatus.FAILED, mergeStrategy,
                lowLevelResults, failingPaths, null);
          } else {
            String mergeMessageWithConflicts = new MergeMessageFormatter()
                .formatWithConflicts(mergeMessage,
                    unmergedPaths);
            repo.writeMergeCommitMsg(mergeMessageWithConflicts);
            return new MergeResult(null,
                merger.getBaseCommit(0, 1),
                new ObjectId[] { headCommit.getId(),
                    srcCommit.getId() },
                MergeStatus.CONFLICTING, mergeStrategy,
                lowLevelResults, null);
          }
View Full Code Here

        throw new NotesMergeConflictException(baseList, oursList,
            theirsList);

      resultTreeId = m.getResultTreeId();
    } else {
      Merger m = nonNotesMergeStrategy.newMerger(db, true);
      if (!m.merge(new AnyObjectId[] { oursId, theirsId }))
        throw new NotesMergeConflictException(baseList, oursList,
            theirsList);
      resultTreeId = m.getResultTreeId();
    }
    AbbreviatedObjectId none = AbbreviatedObjectId.fromString("");
    return NoteParser.parse(none, resultTreeId, reader).nonNotes;
  }
View Full Code Here

              revWalk, srcCommit, headCommit);
          String squashMessage = new SquashMessageFormatter().format(
              squashedCommits, head);
          repo.writeSquashCommitMsg(squashMessage);
        }
        Merger merger = mergeStrategy.newMerger(repo);
        boolean noProblems;
        Map<String, org.eclipse.jgit.merge.MergeResult<?>> lowLevelResults = null;
        Map<String, MergeFailureReason> failingPaths = null;
        List<String> unmergedPaths = null;
        if (merger instanceof ResolveMerger) {
          ResolveMerger resolveMerger = (ResolveMerger) merger;
          resolveMerger.setCommitNames(new String[] {
              "BASE", "HEAD", ref.getName() }); //$NON-NLS-1$ //$NON-NLS-2$
          resolveMerger.setWorkingTreeIterator(new FileTreeIterator(repo));
          noProblems = merger.merge(headCommit, srcCommit);
          lowLevelResults = resolveMerger
              .getMergeResults();
          failingPaths = resolveMerger.getFailingPaths();
          unmergedPaths = resolveMerger.getUnmergedPaths();
        } else
          noProblems = merger.merge(headCommit, srcCommit);
        refLogMessage.append(": Merge made by "); //$NON-NLS-1$
        if (!revWalk.isMergedInto(headCommit, srcCommit))
          refLogMessage.append(mergeStrategy.getName());
        else
          refLogMessage.append("recursive"); //$NON-NLS-1$
        refLogMessage.append('.');
        if (noProblems) {
          dco = new DirCacheCheckout(repo,
              headCommit.getTree(), repo.lockDirCache(),
              merger.getResultTreeId());
          dco.setFailOnConflict(true);
          dco.checkout();

          String msg = null;
          ObjectId newHeadId = null;
          MergeStatus mergeStatus = null;
          if (!commit && squash) {
            mergeStatus = MergeStatus.MERGED_SQUASHED_NOT_COMMITTED;
          }
          if (!commit && !squash) {
            mergeStatus = MergeStatus.MERGED_NOT_COMMITTED;
          }
          if (commit && !squash) {
            newHeadId = new Git(getRepository()).commit()
                .setReflogComment(refLogMessage.toString())
                .call().getId();
            mergeStatus = MergeStatus.MERGED;
          }
          if (commit && squash) {
            msg = JGitText.get().squashCommitNotUpdatingHEAD;
            newHeadId = headCommit.getId();
            mergeStatus = MergeStatus.MERGED_SQUASHED;
          }
          return new MergeResult(newHeadId, null,
              new ObjectId[] { headCommit.getId(),
                  srcCommit.getId() }, mergeStatus,
              mergeStrategy, null, msg);
        } else {
          if (failingPaths != null) {
            repo.writeMergeCommitMsg(null);
            repo.writeMergeHeads(null);
            return new MergeResult(null, merger.getBaseCommitId(),
                new ObjectId[] {
                    headCommit.getId(), srcCommit.getId() },
                MergeStatus.FAILED, mergeStrategy,
                lowLevelResults, failingPaths, null);
          } else {
            String mergeMessageWithConflicts = new MergeMessageFormatter()
                .formatWithConflicts(mergeMessage,
                    unmergedPaths);
            repo.writeMergeCommitMsg(mergeMessageWithConflicts);
            return new MergeResult(null, merger.getBaseCommitId(),
                new ObjectId[] { headCommit.getId(),
                    srcCommit.getId() },
                MergeStatus.CONFLICTING, mergeStrategy,
                lowLevelResults, null);
          }
View Full Code Here

    ObjectId baseId = write(baseList);
    ObjectId oursId = write(oursList);
    ObjectId theirsId = write(theirsList);
    inserter.flush();

    Merger m = nonNotesMergeStrategy.newMerger(db, true);
    if (m instanceof ThreeWayMerger)
      ((ThreeWayMerger) m).setBase(baseId);
    if (!m.merge(oursId, theirsId))
      throw new NotesMergeConflictException(baseList, oursList,
          theirsList);
    ObjectId resultTreeId = m.getResultTreeId();
    AbbreviatedObjectId none = AbbreviatedObjectId.fromString(""); //$NON-NLS-1$
    return NoteParser.parse(none, resultTreeId, reader).nonNotes;
  }
View Full Code Here

        .create();
    RevCommit b2Tip = tr.branch("b2").commit().parent(parent).add("y", "y")
        .create();

    // merge b1Tip and b2Tip and update refs/heads/b1 to the merge commit
    Merger merger = MergeStrategy.SIMPLE_TWO_WAY_IN_CORE.newMerger(repo);
    merger.merge(b1Tip, b2Tip);
    CommitBuilder cb = tr.commit();
    cb.parent(b1Tip).parent(b2Tip);
    cb.setTopLevelTree(merger.getResultTreeId());
    RevCommit mergeCommit = cb.create();
    RefUpdate u = repo.updateRef("refs/heads/b1");
    u.setNewObjectId(mergeCommit);
    u.update();
View Full Code Here

        String mergeMessage = new MergeMessageFormatter().format(
            commits, head);
        repo.writeMergeCommitMsg(mergeMessage);
        repo.writeMergeHeads(Arrays.asList(ref.getObjectId()));
        Merger merger = mergeStrategy.newMerger(repo);
        boolean noProblems;
        Map<String, org.eclipse.jgit.merge.MergeResult<?>> lowLevelResults = null;
        Map<String, MergeFailureReason> failingPaths = null;
        List<String> unmergedPaths = null;
        if (merger instanceof ResolveMerger) {
          ResolveMerger resolveMerger = (ResolveMerger) merger;
          resolveMerger.setCommitNames(new String[] {
              "BASE", "HEAD", ref.getName() });
          resolveMerger.setWorkingTreeIterator(new FileTreeIterator(repo));
          noProblems = merger.merge(headCommit, srcCommit);
          lowLevelResults = resolveMerger
              .getMergeResults();
          failingPaths = resolveMerger.getFailingPaths();
          unmergedPaths = resolveMerger.getUnmergedPaths();
        } else
          noProblems = merger.merge(headCommit, srcCommit);
        refLogMessage.append(": Merge made by ");
        refLogMessage.append(mergeStrategy.getName());
        refLogMessage.append('.');
        if (noProblems) {
          dco = new DirCacheCheckout(repo,
              headCommit.getTree(), repo.lockDirCache(),
              merger.getResultTreeId());
          dco.setFailOnConflict(true);
          dco.checkout();

          RevCommit newHead = new Git(getRepository()).commit()
              .setReflogComment(refLogMessage.toString()).call();
          return new MergeResult(newHead.getId(),
              null, new ObjectId[] {
                  headCommit.getId(), srcCommit.getId() },
              MergeStatus.MERGED, mergeStrategy, null, null);
        } else {
          if (failingPaths != null) {
            repo.writeMergeCommitMsg(null);
            repo.writeMergeHeads(null);
            return new MergeResult(null,
                merger.getBaseCommit(0, 1),
                new ObjectId[] {
                    headCommit.getId(), srcCommit.getId() },
                MergeStatus.FAILED, mergeStrategy,
                lowLevelResults, failingPaths, null);
          } else {
            String mergeMessageWithConflicts = new MergeMessageFormatter()
                .formatWithConflicts(mergeMessage,
                    unmergedPaths);
            repo.writeMergeCommitMsg(mergeMessageWithConflicts);
            return new MergeResult(null,
                merger.getBaseCommit(0, 1),
                new ObjectId[] { headCommit.getId(),
                    srcCommit.getId() },
                MergeStatus.CONFLICTING, mergeStrategy,
                lowLevelResults, null);
          }
View Full Code Here

    ObjectId baseId = write(baseList);
    ObjectId oursId = write(oursList);
    ObjectId theirsId = write(theirsList);
    inserter.flush();

    Merger m = nonNotesMergeStrategy.newMerger(db, true);
    if (m instanceof ThreeWayMerger)
      ((ThreeWayMerger) m).setBase(baseId);
    if (!m.merge(oursId, theirsId))
      throw new NotesMergeConflictException(baseList, oursList,
          theirsList);
    ObjectId resultTreeId = m.getResultTreeId();
    AbbreviatedObjectId none = AbbreviatedObjectId.fromString("");
    return NoteParser.parse(none, resultTreeId, reader).nonNotes;
  }
View Full Code Here

              revWalk, srcCommit, headCommit);
          String squashMessage = new SquashMessageFormatter().format(
              squashedCommits, head);
          repo.writeSquashCommitMsg(squashMessage);
        }
        Merger merger = mergeStrategy.newMerger(repo);
        boolean noProblems;
        Map<String, org.eclipse.jgit.merge.MergeResult<?>> lowLevelResults = null;
        Map<String, MergeFailureReason> failingPaths = null;
        List<String> unmergedPaths = null;
        if (merger instanceof ResolveMerger) {
          ResolveMerger resolveMerger = (ResolveMerger) merger;
          resolveMerger.setCommitNames(new String[] {
              "BASE", "HEAD", ref.getName() });
          resolveMerger.setWorkingTreeIterator(new FileTreeIterator(repo));
          noProblems = merger.merge(headCommit, srcCommit);
          lowLevelResults = resolveMerger
              .getMergeResults();
          failingPaths = resolveMerger.getFailingPaths();
          unmergedPaths = resolveMerger.getUnmergedPaths();
        } else
          noProblems = merger.merge(headCommit, srcCommit);
        refLogMessage.append(": Merge made by ");
        refLogMessage.append(mergeStrategy.getName());
        refLogMessage.append('.');
        if (noProblems) {
          dco = new DirCacheCheckout(repo,
              headCommit.getTree(), repo.lockDirCache(),
              merger.getResultTreeId());
          dco.setFailOnConflict(true);
          dco.checkout();

          String msg = null;
          RevCommit newHead = null;
          MergeStatus mergeStatus = null;
          if (!squash) {
            newHead = new Git(getRepository()).commit()
              .setReflogComment(refLogMessage.toString()).call();
            mergeStatus = MergeStatus.MERGED;
          } else {
            msg = JGitText.get().squashCommitNotUpdatingHEAD;
            newHead = headCommit;
            mergeStatus = MergeStatus.MERGED_SQUASHED;
          }
          return new MergeResult(newHead.getId(), null,
              new ObjectId[] { headCommit.getId(),
                  srcCommit.getId() }, mergeStatus,
              mergeStrategy, null, msg);
        } else {
          if (failingPaths != null) {
            repo.writeMergeCommitMsg(null);
            repo.writeMergeHeads(null);
            return new MergeResult(null,
                merger.getBaseCommit(0, 1),
                new ObjectId[] {
                    headCommit.getId(), srcCommit.getId() },
                MergeStatus.FAILED, mergeStrategy,
                lowLevelResults, failingPaths, null);
          } else {
            String mergeMessageWithConflicts = new MergeMessageFormatter()
                .formatWithConflicts(mergeMessage,
                    unmergedPaths);
            repo.writeMergeCommitMsg(mergeMessageWithConflicts);
            return new MergeResult(null,
                merger.getBaseCommit(0, 1),
                new ObjectId[] { headCommit.getId(),
                    srcCommit.getId() },
                MergeStatus.CONFLICTING, mergeStrategy,
                lowLevelResults, null);
          }
View Full Code Here

              revWalk, srcCommit, headCommit);
          String squashMessage = new SquashMessageFormatter().format(
              squashedCommits, head);
          repo.writeSquashCommitMsg(squashMessage);
        }
        Merger merger = mergeStrategy.newMerger(repo);
        boolean noProblems;
        Map<String, org.eclipse.jgit.merge.MergeResult<?>> lowLevelResults = null;
        Map<String, MergeFailureReason> failingPaths = null;
        List<String> unmergedPaths = null;
        if (merger instanceof ResolveMerger) {
          ResolveMerger resolveMerger = (ResolveMerger) merger;
          resolveMerger.setCommitNames(new String[] {
              "BASE", "HEAD", ref.getName() }); //$NON-NLS-1$
          resolveMerger.setWorkingTreeIterator(new FileTreeIterator(repo));
          noProblems = merger.merge(headCommit, srcCommit);
          lowLevelResults = resolveMerger
              .getMergeResults();
          failingPaths = resolveMerger.getFailingPaths();
          unmergedPaths = resolveMerger.getUnmergedPaths();
        } else
          noProblems = merger.merge(headCommit, srcCommit);
        refLogMessage.append(": Merge made by "); //$NON-NLS-1$
        if (!revWalk.isMergedInto(headCommit, srcCommit))
          refLogMessage.append(mergeStrategy.getName());
        else
          refLogMessage.append("recursive"); //$NON-NLS-1$
        refLogMessage.append('.');
        if (noProblems) {
          dco = new DirCacheCheckout(repo,
              headCommit.getTree(), repo.lockDirCache(),
              merger.getResultTreeId());
          dco.setFailOnConflict(true);
          dco.checkout();

          String msg = null;
          RevCommit newHead = null;
          MergeStatus mergeStatus = null;
          if (!squash) {
            newHead = new Git(getRepository()).commit()
              .setReflogComment(refLogMessage.toString()).call();
            mergeStatus = MergeStatus.MERGED;
          } else {
            msg = JGitText.get().squashCommitNotUpdatingHEAD;
            newHead = headCommit;
            mergeStatus = MergeStatus.MERGED_SQUASHED;
          }
          return new MergeResult(newHead.getId(), null,
              new ObjectId[] { headCommit.getId(),
                  srcCommit.getId() }, mergeStatus,
              mergeStrategy, null, msg);
        } else {
          if (failingPaths != null) {
            repo.writeMergeCommitMsg(null);
            repo.writeMergeHeads(null);
            return new MergeResult(null,
                merger.getBaseCommit(0, 1),
                new ObjectId[] {
                    headCommit.getId(), srcCommit.getId() },
                MergeStatus.FAILED, mergeStrategy,
                lowLevelResults, failingPaths, null);
          } else {
            String mergeMessageWithConflicts = new MergeMessageFormatter()
                .formatWithConflicts(mergeMessage,
                    unmergedPaths);
            repo.writeMergeCommitMsg(mergeMessageWithConflicts);
            return new MergeResult(null,
                merger.getBaseCommit(0, 1),
                new ObjectId[] { headCommit.getId(),
                    srcCommit.getId() },
                MergeStatus.CONFLICTING, mergeStrategy,
                lowLevelResults, null);
          }
View Full Code Here

TOP

Related Classes of org.eclipse.jgit.merge.Merger

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.