Mercurial > hg-stable
changeset 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 | 47b8ec0eb7fb |
children | c20efe04cd7a |
files | mercurial/commands.py mercurial/discovery.py tests/test-bundle.t tests/test-check-code-hg.t |
diffstat | 4 files changed, 50 insertions(+), 22 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/commands.py Mon May 14 19:25:13 2012 -0400 +++ b/mercurial/commands.py Sat May 12 19:38:20 2012 +0200 @@ -1011,7 +1011,8 @@ 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)
--- 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):
--- a/tests/test-bundle.t Mon May 14 19:25:13 2012 -0400 +++ b/tests/test-bundle.t Sat May 12 19:38:20 2012 +0200 @@ -539,32 +539,36 @@ $ 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 @@ 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
--- a/tests/test-check-code-hg.t Mon May 14 19:25:13 2012 -0400 +++ b/tests/test-check-code-hg.t Sat May 12 19:38:20 2012 +0200 @@ -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