List of usage examples for org.eclipse.jgit.lib ObjectId copy
public final ObjectId copy()
From source file:com.google.gerrit.server.git.GroupCollector.java
License:Apache License
public SetMultimap<ObjectId, String> getGroups() throws OrmException { done = true;/*from w w w.j a va 2s. co m*/ SetMultimap<ObjectId, String> result = MultimapBuilder.hashKeys(groups.keySet().size()).treeSetValues() .build(); for (Map.Entry<ObjectId, Collection<String>> e : groups.asMap().entrySet()) { ObjectId id = e.getKey(); result.putAll(id.copy(), resolveGroups(id, e.getValue())); } return result; }
From source file:com.google.gerrit.server.notedb.ChangeNotesCache.java
License:Apache License
Value get(Project.NameKey project, Change.Id changeId, ObjectId metaId, ChangeNotesRevWalk rw) throws IOException { try {/*from w w w.jav a2s. c o m*/ Key key = new AutoValue_ChangeNotesCache_Key(project, changeId, metaId.copy()); Loader loader = new Loader(key, rw); ChangeNotesState s = cache.get(key, loader); return new AutoValue_ChangeNotesCache_Value(s, loader.revisionNoteMap); } catch (ExecutionException e) { throw new IOException(String.format("Error loading %s in %s at %s", RefNames.changeMetaRef(changeId), project, metaId.name()), e); } }
From source file:com.google.gerrit.server.schema.Schema_108.java
License:Apache License
private static void updateProjectGroups(ReviewDb db, Repository repo, RevWalk rw, Set<Change.Id> changes) throws OrmException, IOException { // Match sorting in ReceiveCommits. rw.reset();/* w ww . ja v a2 s. c om*/ rw.sort(RevSort.TOPO); rw.sort(RevSort.REVERSE, true); RefDatabase refdb = repo.getRefDatabase(); for (Ref ref : refdb.getRefs(Constants.R_HEADS).values()) { RevCommit c = maybeParseCommit(rw, ref.getObjectId()); if (c != null) { rw.markUninteresting(c); } } Multimap<ObjectId, Ref> changeRefsBySha = ArrayListMultimap.create(); Multimap<ObjectId, PatchSet.Id> patchSetsBySha = ArrayListMultimap.create(); for (Ref ref : refdb.getRefs(RefNames.REFS_CHANGES).values()) { ObjectId id = ref.getObjectId(); if (ref.getObjectId() == null) { continue; } id = id.copy(); changeRefsBySha.put(id, ref); PatchSet.Id psId = PatchSet.Id.fromRef(ref.getName()); if (psId != null && changes.contains(psId.getParentKey())) { patchSetsBySha.put(id, psId); RevCommit c = maybeParseCommit(rw, id); if (c != null) { rw.markStart(c); } } } GroupCollector collector = new GroupCollector(changeRefsBySha, db); RevCommit c; while ((c = rw.next()) != null) { collector.visit(c); } updateGroups(db, collector, patchSetsBySha); }
From source file:com.google.gitiles.blame.BlameCacheImpl.java
License:Open Source License
private static List<Region> loadRegions(BlameGenerator gen) throws IOException { Map<ObjectId, PooledCommit> commits = Maps.newHashMap(); Interner<String> strings = Interners.newStrongInterner(); int lineCount = gen.getResultContents().size(); List<Region> regions = Lists.newArrayList(); while (gen.next()) { String path = gen.getSourcePath(); PersonIdent author = gen.getSourceAuthor(); ObjectId commit = gen.getSourceCommit(); checkState(path != null && author != null && commit != null); PooledCommit pc = commits.get(commit); if (pc == null) { pc = new PooledCommit(commit.copy(), new PersonIdent(strings.intern(author.getName()), strings.intern(author.getEmailAddress()), author.getWhen(), author.getTimeZone())); commits.put(pc.commit, pc);// w w w.java 2 s . c o m } path = strings.intern(path); commit = pc.commit; author = pc.author; regions.add(new Region(path, commit, author, gen.getResultStart(), gen.getResultEnd())); } Collections.sort(regions); // Fill in any gaps left by bugs in JGit, since rendering code assumes the // full set of contiguous regions. List<Region> result = Lists.newArrayListWithExpectedSize(regions.size()); Region last = null; for (Region r : regions) { if (last != null) { checkState(last.getEnd() <= r.getStart()); if (last.getEnd() < r.getStart()) { result.add(new Region(null, null, null, last.getEnd(), r.getStart())); } } result.add(r); last = r; } if (last != null && last.getEnd() != lineCount) { result.add(new Region(null, null, null, last.getEnd(), lineCount)); } return ImmutableList.copyOf(result); }
From source file:org.jenkinsci.git.BuildRepositoryState.java
License:Open Source License
/** * Insert a mapping between a repository and an object id * * @param repo/* w ww . ja va 2 s . co m*/ * @param id * @return this repository state */ public BuildRepositoryState put(BuildRepository repo, ObjectId id) { if (repo == null || id == null) return this; states.put(repo, id.copy()); return this; }
From source file:svnserver.repository.git.cache.CacheChange.java
License:GNU General Public License
public CacheChange(@Nullable ObjectId oldFile, @Nullable ObjectId newFile) { this.oldFile = oldFile != null ? oldFile.copy() : null; this.newFile = newFile != null ? newFile.copy() : null; }