private void mergeNotesAndPush(RevWalk revWalk,String refName,RevCommit baseCommit,RevCommit localCommit,RevCommit originCommit) throws GitClientException {
  int remainingLockFailureCalls=JgitUtils.MAX_LOCK_FAILURE_CALLS;
  while (true) {
    try {
      NoteMap theirNoteMap=NoteMap.read(revWalk.getObjectReader(),originCommit);
      NoteMap ourNoteMap=NoteMap.read(revWalk.getObjectReader(),localCommit);
      NoteMap baseNoteMap;
      if (baseCommit != null) {
        baseNoteMap=NoteMap.read(revWalk.getObjectReader(),baseCommit);
      }
 else {
        baseNoteMap=NoteMap.newEmptyMap();
      }
      NoteMapMerger merger=new NoteMapMerger(repo,new DefaultNoteMerger(),MergeStrategy.RESOLVE);
      NoteMap merged=merger.merge(baseNoteMap,ourNoteMap,theirNoteMap);
      try (ObjectInserter inserter=repo.newObjectInserter()){
        RevCommit mergeCommit=createNotesCommit(merged,inserter,revWalk,"Merged note commits\n",localCommit,originCommit);
        RefUpdate update=JgitUtils.updateRef(repo,mergeCommit,localCommit,refName);
        Result result=update.update();
        if (result == Result.LOCK_FAILURE) {
          if (--remainingLockFailureCalls > 0) {
            Thread.sleep(JgitUtils.SLEEP_ON_LOCK_FAILURE_MS);
          }
 else {
            throw new GitClientException("Failed to lock the ref: " + refName);
          }
        }
 else         if (result == Result.REJECTED) {
          throw new GitClientException("Rejected update to " + refName + ", this is unexpected");
        }
 else         if (result == Result.IO_FAILURE) {
          throw new GitClientException("I/O failure merging notes");
        }
 else {
          break;
        }
      }
     }
 catch (    Exception e) {
      throw new GitClientException("Error merging notes commits",e);
    }
  }
  try {
    pushCommentsAndReviews();
  }
 catch (  Exception e) {
    throw new GitClientException("Error pushing merge commit",e);
  }
}

private void mergeNotesAndPush ( RevWalk revWalk , String refName , RevCommit baseCommit , RevCommit localCommit , RevCommit originCommit ) throws GitClientException { int remainingLockFailureCalls = JgitUtils . MAX_LOCK_FAILURE_CALLS ; while ( true ) { try { NoteMap theirNoteMap = NoteMap . read ( revWalk . getObjectReader ( ) , originCommit ) ; NoteMap ourNoteMap = NoteMap . read ( revWalk . getObjectReader ( ) , localCommit ) ; NoteMap baseNoteMap ; if ( baseCommit != null ) { baseNoteMap = NoteMap . read ( revWalk . getObjectReader ( ) , baseCommit ) ; } else { baseNoteMap = NoteMap . newEmptyMap ( ) ; } NoteMapMerger merger = new NoteMapMerger ( repo , new DefaultNoteMerger ( ) , MergeStrategy . RESOLVE ) ; NoteMap merged = merger . merge ( baseNoteMap , ourNoteMap , theirNoteMap ) ; try ( ObjectInserter inserter = repo . newObjectInserter ( ) ) { RevCommit mergeCommit = createNotesCommit ( merged , inserter , revWalk , "Merged note commits\n" , localCommit , originCommit ) ; RefUpdate update = JgitUtils . updateRef ( repo , mergeCommit , localCommit , refName ) ; Result result = update . update ( ) ; if ( result == Result . LOCK_FAILURE ) { if ( -- remainingLockFailureCalls > 0 ) { Thread . sleep ( JgitUtils . SLEEP_ON_LOCK_FAILURE_MS ) ; } else { throw new GitClientException ( "Failed to lock the ref: " + refName ) ; } } else if ( result == Result . REJECTED ) { throw new GitClientException ( "Rejected update to " + refName + ", this is unexpected" ) ; } else if ( result == Result . IO_FAILURE ) { throw new GitClientException ( "I/O failure merging notes" ) ; } else { break ; } } } catch ( Exception e ) { throw new GitClientException ( "Error merging notes commits" , e ) ; } } try { pushCommentsAndReviews ( ) ; } catch ( Exception e ) { throw new GitClientException ( "Error pushing merge commit" , e ) ; } }
merges the notes from local and origin commits with the given merge base .
