evolve: fix the inconsistent behaviour of prune (issue6137) stable
authorSushil khanchi <sushilkhanchi97@gmail.com>
Mon, 01 Jul 2019 19:15:57 +0530
branchstable
changeset 4702 fcecbb1261f2
parent 4701 1b5da965d72a
child 4706 de194ed973ba
child 4708 dcdd2b3ce52c
evolve: fix the inconsistent behaviour of prune (issue6137) Let's not update to any revision when working directory parent is not related to the revision being pruned. Changes in test file demonstrate the fixed behaviour.
CHANGELOG
hgext3rd/evolve/cmdrewrite.py
tests/test-prune.t
--- a/CHANGELOG	Tue Jul 02 21:00:46 2019 +0530
+++ b/CHANGELOG	Mon Jul 01 19:15:57 2019 +0530
@@ -6,6 +6,7 @@
 
   * pick: no longer forget file in case of conflict (issue6037)
   * pick: properly report and cleanup "unfinished state"
+  * prune: don't update wcp if pruned revision are unrelated (issue6137)
   * evolve: properly prune changeset with no change in case of conflict (issue5967)
 
 9.0.0 -- 2019-06-06
--- a/hgext3rd/evolve/cmdrewrite.py	Tue Jul 02 21:00:46 2019 +0530
+++ b/hgext3rd/evolve/cmdrewrite.py	Mon Jul 01 19:15:57 2019 +0530
@@ -1063,19 +1063,24 @@
 
         wdp = repo['.']
 
-        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)]
+        if wdp in precs:
+            if len(sucs) == 1 and len(precs) == 1:
+                # '.' killed, so update to the successor
+                newnode = sucs[0]
+            elif biject:
+                # find the exact successor of '.'
+                newnode = sucs[precs.index(wdp)]
+            else:
+                # update to an unkilled parent
+                newnode = wdp
+
+                while newnode in precs or newnode.obsolete():
+                    newnode = newnode.parents()[0]
         else:
-            # update to an unkilled parent
+            # no need to update anywhere as wdp is not related to revs
+            # being pruned
             newnode = wdp
 
-            while newnode in precs or newnode.obsolete():
-                newnode = newnode.parents()[0]
-
         if newnode.node() != wdp.node():
             if opts.get('keep', False):
                 # This is largely the same as the implementation in
--- a/tests/test-prune.t	Tue Jul 02 21:00:46 2019 +0530
+++ b/tests/test-prune.t	Mon Jul 01 19:15:57 2019 +0530
@@ -493,12 +493,11 @@
   o  0:9092f1db7931[] (draft) added a
   
   $ hg prune -r "desc('added c')"
-  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
-  working directory is now at 9092f1db7931
   1 changesets pruned
 
   $ hg par
-  0:9092f1db7931[] (draft) added a
-XXX: it doesn't make sense to update to "added a"; parent should be "added b"
+  1:5f6d8a4bf34a[] (obsolete/draft) added b
+  working directory parent is obsolete! (5f6d8a4bf34a)
+  (use 'hg evolve' to update to its parent successor)
 
   $ cd ..