diff src/org/tmatesoft/hg/internal/RepositoryComparator.java @ 654:12a4f60ea972

1) Console push tool. 2) Pass class to blame into FileUtils
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Wed, 03 Jul 2013 15:11:40 +0200
parents 629a7370554c
children 822f3a83ff57
line wrap: on
line diff
--- a/src/org/tmatesoft/hg/internal/RepositoryComparator.java	Wed Jul 03 14:38:30 2013 +0200
+++ b/src/org/tmatesoft/hg/internal/RepositoryComparator.java	Wed Jul 03 15:11:40 2013 +0200
@@ -94,20 +94,24 @@
 		if (c.isEmpty()) {
 			return localRepo.all();
 		} else {
-			RevisionSet localHeads = new RevisionSet(localRepo.heads());
+			final RevisionSet rsCommon = new RevisionSet(c);
+			final RevisionSet localHeads = new RevisionSet(localRepo.heads());
 			final List<Nodeid> commonChildren = localRepo.childrenOf(c);
 			final RevisionSet rsCommonChildren = new RevisionSet(commonChildren);
-			RevisionSet headsNotFromCommon = localHeads.subtract(rsCommonChildren);
+			// check if there's any revision in the repository that doesn't trace to common
+			// e.g. branches from one of common ancestors
+			RevisionSet headsNotFromCommon = localHeads.subtract(rsCommonChildren).subtract(rsCommon);
 			if (headsNotFromCommon.isEmpty()) {
 				return commonChildren;
 			}
 			RevisionSet all = new RevisionSet(localRepo.all());
-			final RevisionSet rsCommon = new RevisionSet(c);
+			// need outgoing := ancestors(missing) - ancestors(common):
 			RevisionSet rsAncestors = all.ancestors(headsNotFromCommon, localRepo);
 			// #ancestors gives only parents, we need terminating children as well
 			rsAncestors = rsAncestors.union(headsNotFromCommon);
 			final RevisionSet rsAncestorsCommon = all.ancestors(rsCommon, localRepo);
 			RevisionSet outgoing = rsAncestors.subtract(rsAncestorsCommon).subtract(rsCommon);
+			// outgoing keeps children that spined off prior to common revisions
 			return outgoing.union(rsCommonChildren).asList();
 		}
 	}