Package org.eclipse.jgit.merge

Examples of org.eclipse.jgit.merge.ResolveMerger


        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('.');
View Full Code Here


                  Integer.valueOf(srcCommit.getParentCount())));

        RevCommit srcParent = srcCommit.getParent(0);
        revWalk.parseHeaders(srcParent);

        ResolveMerger merger = (ResolveMerger) MergeStrategy.RESOLVE
            .newMerger(repo);
        merger.setWorkingTreeIterator(new FileTreeIterator(repo));
        merger.setBase(srcParent.getTree());
        if (merger.merge(headCommit, srcCommit)) {
          if (AnyObjectId.equals(headCommit.getTree().getId(), merger
              .getResultTreeId()))
            continue;
          DirCacheCheckout dco = new DirCacheCheckout(repo,
              headCommit.getTree(), repo.lockDirCache(),
              merger.getResultTreeId());
          dco.setFailOnConflict(true);
          dco.checkout();
          newHead = new Git(getRepository()).commit()
              .setMessage(srcCommit.getFullMessage())
              .setReflogComment(
                  "cherry-pick: "
                      + srcCommit.getShortMessage())
              .setAuthor(srcCommit.getAuthorIdent()).call();
          cherryPickedRefs.add(src);
        } else {
          if (merger.failed())
            return new CherryPickResult(merger.getFailingPaths());

          // there are merge conflicts

          String message = new MergeMessageFormatter()
              .formatWithConflicts(srcCommit.getFullMessage(),
                  merger.getUnmergedPaths());

          repo.writeCherryPickHead(srcCommit.getId());
          repo.writeMergeCommitMsg(message);

          return CherryPickResult.CONFLICT;
View Full Code Here

              JGitText.get().canOnlyRevertCommitsWithOneParent);
        }
        RevCommit srcParent = srcCommit.getParent(0);
        revWalk.parseHeaders(srcParent);

        ResolveMerger merger = (ResolveMerger) MergeStrategy.RESOLVE
            .newMerger(repo);
        merger.setWorkingTreeIterator(new FileTreeIterator(repo));
        merger.setBase(srcCommit.getTree());

        if (merger.merge(headCommit, srcParent)) {
          if (AnyObjectId.equals(headCommit.getTree().getId(), merger
              .getResultTreeId()))
            continue;
          DirCacheCheckout dco = new DirCacheCheckout(repo,
              headCommit.getTree(), repo.lockDirCache(),
              merger.getResultTreeId());
          dco.setFailOnConflict(true);
          dco.checkout();
          String shortMessage = "Revert \"" + srcCommit.getShortMessage() + "\"";
          String newMessage = shortMessage + "\n\n"
              + "This reverts commit "
              + srcCommit.getId().getName() + ".\n";
          newHead = new Git(getRepository()).commit()
              .setMessage(newMessage)
              .setReflogComment("revert: " + shortMessage).call();
          revertedRefs.add(src);
        } else {
          unmergedPaths = merger.getUnmergedPaths();
          Map<String, MergeFailureReason> failingPaths = merger
              .getFailingPaths();
          if (failingPaths != null)
            failingResult = new MergeResult(null,
                merger.getBaseCommit(0, 1),
                new ObjectId[] { headCommit.getId(),
                    srcParent.getId() },
                MergeStatus.FAILED, MergeStrategy.RESOLVE,
                merger.getMergeResults(), failingPaths, null);
          return null;
        }
      }
    } catch (IOException e) {
      throw new JGitInternalException(
View Full Code Here

                              Integer.valueOf(srcCommit.getParentCount())));

         RevCommit srcParent = srcCommit.getParent(0);
         revWalk.parseHeaders(srcParent);

         ResolveMerger merger = (ResolveMerger) MergeStrategy.RESOLVE
                  .newMerger(repo);
         merger.setWorkingTreeIterator(new FileTreeIterator(repo));
         merger.setBase(srcParent.getTree());
         if (merger.merge(headCommit, srcCommit))
         {
            DirCacheCheckout dco = new DirCacheCheckout(repo,
                     headCommit.getTree(), repo.lockDirCache(),
                     merger.getResultTreeId());
            dco.setFailOnConflict(true);
            dco.checkout();

            cherryPickedRefs.add(src);
         }
         else
         {
            if (merger.failed())
               return new CherryPickResult(merger.getFailingPaths());

            // there are merge conflicts
            String message = new MergeMessageFormatter()
                     .formatWithConflicts(srcCommit.getFullMessage(),
                              merger.getUnmergedPaths());

            repo.writeCherryPickHead(srcCommit.getId());
            repo.writeMergeCommitMsg(message);

            return CherryPickResult.CONFLICT;
View Full Code Here

        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);

        if (noProblems) {
          DirCacheCheckout dco = new DirCacheCheckout(repo,
View Full Code Here

              JGitText.get().canOnlyCherryPickCommitsWithOneParent);
        }
        RevCommit srcParent = srcCommit.getParent(0);
        revWalk.parseHeaders(srcParent);

        ResolveMerger merger = (ResolveMerger) MergeStrategy.RESOLVE
            .newMerger(repo);
        merger.setWorkingTreeIterator(new FileTreeIterator(repo));
        merger.setBase(srcParent.getTree());

        if (merger.merge(headCommit, srcCommit)) {
          if (AnyObjectId.equals(headCommit.getTree().getId(), merger
              .getResultTreeId()))
            continue;
          DirCacheCheckout dco = new DirCacheCheckout(repo,
              headCommit.getTree(), repo.lockDirCache(),
              merger.getResultTreeId());
          dco.setFailOnConflict(true);
          dco.checkout();
          newHead = new Git(getRepository()).commit()
              .setMessage(srcCommit.getFullMessage())
              .setAuthor(srcCommit.getAuthorIdent()).call();
          cherryPickedRefs.add(src);
        } else {
          if (merger.failed())
            return new CherryPickResult(merger.getFailingPaths());

          // there are merge conflicts

          String message = new MergeMessageFormatter()
              .formatWithConflicts(srcCommit.getFullMessage(),
                  merger.getUnmergedPaths());

          repo.writeCherryPickHead(srcCommit.getId());
          repo.writeMergeCommitMsg(message);

          return CherryPickResult.CONFLICT;
View Full Code Here

              JGitText.get().canOnlyRevertCommitsWithOneParent);
        }
        RevCommit srcParent = srcCommit.getParent(0);
        revWalk.parseHeaders(srcParent);

        ResolveMerger merger = (ResolveMerger) MergeStrategy.RESOLVE
            .newMerger(repo);
        merger.setWorkingTreeIterator(new FileTreeIterator(repo));
        merger.setBase(srcCommit.getTree());

        if (merger.merge(headCommit, srcParent)) {
          if (AnyObjectId.equals(headCommit.getTree().getId(), merger
              .getResultTreeId()))
            continue;
          DirCacheCheckout dco = new DirCacheCheckout(repo,
              headCommit.getTree(), repo.lockDirCache(),
              merger.getResultTreeId());
          dco.setFailOnConflict(true);
          dco.checkout();
          String newMessage = "Revert \""
              + srcCommit.getShortMessage() + "\"" + "\n\n"
              + "This reverts commit "
View Full Code Here

                              Integer.valueOf(srcCommit.getParentCount())));

         RevCommit srcParent = srcCommit.getParent(0);
         revWalk.parseHeaders(srcParent);

         ResolveMerger merger = (ResolveMerger) MergeStrategy.RESOLVE
                  .newMerger(repo);
         merger.setWorkingTreeIterator(new FileTreeIterator(repo));
         merger.setBase(srcParent.getTree());
         if (merger.merge(headCommit, srcCommit))
         {
            DirCacheCheckout dco = new DirCacheCheckout(repo,
                     headCommit.getTree(), repo.lockDirCache(),
                     merger.getResultTreeId());
            dco.setFailOnConflict(true);
            dco.checkout();

            cherryPickedRefs.add(src);
         }
         else
         {
            if (merger.failed())
               return new CherryPickResult(merger.getFailingPaths());

            // there are merge conflicts
            String message = new MergeMessageFormatter()
                     .formatWithConflicts(srcCommit.getFullMessage(),
                              merger.getUnmergedPaths());

            repo.writeCherryPickHead(srcCommit.getId());
            repo.writeMergeCommitMsg(message);

            return CherryPickResult.CONFLICT;
View Full Code Here

    if (ref != null && ref.getObjectId() != null) {
      return rw.parseTree(ref.getObjectId());
    }

    ObjectId treeId;
    ResolveMerger m = (ResolveMerger) MergeStrategy.RESOLVE.newMerger(repo, true);
    final ObjectInserter ins = repo.newObjectInserter();
    try {
      DirCache dc = DirCache.newInCore();
      m.setDirCache(dc);
      m.setObjectInserter(new ObjectInserter.Filter() {
        @Override
        protected ObjectInserter delegate() {
          return ins;
        }

        @Override
        public void flush() {
        }

        @Override
        public void release() {
        }
      });

      boolean couldMerge = false;
      try {
        couldMerge = m.merge(b.getParents());
      } catch (IOException e) {
        //
      }

      if (couldMerge) {
        treeId = m.getResultTreeId();

      } else {
        RevCommit ours = b.getParent(0);
        RevCommit theirs = b.getParent(1);
        rw.parseBody(ours);
        rw.parseBody(theirs);
        String oursMsg = ours.getShortMessage();
        String theirsMsg = theirs.getShortMessage();

        String oursName = String.format("HEAD   (%s %s)",
            ours.abbreviate(6).name(),
            oursMsg.substring(0, Math.min(oursMsg.length(), 60)));
        String theirsName = String.format("BRANCH (%s %s)",
            theirs.abbreviate(6).name(),
            theirsMsg.substring(0, Math.min(theirsMsg.length(), 60)));

        MergeFormatter fmt = new MergeFormatter();
        Map<String, MergeResult<? extends Sequence>> r = m.getMergeResults();
        Map<String, ObjectId> resolved = new HashMap<String, ObjectId>();
        for (String path : r.keySet()) {
          MergeResult<? extends Sequence> p = r.get(path);
          TemporaryBuffer buf = new TemporaryBuffer.LocalFile(10 * 1024 * 1024);
          try {
View Full Code Here

        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());
View Full Code Here

TOP

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

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.