prune: actually track folds using fold-* metadata in obsmarkers
authorAnton Shestakov <av6@dwimlabs.net>
Sat, 15 Feb 2020 16:52:56 +0800
changeset 5131 53dd70f557aa
parent 5130 40ae7c5b3b17
child 5134 d9b1336f7d1c
prune: actually track folds using fold-* metadata in obsmarkers
hgext3rd/evolve/cmdrewrite.py
tests/test-prune.t
--- a/hgext3rd/evolve/cmdrewrite.py	Thu Feb 13 19:13:36 2020 +0800
+++ b/hgext3rd/evolve/cmdrewrite.py	Sat Feb 15 16:52:56 2020 +0800
@@ -1170,6 +1170,11 @@
                 if not dest.obsolete() and dest.node() not in replacements:
                     moves[ctx.node()] = dest.node()
                     break
+        if len(sucs) == 1 and len(precs) > 1 and fold:
+            # hg <= 4.7 (b99903534e06)
+            # Using a proxy condition to let people wrap cleanupnodes()
+            if util.safehasattr(scmutil, 'nullrev'):
+                replacements = {tuple(p.node() for p in precs): [s.node() for s in sucs]}
         scmutil.cleanupnodes(repo, replacements, operation=b"prune", moves=moves,
                              metadata=metadata)
 
--- a/tests/test-prune.t	Thu Feb 13 19:13:36 2020 +0800
+++ b/tests/test-prune.t	Sat Feb 15 16:52:56 2020 +0800
@@ -226,8 +226,8 @@
   47d2a3944de8b013de3be9578e8e344ea2e6c097 0 {4538525df7e2b9f09423636c61ef63a4cb872a2d} (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '0', 'operation': 'prune', 'user': 'test'}
   bb5e90a7ea1f3b4b38b23150a4a597b6146d70ef 6e8148413dd541855b72a920a90c06fca127c7e7 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '13', 'operation': 'prune', 'user': 'test'}
   00ded550b1e28bba454bd34cec1269d22cf3ef25 aa96dc3f04c2c2341fe6880aeb6dc9fbffff9ef9 8ee176ff1d4b2034ce51e3efc579c2de346b631d 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '13', 'operation': 'prune', 'user': 'test'}
-  814c38b95e72dfe2cbf675b1649ea9d780c89a80 6f6f25e4f748d8f7571777e6e168aedf50350ce8 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '9', 'operation': 'prune', 'user': 'test'}
-  354011cd103f58bbbd9091a3cee6d6a6bd0dddf7 6f6f25e4f748d8f7571777e6e168aedf50350ce8 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '13', 'operation': 'prune', 'user': 'test'}
+  814c38b95e72dfe2cbf675b1649ea9d780c89a80 6f6f25e4f748d8f7571777e6e168aedf50350ce8 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '9', 'fold-id': '691ebcba', 'fold-idx': '1', 'fold-size': '2', 'operation': 'prune', 'user': 'test'}
+  354011cd103f58bbbd9091a3cee6d6a6bd0dddf7 6f6f25e4f748d8f7571777e6e168aedf50350ce8 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '13', 'fold-id': '691ebcba', 'fold-idx': '2', 'fold-size': '2', 'operation': 'prune', 'user': 'test'}
 
 two old, two new with --pair (also test bookmark move)
 
@@ -249,8 +249,8 @@
   47d2a3944de8b013de3be9578e8e344ea2e6c097 0 {4538525df7e2b9f09423636c61ef63a4cb872a2d} (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '0', 'operation': 'prune', 'user': 'test'}
   bb5e90a7ea1f3b4b38b23150a4a597b6146d70ef 6e8148413dd541855b72a920a90c06fca127c7e7 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '13', 'operation': 'prune', 'user': 'test'}
   00ded550b1e28bba454bd34cec1269d22cf3ef25 aa96dc3f04c2c2341fe6880aeb6dc9fbffff9ef9 8ee176ff1d4b2034ce51e3efc579c2de346b631d 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '13', 'operation': 'prune', 'user': 'test'}
-  814c38b95e72dfe2cbf675b1649ea9d780c89a80 6f6f25e4f748d8f7571777e6e168aedf50350ce8 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '9', 'operation': 'prune', 'user': 'test'}
-  354011cd103f58bbbd9091a3cee6d6a6bd0dddf7 6f6f25e4f748d8f7571777e6e168aedf50350ce8 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '13', 'operation': 'prune', 'user': 'test'}
+  814c38b95e72dfe2cbf675b1649ea9d780c89a80 6f6f25e4f748d8f7571777e6e168aedf50350ce8 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '9', 'fold-id': '691ebcba', 'fold-idx': '1', 'fold-size': '2', 'operation': 'prune', 'user': 'test'}
+  354011cd103f58bbbd9091a3cee6d6a6bd0dddf7 6f6f25e4f748d8f7571777e6e168aedf50350ce8 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '13', 'fold-id': '691ebcba', 'fold-idx': '2', 'fold-size': '2', 'operation': 'prune', 'user': 'test'}
   cb7f8f706a6532967b98cf8583a81baab79a0fa7 8ee176ff1d4b2034ce51e3efc579c2de346b631d 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '13', 'operation': 'prune', 'user': 'test'}
   21b6f2f1cece8c10326e575dd38239189d467190 6e8148413dd541855b72a920a90c06fca127c7e7 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '13', 'operation': 'prune', 'user': 'test'}
   $ hg log --hidden -r 'desc("add n2") + desc("add nE") + bookmark("prune-pair-book")'