[PATCH STABLE] changegroup: properly compute common base in changeggroupsubset (issue4736)

Pierre-Yves David pierre-yves.david at ens-lyon.org
Mon Jun 29 21:27:58 CDT 2015


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at fb.com>
# Date 1435602009 25200
#      Mon Jun 29 11:20:09 2015 -0700
# Branch stable
# Node ID ecf92cb7ccbfafda1122f7bc7de46ce70573b0f7
# Parent  dc05a10e1e4595381a1699a9c62548a5296e7ab3
changegroup: properly compute common base in changeggroupsubset (issue4736)

The computation of roots was buggy, any ancestors of a bundled merge who was
also a descendant of a parents of the bundled revision were included as part of
the bundle. We fixes it and add a test for strip (which revealed the problem).

Check the test for practical usecase.

diff --git a/mercurial/changegroup.py b/mercurial/changegroup.py
--- a/mercurial/changegroup.py
+++ b/mercurial/changegroup.py
@@ -575,15 +575,17 @@ def changegroupsubset(repo, roots, heads
     the changegroup a particular filenode or manifestnode belongs to.
     """
     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)
 
 def getlocalchangegroupraw(repo, source, outgoing, bundlecaps=None,
diff --git a/tests/test-rebase-conflicts.t b/tests/test-rebase-conflicts.t
--- a/tests/test-rebase-conflicts.t
+++ b/tests/test-rebase-conflicts.t
@@ -278,21 +278,18 @@ Check that the right ancestors is used w
   removing f1.txt
   updating: f1.txt 1/2 files (50.00%)
    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
   list of changesets:
   4c9fbe56a16f30c0d5dcc40ec1a97bbe3325209c
diff --git a/tests/test-strip.t b/tests/test-strip.t
--- a/tests/test-strip.t
+++ b/tests/test-strip.t
@@ -688,5 +688,145 @@ Verify bundles don't get overwritten:
   $ hg strip -r 0
   saved backup bundle to $TESTTMP/doublebundle/.hg/strip-backup/3903775176ed-54390173-backup.hg (glob)
   $ 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
+  


More information about the Mercurial-devel mailing list