changeset 33558:0103e7187237

drawdag: include files from both parents in merge commits Consider a graph like this: D |\ B C |/ A drawdag will add a file called A in commit A, file B in B, file C in C. That's fine and expected. In merge commits like D, I would expect the files and their contents to be taken from the parent commits, so commit D in this example would have files A, B, and C. However, drawdag will instead add the file D compared to the first parent. Depending on whether B or C got a smaller nodeid, the contents of D would be {A, B, D} or {A, C, D}. This patch changes it to to be {A, B, C}. Differential Revision: https://phab.mercurial-scm.org/D92
author Martin von Zweigbergk <martinvonz@google.com>
date Fri, 14 Jul 2017 22:32:58 -0700
parents 875b054e5b95
children 094634292d34
files tests/drawdag.py tests/test-bundle-phases.t tests/test-drawdag.t tests/test-rebase-base.t tests/test-strip.t
diffstat 5 files changed, 56 insertions(+), 35 deletions(-) [+]
line wrap: on
line diff
--- a/tests/drawdag.py	Mon Jul 17 15:54:15 2017 -0700
+++ b/tests/drawdag.py	Fri Jul 14 22:32:58 2017 -0700
@@ -235,22 +235,21 @@
         return ''
 
 class simplecommitctx(context.committablectx):
-    def __init__(self, repo, name, parentctxs, added=None):
+    def __init__(self, repo, name, parentctxs, added):
         opts = {
-            'changes': scmutil.status([], added or [], [], [], [], [], []),
+            'changes': scmutil.status([], list(added), [], [], [], [], []),
             'date': '0 0',
             'extra': {'branch': 'default'},
         }
         super(simplecommitctx, self).__init__(self, name, **opts)
         self._repo = repo
-        self._name = name
+        self._added = added
         self._parents = parentctxs
-        self._parents.sort(key=lambda c: c.node())
         while len(self._parents) < 2:
             self._parents.append(repo[node.nullid])
 
     def filectx(self, key):
-        return simplefilectx(key, self._name)
+        return simplefilectx(key, self._added[key])
 
     def commit(self):
         return self._repo.commitctx(self)
@@ -317,7 +316,17 @@
         if name in committed:
             continue
         pctxs = [repo[committed[n]] for n in parents]
