# HG changeset patch # User Pierre-Yves David # Date 1435602009 25200 # Node ID af5b2f4ed594621a764fbe3034122253afcf225c # Parent ec9c258e666d872b4550bf7fff82efc0647f4089 changegroup: properly compute common base in changeggroupsubset (issue4736) The computation of roots was buggy, any ancestor of a bundled merge which was also a descendant of the parents of a bundled revision were included as part of the bundle. We fix it and add a test for strip (which revealed the problem). Check the test for a practical usecase. diff -r ec9c258e666d -r af5b2f4ed594 mercurial/changegroup.py --- a/mercurial/changegroup.py Thu Jun 25 22:07:38 2015 +0900 +++ b/mercurial/changegroup.py Mon Jun 29 11:20:09 2015 -0700 @@ -577,11 +577,13 @@ cl = repo.changelog if not roots: roots = [nullid] - # TODO: remove call to nodesbetween. - csets, roots, heads = cl.nodesbetween(roots, heads) discbases = [] for n in roots: discbases.extend([p for p in cl.parents(n) if p != nullid]) + # TODO: remove call to nodesbetween. + csets, roots, heads = cl.nodesbetween(roots, heads) + included = set(csets) + discbases = [n for n in discbases if n not in included] outgoing = discovery.outgoing(cl, discbases, heads) bundler = packermap[version][0](repo) return getsubset(repo, outgoing, bundler, source, version=version) diff -r ec9c258e666d -r af5b2f4ed594 tests/test-rebase-conflicts.t --- a/tests/test-rebase-conflicts.t Thu Jun 25 22:07:38 2015 +0900 +++ b/tests/test-rebase-conflicts.t Mon Jun 29 11:20:09 2015 -0700 @@ -280,17 +280,14 @@ f2.txt: remote created -> g getting f2.txt updating: f2.txt 2/2 files (100.00%) - 3 changesets found + 2 changesets found list of changesets: - 4c9fbe56a16f30c0d5dcc40ec1a97bbe3325209c e31216eec445e44352c5f01588856059466a24c9 2f2496ddf49d69b5ef23ad8cf9fb2e0e4faf0ac2 - bundling: 1/3 changesets (33.33%) - bundling: 2/3 changesets (66.67%) - bundling: 3/3 changesets (100.00%) - bundling: 1/3 manifests (33.33%) - bundling: 2/3 manifests (66.67%) - bundling: 3/3 manifests (100.00%) + 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: f1.txt 1/1 files (100.00%) saved backup bundle to $TESTTMP/issue4041/.hg/strip-backup/e31216eec445-15f7a814-backup.hg (glob) 3 changesets found diff -r ec9c258e666d -r af5b2f4ed594 tests/test-strip.t --- a/tests/test-strip.t Thu Jun 25 22:07:38 2015 +0900 +++ b/tests/test-strip.t Mon Jun 29 11:20:09 2015 -0700 @@ -690,3 +690,143 @@ $ ls .hg/strip-backup 3903775176ed-54390173-backup.hg 3903775176ed-e68910bd-backup.hg + $ cd .. + +Test that we only bundle the stripped changesets (issue4736) +------------------------------------------------------------ + +initialisation (previous repo is empty anyway) + + $ hg init issue4736 + $ cd issue4736 + $ echo a > a + $ hg add a + $ hg commit -m commitA + $ echo b > b + $ hg add b + $ hg commit -m commitB + $ echo c > c + $ hg add c + $ hg commit -m commitC + $ hg up 'desc(commitB)' + 0 files updated, 0 files merged, 1 files removed, 0 files unresolved + $ echo d > d + $ hg add d + $ hg commit -m commitD + created new head + $ hg up 'desc(commitC)' + 1 files updated, 0 files merged, 1 files removed, 0 files unresolved + $ hg merge 'desc(commitD)' + 1 files updated, 0 files merged, 0 files removed, 0 files unresolved + (branch merge, don't forget to commit) + $ hg ci -m 'mergeCD' + $ hg log -G + @ changeset: 4:d8db9d137221 + |\ tag: tip + | | parent: 2:5c51d8d6557d + | | parent: 3:6625a5168474 + | | user: test + | | date: Thu Jan 01 00:00:00 1970 +0000 + | | summary: mergeCD + | | + | o changeset: 3:6625a5168474 + | | parent: 1:eca11cf91c71 + | | user: test + | | date: Thu Jan 01 00:00:00 1970 +0000 + | | summary: commitD + | | + o | changeset: 2:5c51d8d6557d + |/ user: test + | date: Thu Jan 01 00:00:00 1970 +0000 + | summary: commitC + | + o changeset: 1:eca11cf91c71 + | user: test + | date: Thu Jan 01 00:00:00 1970 +0000 + | summary: commitB + | + o changeset: 0:105141ef12d0 + user: test + date: Thu Jan 01 00:00:00 1970 +0000 + summary: commitA + + +Check bundle behavior: + + $ hg bundle -r 'desc(mergeCD)' --base 'desc(commitC)' ../issue4736.hg + 2 changesets found + $ hg log -r 'bundle()' -R ../issue4736.hg + changeset: 3:6625a5168474 + parent: 1:eca11cf91c71 + user: test + date: Thu Jan 01 00:00:00 1970 +0000 + summary: commitD + + changeset: 4:d8db9d137221 + tag: tip + parent: 2:5c51d8d6557d + parent: 3:6625a5168474 + user: test + date: Thu Jan 01 00:00:00 1970 +0000 + summary: mergeCD + + +check strip behavior + + $ hg --config extensions.strip= strip 'desc(commitD)' --debug + resolving manifests + branchmerge: False, force: True, partial: False + ancestor: d8db9d137221+, local: d8db9d137221+, remote: eca11cf91c71 + c: other deleted -> r + removing c + d: other deleted -> r + removing d + updating: d 2/2 files (100.00%) + 0 files updated, 0 files merged, 2 files removed, 0 files unresolved + 2 changesets found + list of changesets: + 6625a516847449b6f0fa3737b9ba56e9f0f3032c + d8db9d1372214336d2b5570f20ee468d2c72fa8b + 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: d 1/1 files (100.00%) + saved backup bundle to $TESTTMP/issue4736/.hg/strip-backup/6625a5168474-345bb43d-backup.hg (glob) + invalid branchheads cache (served): tip differs + truncating cache/rbc-revs-v1 to 24 + $ hg log -G + o changeset: 2:5c51d8d6557d + | tag: tip + | user: test + | date: Thu Jan 01 00:00:00 1970 +0000 + | summary: commitC + | + @ changeset: 1:eca11cf91c71 + | user: test + | date: Thu Jan 01 00:00:00 1970 +0000 + | summary: commitB + | + o changeset: 0:105141ef12d0 + user: test + date: Thu Jan 01 00:00:00 1970 +0000 + summary: commitA + + +strip backup content + + $ hg log -r 'bundle()' -R .hg/strip-backup/6625a5168474-*-backup.hg + changeset: 3:6625a5168474 + parent: 1:eca11cf91c71 + user: test + date: Thu Jan 01 00:00:00 1970 +0000 + summary: commitD + + changeset: 4:d8db9d137221 + tag: tip + parent: 2:5c51d8d6557d + parent: 3:6625a5168474 + user: test + date: Thu Jan 01 00:00:00 1970 +0000 + summary: mergeCD +