changeset 4699:dfd88e3fa90a stable

prune: update to the successor of wdir also with --pair/--biject (issue6142) When prune is used with --pair flag, we can also update to the successor of working directory parent. No need to check len(sucs) or len(precs) here because there's a check for that earlier in the code (it's a requirement of biject). The tests are now demonstrate the correct behavior: when rev 14 was pruned with 12 as its successor, the bookmark that was on 14 was moved to 12. That bookmark was also activated (even before this patch).
author Anton Shestakov <av6@dwimlabs.net>
date Sat, 29 Jun 2019 18:21:57 +0800
parents b89495215c6e
children 1b5da965d72a
files hgext3rd/evolve/cmdrewrite.py tests/test-prune.t
diffstat 2 files changed, 7 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/hgext3rd/evolve/cmdrewrite.py	Sat Jun 22 18:37:21 2019 +0800
+++ b/hgext3rd/evolve/cmdrewrite.py	Sat Jun 29 18:21:57 2019 +0800
@@ -1066,6 +1066,9 @@
         if len(sucs) == 1 and len(precs) == 1 and wdp in precs:
             # '.' killed, so update to the successor
             newnode = sucs[0]
+        elif biject and wdp in precs:
+            # find the exact successor of '.'
+            newnode = sucs[precs.index(wdp)]
         else:
             # update to an unkilled parent
             newnode = wdp
--- a/tests/test-prune.t	Sat Jun 22 18:37:21 2019 +0800
+++ b/tests/test-prune.t	Sat Jun 29 18:21:57 2019 +0800
@@ -239,8 +239,8 @@
   $ mkcommit n2
 
   $ hg prune 'desc("add n1")::desc("add n2")' -s 'desc("add nD")::desc("add nE")' --pair
-  0 files updated, 0 files merged, 2 files removed, 0 files unresolved
-  working directory is now at 1f0dee641bb7
+  4 files updated, 0 files merged, 2 files removed, 0 files unresolved
+  working directory is now at 6e8148413dd5
   2 changesets pruned
   $ hg debugobsolete
   9d206ffc875e1bc304590549be293be36821e66c 0 {47d2a3944de8b013de3be9578e8e344ea2e6c097} (Sat Dec 15 00:00:00 1979 +0000) {'ef1': '0', 'operation': 'prune', 'user': 'blah'}
@@ -255,13 +255,12 @@
   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")'
   14:21b6f2f1cece[] (obsolete/draft) add n2
-  12:6e8148413dd5[] (draft) add nE
-  0:1f0dee641bb7[BABAR prune-pair-book] (public) add a
+  12:6e8148413dd5[prune-pair-book] (draft) add nE
 
 test hg strip replacement
 
   $ hg up 10
-  2 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  0 files updated, 0 files merged, 2 files removed, 0 files unresolved
   (leaving bookmark prune-pair-book)
   $ mkcommit n1
   created new head