You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@netbeans.apache.org by GitBox <gi...@apache.org> on 2018/01/29 06:32:18 UTC
[GitHub] JaroslavTulach closed pull request #391: Support git replace in search history window
JaroslavTulach closed pull request #391: Support git replace in search history window
URL: https://github.com/apache/incubator-netbeans/pull/391
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/libs.git/src/org/netbeans/libs/git/jgit/commands/LogCommand.java b/libs.git/src/org/netbeans/libs/git/jgit/commands/LogCommand.java
index 9327aed31..c874fe9f7 100644
--- a/libs.git/src/org/netbeans/libs/git/jgit/commands/LogCommand.java
+++ b/libs.git/src/org/netbeans/libs/git/jgit/commands/LogCommand.java
@@ -28,7 +28,6 @@
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
@@ -39,6 +38,7 @@
import org.eclipse.jgit.diff.DiffConfig;
import org.eclipse.jgit.errors.MissingObjectException;
import org.eclipse.jgit.lib.Constants;
+import org.eclipse.jgit.lib.Ref;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.revwalk.FollowFilter;
import org.eclipse.jgit.revwalk.RevCommit;
@@ -151,11 +151,37 @@ protected void run () throws GitException {
walk.sort(RevSort.TOPO);
walk.sort(RevSort.COMMIT_TIME_DESC, true);
int remaining = criteria.getLimit();
- for (Iterator<RevCommit> it = walk.iterator(); it.hasNext() && !monitor.isCanceled() && remaining != 0;) {
- RevCommit commit = it.next();
- addRevision(getClassFactory().createRevisionInfo(fullWalk.parseCommit(commit),
- getAffectedBranches(commit, branchFlags), repository));
- --remaining;
+ Map<String, GitBranch> extraBranches = null;
+ while (remaining-- > 0) {
+ if (monitor.isCanceled()) {
+ break;
+ }
+ RevCommit commit = walk.next();
+ if (commit == null) {
+ break;
+ }
+ final Map<String, GitBranch> branches = getAffectedBranches(extraBranches, commit, branchFlags);
+ addRevision(getClassFactory().createRevisionInfo(
+ fullWalk.parseCommit(commit), branches, repository)
+ );
+ if (commit.getParentCount() == 0) {
+ Ref replace = repository.getAllRefs().get("refs/replace/" + commit.getId().getName());
+ if (replace != null) {
+ final RevCommit newCommit = Utils.findCommit(repository, replace.getTarget().getName());
+ if (newCommit != null) {
+ if (extraBranches == null) {
+ extraBranches = branches;
+ } else {
+ extraBranches.putAll(branches);
+ }
+ walk.reset();
+ walk.markStart(markStartCommit(walk.lookupCommit(newCommit), interestingFlag));
+ applyCriteria(walk, criteria, interestingFlag, diffConfig);
+ walk.sort(RevSort.TOPO);
+ walk.sort(RevSort.COMMIT_TIME_DESC, true);
+ }
+ }
+ }
}
} catch (MissingObjectException ex) {
throw new GitException.MissingObjectException(ex.getObjectId().toString(), GitObjectType.COMMIT);
@@ -302,8 +328,10 @@ private RevCommit markStartCommit (RevCommit commit, RevFlag interestingFlag) {
return commit;
}
- private Map<String, GitBranch> getAffectedBranches (RevCommit commit, Map<RevFlag, List<GitBranch>> flags) {
- Map<String, GitBranch> affected = new LinkedHashMap<>();
+ private Map<String, GitBranch> getAffectedBranches (Map<String, GitBranch> extraBranches, RevCommit commit, Map<RevFlag, List<GitBranch>> flags) {
+ Map<String, GitBranch> affected = new LinkedHashMap<>(
+ extraBranches == null ? Collections.<String, GitBranch>emptyMap() : extraBranches
+ );
for (Map.Entry<RevFlag, List<GitBranch>> e : flags.entrySet()) {
if (commit.has(e.getKey())) {
for (GitBranch b : e.getValue()) {
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists