Mercurial > public > mercurial-scm > hg-stable
diff mercurial/discovery.py @ 16736:025b3b763ba9 stable
bundle: make bundles more portable (isue3441)
This is achieved by acting as if the user had given -r<rev> for each head rev
of outgoing changesets on the command line, as well as appropriate
--base <rev>.
The discovery information is computed as normal, and then adjusted as above.
author | Sune Foldager <cryo@cyanite.org> |
---|---|
date | Sat, 12 May 2012 19:38:20 +0200 |
parents | 39d1f83eb05d |
children | 9acb5cd19162 |
line wrap: on
line diff
--- 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):