# HG changeset patch # User Sushil khanchi # Date 1561988757 -19800 # Node ID fcecbb1261f241f6b83f8630898873c3cf90a7a9 # Parent 1b5da965d72a3ebe837f750d61c46531759bf1a7 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. diff -r 1b5da965d72a -r fcecbb1261f2 CHANGELOG --- 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 diff -r 1b5da965d72a -r fcecbb1261f2 hgext3rd/evolve/cmdrewrite.py --- 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 diff -r 1b5da965d72a -r fcecbb1261f2 tests/test-prune.t --- 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 ..