List of usage examples for org.eclipse.jgit.notes NoteMap newEmptyMap
public static NoteMap newEmptyMap()
From source file:com.google.gerrit.server.notedb.ChangeUpdate.java
License:Apache License
/** @return the tree id for the updated tree */ private ObjectId storeCommentsInNotes() throws OrmException, IOException { ChangeNotes notes = ctl.getNotes().load(); NoteMap noteMap = notes.getNoteMap(); if (noteMap == null) { noteMap = NoteMap.newEmptyMap(); }//w w w. j a v a2 s . co m if (comments.isEmpty()) { return null; } Map<RevId, List<PatchLineComment>> allComments = Maps.newHashMap(); for (Map.Entry<RevId, Collection<PatchLineComment>> e : notes.getComments().asMap().entrySet()) { List<PatchLineComment> comments = new ArrayList<>(); for (PatchLineComment c : e.getValue()) { comments.add(c); } allComments.put(e.getKey(), comments); } for (PatchLineComment c : comments) { addCommentToMap(allComments, c); } commentsUtil.writeCommentsToNoteMap(noteMap, allComments, inserter); return noteMap.writeTree(inserter); }
From source file:com.google.gerrit.server.notedb.RevisionNoteMap.java
License:Apache License
static RevisionNoteMap emptyMap() { return new RevisionNoteMap(NoteMap.newEmptyMap(), ImmutableMap.<RevId, RevisionNote>of()); }
From source file:com.google.gerrit.server.notedb.RobotCommentUpdate.java
License:Apache License
private RevisionNoteMap<RobotCommentsRevisionNote> getRevisionNoteMap(RevWalk rw, ObjectId curr) throws ConfigInvalidException, OrmException, IOException { if (curr.equals(ObjectId.zeroId())) { return RevisionNoteMap.emptyMap(); }/*from w ww. jav a 2 s .com*/ if (migration.readChanges()) { // If reading from changes is enabled, then the old RobotCommentNotes // already parsed the revision notes. We can reuse them as long as the ref // hasn't advanced. ChangeNotes changeNotes = getNotes(); if (changeNotes != null) { RobotCommentNotes robotCommentNotes = changeNotes.load().getRobotCommentNotes(); if (robotCommentNotes != null) { ObjectId idFromNotes = firstNonNull(robotCommentNotes.getRevision(), ObjectId.zeroId()); RevisionNoteMap<RobotCommentsRevisionNote> rnm = robotCommentNotes.getRevisionNoteMap(); if (idFromNotes.equals(curr) && rnm != null) { return rnm; } } } } NoteMap noteMap; if (!curr.equals(ObjectId.zeroId())) { noteMap = NoteMap.read(rw.getObjectReader(), rw.parseCommit(curr)); } else { noteMap = NoteMap.newEmptyMap(); } // Even though reading from changes might not be enabled, we need to // parse any existing revision notes so we can merge them. return RevisionNoteMap.parseRobotComments(noteUtil, rw.getObjectReader(), noteMap); }