diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -1011,7 +1011,8 @@ def bundle(ui, repo, fname, dest=None, * heads = revs and map(repo.lookup, revs) or revs outgoing = discovery.findcommonoutgoing(repo, other, onlyheads=heads, - force=opts.get('force')) + force=opts.get('force'), + portable=True) cg = repo.getlocalbundle('bundle', outgoing) if not cg: scmutil.nochangesfound(ui, outgoing and outgoing.excluded) diff --git a/mercurial/discovery.py b/mercurial/discovery.py --- a/mercurial/discovery.py +++ b/mercurial/discovery.py @@ -86,7 +86,8 @@ class outgoing(object): 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 @@ def findcommonoutgoing(repo, other, only 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 @@ def findcommonoutgoing(repo, other, only missingheads = onlyheads og.missingheads = missingheads + if portable: + # recompute common and missingheads as if -r had been given for + # each head of missing, and --base 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): diff --git a/tests/test-bundle.t b/tests/test-bundle.t --- a/tests/test-bundle.t +++ b/tests/test-bundle.t @@ -539,32 +539,36 @@ bundle single branch $ hg init branchy $ cd branchy $ echo a >a + $ echo x >x $ hg ci -Ama adding a + adding x + $ echo c >c + $ echo xx >x + $ hg ci -Amc + adding c + $ echo c1 >c1 + $ hg ci -Amc1 + adding c1 + $ hg up 0 + 1 files updated, 0 files merged, 2 files removed, 0 files unresolved $ echo b >b $ hg ci -Amb adding b + created new head $ echo b1 >b1 + $ echo xx >x $ hg ci -Amb1 adding b1 - $ hg up 0 - 0 files updated, 0 files merged, 2 files removed, 0 files unresolved - $ echo c >c - $ hg ci -Amc - adding c - created new head - $ echo c1 >c1 - $ hg ci -Amc1 - adding c1 - $ hg clone -q .#tip part + $ hg clone -q -r2 . part == bundling via incoming $ hg in -R part --bundle incoming.hg --template "{node}\n" . comparing with . searching for changes - d2ae7f538514cd87c17547b0de4cea71fe1af9fb - 5ece8e77363e2b5269e27c66828b72da29e4341a + 1a38c1b849e8b70c756d2d80b0b9a3ac0b7ea11a + 057f4db07f61970e1c11e83be79e9d08adc4dc31 == bundling @@ -574,12 +578,23 @@ bundle single branch all remote heads known locally 2 changesets found list of changesets: - d2ae7f538514cd87c17547b0de4cea71fe1af9fb - 5ece8e77363e2b5269e27c66828b72da29e4341a + 1a38c1b849e8b70c756d2d80b0b9a3ac0b7ea11a + 057f4db07f61970e1c11e83be79e9d08adc4dc31 bundling: 1/2 changesets (50.00%) bundling: 2/2 changesets (100.00%) bundling: 1/2 manifests (50.00%) bundling: 2/2 manifests (100.00%) - bundling: b 1/2 files (50.00%) - bundling: b1 2/2 files (100.00%) + bundling: b 1/3 files (33.33%) + bundling: b1 2/3 files (66.67%) + bundling: x 3/3 files (100.00%) + +== Test for issue3441 + $ hg clone -q -r0 . part2 + $ hg -q -R part2 pull bundle.hg + $ hg -R part2 verify + checking changesets + checking manifests + crosschecking files in changesets and manifests + checking files + 4 files, 3 changesets, 5 total revisions diff --git a/tests/test-check-code-hg.t b/tests/test-check-code-hg.t --- a/tests/test-check-code-hg.t +++ b/tests/test-check-code-hg.t @@ -420,9 +420,6 @@ mercurial/discovery.py:0: > If onlyheads is given, only nodes ancestral to nodes in onlyheads (inclusive) warning: line over 80 characters - mercurial/discovery.py:0: - > def findcommonoutgoing(repo, other, onlyheads=None, force=False, commoninc=None): - warning: line over 80 characters mercurial/dispatch.py:0: > " (.hg not found)") % os.getcwd()) warning: line over 80 characters