-        ctx = simplecommitctx(repo, name, pctxs, [name])
+        pctxs.sort(key=lambda c: c.node())
+        added = {}
+        if len(parents) > 1:
+            # If it's a merge, take the files and contents from the parents
+            for f in pctxs[1].manifest():
+                if f not in pctxs[0].manifest():
+                    added[f] = pctxs[1][f].data()
+        else:
+            # If it's not a merge, add a single file
+            added[name] = name
+        ctx = simplecommitctx(repo, name, pctxs, added)
         n = ctx.commit()
         committed[name] = n
         tagsmod.tag(repo, name, n, message=None, user=None, date=None,
--- a/tests/test-bundle-phases.t	Mon Jul 17 15:54:15 2017 -0700
+++ b/tests/test-bundle-phases.t	Fri Jul 14 22:32:58 2017 -0700
@@ -213,7 +213,7 @@
   $ hg log -G -T '{node|short} {desc} {phase}\n'
   o  03ca77807e91 E draft
   |
-  | o  215e7b0814e1 D secret
+  | o  4e4f9194f9f1 D secret
   |/|
   o |  dc0947a82db8 C public
   | |
@@ -231,7 +231,7 @@
       426bada5c67598ca65036d57d9e4b64b0c1ce7a0
       112478962961147124edd43549aedd1a335e44bf
       dc0947a82db884575bb76ea10ac97b08536bfa03
-      215e7b0814e1cac8e2614e7284f2a5dc266b4323
+      4e4f9194f9f181c57f62e823e8bdfa46ab9e4ff4
       03ca77807e919db8807c3749086dc36fb478cac0
   phase-heads -- 'sortdict()'
       dc0947a82db884575bb76ea10ac97b08536bfa03 public
@@ -242,7 +242,7 @@
   $ hg log -G -T '{node|short} {desc} {phase}\n'
   o  03ca77807e91 E draft
   |
-  | o  215e7b0814e1 D secret
+  | o  4e4f9194f9f1 D secret
   |/|
   o |  dc0947a82db8 C public
   | |
@@ -257,7 +257,7 @@
   Stream params: sortdict([('Compression', 'BZ')])
   changegroup -- "sortdict([('version', '02'), ('nbchanges', '2'), ('targetphase', '2')])"
       112478962961147124edd43549aedd1a335e44bf
-      215e7b0814e1cac8e2614e7284f2a5dc266b4323
+      4e4f9194f9f181c57f62e823e8bdfa46ab9e4ff4
   phase-heads -- 'sortdict()'
   $ rm bundle
 
@@ -268,7 +268,7 @@
   changegroup -- "sortdict([('version', '02'), ('nbchanges', '3'), ('targetphase', '2')])"
       112478962961147124edd43549aedd1a335e44bf
       dc0947a82db884575bb76ea10ac97b08536bfa03
-      215e7b0814e1cac8e2614e7284f2a5dc266b4323
+      4e4f9194f9f181c57f62e823e8bdfa46ab9e4ff4
   phase-heads -- 'sortdict()'
       dc0947a82db884575bb76ea10ac97b08536bfa03 public
   $ rm bundle
@@ -278,7 +278,7 @@
   $ hg debugbundle bundle
   Stream params: sortdict([('Compression', 'BZ')])
   changegroup -- "sortdict([('version', '02'), ('nbchanges', '2'), ('targetphase', '2')])"
-      215e7b0814e1cac8e2614e7284f2a5dc266b4323
+      4e4f9194f9f181c57f62e823e8bdfa46ab9e4ff4
       03ca77807e919db8807c3749086dc36fb478cac0
   phase-heads -- 'sortdict()'
       03ca77807e919db8807c3749086dc36fb478cac0 draft
--- a/tests/test-drawdag.t	Mon Jul 17 15:54:15 2017 -0700
+++ b/tests/test-drawdag.t	Fri Jul 14 22:32:58 2017 -0700
@@ -117,6 +117,18 @@
    /
   o  a
   
+  $ hg manifest -r a
+  a
+  $ hg manifest -r b
+  a
+  b
+  $ hg manifest -r bar
+  a
+  b
+  $ hg manifest -r foo
+  a
+  b
+  baz
 
 Edges existed in repo are no-ops
 
--- a/tests/test-rebase-base.t	Mon Jul 17 15:54:15 2017 -0700
+++ b/tests/test-rebase-base.t	Fri Jul 14 22:32:58 2017 -0700
@@ -65,7 +65,7 @@
   > EOS
   rebasing 2:c1e6b162678d "B" (B)
   rebasing 3:d6003a550c2c "C" (C)
-  rebasing 6:5251e0cb7302 "E" (E tip)
+  rebasing 6:54c8f00cb91c "E" (E tip)
   o    6: E
   |\
   | o  5: C
@@ -92,7 +92,7 @@
   >   R
   > EOS
   rebasing 2:c1e6b162678d "B" (B)
-  rebasing 5:5251e0cb7302 "E" (E tip)
+  rebasing 5:54c8f00cb91c "E" (E tip)
   o    5: E
   |\
   | o  4: B
@@ -118,7 +118,7 @@
   > EOS
   rebasing 2:c1e6b162678d "B" (B)
   rebasing 3:d6003a550c2c "C" (C)
-  rebasing 5:5251e0cb7302 "E" (E tip)
+  rebasing 5:54c8f00cb91c "E" (E tip)
   o    5: E
   |\
   | o  4: C
@@ -208,18 +208,18 @@
   >   A   A   A
   > EOS
   rebasing 2:dc0947a82db8 "C" (C)
-  rebasing 8:215e7b0814e1 "D" (D)
+  rebasing 8:4e4f9194f9f1 "D" (D)
   rebasing 9:03ca77807e91 "E" (E)
   rebasing 10:afc707c82df0 "F" (F)
-  rebasing 13:018caa673317 "G" (G)
-  rebasing 14:4f710fbd68cb "H" (H)
+  rebasing 13:690dfff91e9e "G" (G)
+  rebasing 14:2893b886bb10 "H" (H)
   rebasing 3:08ebfeb61bac "I" (I)
   rebasing 4:a0a5005cec67 "J" (J)
   rebasing 5:83780307a7e8 "K" (K)
   rebasing 6:e131637a1cb6 "L" (L)
-  rebasing 11:d6fe3d11d95d "M" (M)
-  rebasing 12:fa1e02269063 "N" (N)
-  rebasing 15:448b1a498430 "P" (P tip)
+  rebasing 11:d1f6d0c3c7e4 "M" (M)
+  rebasing 12:7aaec6f81888 "N" (N)
+  rebasing 15:325bc8f1760d "P" (P tip)
   o    15: P
   |\
   | o    14: N
@@ -269,9 +269,9 @@
   rebasing 6:06ca5dfe3b5b "B2" (B2)
   rebasing 7:73508237b032 "C1" (C1)
   rebasing 9:fdb955e2faed "A2" (A2)
-  rebasing 11:1b2f368c3cb5 "A3" (A3)
+  rebasing 11:4e449bd1a643 "A3" (A3)
   rebasing 10:0a33b0519128 "B1" (B1)
-  rebasing 12:bd6a37b5b67a "B3" (B3 tip)
+  rebasing 12:209327807c3a "B3" (B3 tip)
   o    12: B3
   |\
   | o  11: B1
@@ -334,7 +334,7 @@
   >  \|\|
   >   A C
   > EOF
-  nothing to rebase from 86d01f49c0d9+b70f76719894 to 262e37e34f63
+  nothing to rebase from f675d5a1c6a4+b70f76719894 to 262e37e34f63
   [1]
 
 Multiple roots. One root is not an ancestor of dest. Select using a merge:
@@ -346,8 +346,8 @@
   >  \|\|
   >   A C
   > EOF
-  rebasing 2:86d01f49c0d9 "B" (B)
-  rebasing 5:539a0ff83ea9 "E" (E tip)
+  rebasing 2:f675d5a1c6a4 "B" (B)
+  rebasing 5:f68696fe6af8 "E" (E tip)
   o    5: E
   |\
   | o    4: B
@@ -367,8 +367,8 @@
   >  \|\|\
   >   A C A
   > EOF
-  rebasing 2:86d01f49c0d9 "B" (B)
-  rebasing 3:b7df2ca01aa8 "D" (D)
+  rebasing 2:f675d5a1c6a4 "B" (B)
+  rebasing 3:c2a779e13b56 "D" (D)
   o    4: D
   |\
   +---o  3: B
--- a/tests/test-strip.t	Mon Jul 17 15:54:15 2017 -0700
+++ b/tests/test-strip.t	Fri Jul 14 22:32:58 2017 -0700
@@ -974,7 +974,7 @@
   > EOF
   $ hg log -r . -T '\n' --config extensions.t=$TESTTMP/delayedstrip.py
   warning: orphaned descendants detected, not stripping 08ebfeb61bac, 112478962961, 7fb047a69f22
-  saved backup bundle to $TESTTMP/delayedstrip/.hg/strip-backup/f585351a92f8-81fa23b0-I.hg (glob)
+  saved backup bundle to $TESTTMP/delayedstrip/.hg/strip-backup/f585351a92f8-17475721-I.hg (glob)
   
   $ hg log -G -T '{rev}:{node|short} {desc}' -r 'sort(all(), topo)'
   @  6:2f2d51af6205 J
@@ -1030,9 +1030,9 @@
   $ hg log -G -T '{rev}:{node|short} {desc} {bookmarks}' -r 'sort(all(), topo)'
   o  8:1473d4b996d1 G2 b-F@divergent3 b-G
   |
-  | o  7:d94e89b773b6 F2 b-F
+  | o  7:d11b3456a873 F2 b-F
   | |
-  | o  5:7fe5bac4c918 H
+  | o  5:5cb05ba470a7 H
   |/|
   | o  3:7fb047a69f22 E b-F@divergent1
   | |
@@ -1050,7 +1050,7 @@
      b-B                       0:426bada5c675
      b-C                       0:426bada5c675
      b-D                       6:7c78f703e465
-     b-F                       7:d94e89b773b6
+     b-F                       7:d11b3456a873
      b-F@divergent1            3:7fb047a69f22
      b-F@divergent3            8:1473d4b996d1
      b-G                       8:1473d4b996d1
@@ -1073,9 +1073,9 @@
   $ hg log -G -T '{rev}:{node|short} {desc} {bookmarks}' -r 'sort(all(), topo)'
   o  12:1473d4b996d1 G2 b-F@divergent3 b-G
   |
-  | o  11:d94e89b773b6 F2 b-F
+  | o  11:d11b3456a873 F2 b-F
   | |
-  | o  8:7fe5bac4c918 H
+  | o  8:5cb05ba470a7 H
   |/|
   | o  4:7fb047a69f22 E b-F@divergent1
   | |
@@ -1091,7 +1091,7 @@
   
   $ hg debugobsolete
   1fc8102cda6204549f031015641606ccf5513ec3 1473d4b996d1d1b121de6b39fab6a04fbf9d873e 0 (Thu Jan 01 00:00:00 1970 +0000) {'operation': 'replace', 'user': 'test'}
-  64a8289d249234b9886244d379f15e6b650b28e3 d94e89b773b67e72642a931159ada8d1a9246998 0 (Thu Jan 01 00:00:00 1970 +0000) {'operation': 'replace', 'user': 'test'}
+  64a8289d249234b9886244d379f15e6b650b28e3 d11b3456a873daec7c7bc53e5622e8df6d741bd2 0 (Thu Jan 01 00:00:00 1970 +0000) {'operation': 'replace', 'user': 'test'}
   f585351a92f85104bff7c284233c338b10eb1df7 7c78f703e465d73102cc8780667ce269c5208a40 0 (Thu Jan 01 00:00:00 1970 +0000) {'operation': 'replace', 'user': 'test'}
   48b9aae0607f43ff110d84e6883c151942add5ab 0 {0000000000000000000000000000000000000000} (Thu Jan 01 00:00:00 1970 +0000) {'operation': 'replace', 'user': 'test'}
   112478962961147124edd43549aedd1a335e44bf 0 {426bada5c67598ca65036d57d9e4b64b0c1ce7a0} (Thu Jan 01 00:00:00 1970 +0000) {'operation': 'replace', 'user': 'test'}