prune: add tests to demonstrate issue6137 stable
authorSushil khanchi <sushilkhanchi97@gmail.com>
Tue, 02 Jul 2019 21:00:46 +0530
branchstable
changeset 4701 1b5da965d72a
parent 4699 dfd88e3fa90a
child 4702 fcecbb1261f2
prune: add tests to demonstrate issue6137 Here we can see that prune updates off to the parent revision even when the pruned revision wasn't related with the working directory parent. A follow-up patch will fix this.
tests/test-prune.t
--- a/tests/test-prune.t	Sat Jun 29 18:21:57 2019 +0800
+++ b/tests/test-prune.t	Tue Jul 02 21:00:46 2019 +0530
@@ -459,3 +459,46 @@
      r10                       8:d62d843c9a01
      rg                        15:cd0038e05e1b
 
+  $ cd ..
+
+Test that prune doesn't update off when pruning unrelated commit (issue6137)
+----------------------------------------------------------------------------
+
+  $ hg init issue6137
+  $ cd issue6137
+  $ echo a > a
+  $ hg ci -Aqm "added a"
+  $ echo b > b
+  $ hg ci -Aqm "added b"
+
+  $ hg prune .
+  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  working directory is now at 9092f1db7931
+  1 changesets pruned
+
+  $ echo c > c
+  $ hg ci -Aqm "added c"
+
+update to obsoleted revision and perform prune on unrelated revision:
+  $ hg up -r "desc('added b')" --hidden -q
+  updated to hidden changeset 5f6d8a4bf34a
+  (hidden revision '5f6d8a4bf34a' is pruned)
+  working directory parent is obsolete! (5f6d8a4bf34a)
+
+  $ hg log -G
+  o  2:29edef26570b[] (draft) added c
+  |
+  | @  1:5f6d8a4bf34a[] (obsolete/draft) added b
+  |/
+  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"
+
+  $ cd ..