diff src/org/tmatesoft/hg/internal/RepositoryComparator.java @ 652:cd77bf51b562

Push: tests. Commit respects phases.new-commit setting. Fix outgoing when changes are not children of common (Issue 47)
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Tue, 02 Jul 2013 23:21:16 +0200
parents 14dac192aa26
children 629a7370554c
line wrap: on
line diff
--- a/src/org/tmatesoft/hg/internal/RepositoryComparator.java	Mon Jul 01 21:19:53 2013 +0200
+++ b/src/org/tmatesoft/hg/internal/RepositoryComparator.java	Tue Jul 02 23:21:16 2013 +0200
@@ -95,7 +95,21 @@
 		if (c.isEmpty()) {
 			return localRepo.all();
 		} else {
-			return localRepo.childrenOf(c);
+			RevisionSet localHeads = new RevisionSet(localRepo.heads());
+			final List<Nodeid> commonChildren = localRepo.childrenOf(c);
+			final RevisionSet rsCommonChildren = new RevisionSet(commonChildren);
+			RevisionSet headsNotFromCommon = localHeads.subtract(rsCommonChildren);
+			if (headsNotFromCommon.isEmpty()) {
+				return commonChildren;
+			}
+			RevisionSet all = new RevisionSet(localRepo.all());
+			final RevisionSet rsCommon = new RevisionSet(c);
+			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);
+			return outgoing.union(rsCommonChildren).asList();
 		}
 	}