mercurial/discovery.py
branchstable
changeset 16736 025b3b763ba9
parent 16535 39d1f83eb05d
child 16746 9acb5cd19162
--- a/mercurial/discovery.py	Mon May 14 19:25:13 2012 -0400
+++ b/mercurial/discovery.py	Sat May 12 19:38:20 2012 +0200
@@ -86,7 +86,8 @@
             self._computecommonmissing()
         return self._missing
 
-def findcommonoutgoing(repo, other, onlyheads=None, force=False, commoninc=None):
+def findcommonoutgoing(repo, other, onlyheads=None, force=False, commoninc=None,
+                       portable=False):
     '''Return an outgoing instance to identify the nodes present in repo but
     not in other.
 
@@ -95,7 +96,10 @@
     onlyheads is faster than letting them be recomputed here.
 
     If commoninc is given, it must the the result of a prior call to
-    findcommonincoming(repo, other, force) to avoid recomputing it here.'''
+    findcommonincoming(repo, other, force) to avoid recomputing it here.
+
+    If portable is given, compute more conservative common and missingheads,
+    to make bundles created from the instance more portable.'''
     # declare an empty outgoing object to be filled later
     og = outgoing(repo.changelog, None, None)
 
@@ -129,6 +133,17 @@
             missingheads = onlyheads
         og.missingheads = missingheads
 
+    if portable:
+        # recompute common and missingheads as if -r<rev> had been given for
+        # each head of missing, and --base <rev> for each head of the proper
+        # ancestors of missing
+        og._computecommonmissing()
+        cl = repo.changelog
+        missingrevs = set(cl.rev(n) for n in og._missing)
+        og._common = set(cl.ancestors(*missingrevs)) - missingrevs
+        commonheads = set(og.commonheads)
+        og.missingheads = [h for h in og.missingheads if h not in commonheads]
+
     return og
 
 def checkheads(repo, remote, outgoing, remoteheads, newbranch=False, inc=False):