stage(cmds, c.copy());
roots.add(c.copy());
public CacheRevision( @Nullable RevCommit svnCommit, @NotNull Map<String, String> renames, @NotNull Map<String, CacheChange> fileChange ) { this(svnCommit == null ? null : svnCommit.copy(), renames, fileChange); }
public Value(RevCommit commit) { this.id = commit.copy(); this.author = commit.getAuthorIdent(); this.commitDate = commit.getCommitterIdent().getWhen(); this.summary = StringUtils.substringBefore(commit.getFullMessage(), "\n").trim(); }
@NotNull private CacheRevision loadCacheRevision(@NotNull ObjectReader reader, @NotNull RevCommit newCommit, int revisionId) throws IOException, SVNException { final ObjectId cacheKey = newCommit.copy(); CacheRevision result = revisionCache.get(cacheKey); if (result == null) { final RevCommit baseCommit = LayoutHelper.loadOriginalCommit(reader, newCommit); final GitFile oldTree = getSubversionTree(reader, newCommit.getParentCount() > 0 ? newCommit.getParent(0) : null, revisionId - 1); final GitFile newTree = getSubversionTree(reader, newCommit, revisionId); final Map<String, CacheChange> fileChange = new TreeMap<>(); for (Map.Entry<String, GitLogPair> entry : ChangeHelper.collectChanges(oldTree, newTree, true).entrySet()) { fileChange.put(entry.getKey(), new CacheChange(entry.getValue())); } result = new CacheRevision( baseCommit, collectRename(oldTree, newTree), fileChange ); revisionCache.put(cacheKey, result); } return result; }
/** * @return * merge base of specified commits, or <tt>null</tt> if two commits do not have related history. In this * case, these two commits can not be merged */ @Nullable public static ObjectId getMergeBase(Repository repository, ObjectId commit1, ObjectId commit2) { try (RevWalk revWalk = new RevWalk(repository)) { revWalk.setRevFilter(RevFilter.MERGE_BASE); revWalk.markStart(revWalk.parseCommit(commit1)); revWalk.markStart(revWalk.parseCommit(commit2)); RevCommit mergeBase = revWalk.next(); return mergeBase!=null?mergeBase.copy():null; } catch (IOException e) { throw new RuntimeException(e); } }
stage(cmds, c.copy());
stage(cmds, c.copy());
roots.add(c.copy());
roots.add(c.copy());
@Transactional @Override public void restoreSourceBranch(PullRequest request, String note) { Preconditions.checkState(!request.isOpen() && request.getSourceProject() != null); if (request.getSource().getObjectName(false) == null) { RevCommit latestCommit = request.getHeadCommit(); try { request.getSourceProject().git().branchCreate().setName(request.getSourceBranch()).setStartPoint(latestCommit).call(); } catch (Exception e) { throw ExceptionUtils.unchecked(e); } request.getSourceProject().cacheObjectId(request.getSourceBranch(), latestCommit.copy()); PullRequestChange change = new PullRequestChange(); change.setDate(new Date()); change.setData(new PullRequestSourceBranchRestoreData(note)); change.setRequest(request); change.setUser(userManager.getCurrent()); pullRequestChangeManager.save(change); } }
return headCommit.copy(); } catch (IOException e) { throw new RuntimeException(e);