evolve: apply prune update before creating obsolescence markers
authorLaurent Charignon <lcharignon@fb.com>
Thu, 02 Apr 2015 18:33:44 -0700
changeset 1239 8a06b32061ce
parent 1238 ee695c7d1bf1
child 1240 e1347ce2f954
evolve: apply prune update before creating obsolescence markers Prune used to compute the destination commit to update to after creating the obsolescence markers. This is a commit to prevent a bug that would occur with the changes in inhibit for transactions (next commit). Indeed, with that change in inhibit, when creating the obsolescence markers in prune, they would get inhibited right away and we wouldn't update to the first non obsolete parent but stay on the same node as its obsolescence would have been inhibited (bug).
hgext/evolve.py
tests/test-evolve.t
tests/test-exchange-D2.t
tests/test-exchange-D3.t
tests/test-inhibit.t
tests/test-prune.t
tests/test-tutorial.t
tests/test-userguide.t
--- a/hgext/evolve.py	Fri Apr 03 11:35:46 2015 -0700
+++ b/hgext/evolve.py	Thu Apr 02 18:33:44 2015 -0700
@@ -1832,12 +1832,6 @@
         if biject:
             relations = [(p, (s,)) for p, s in zip(precs, sucs)]
 
-        # create markers
-        obsolete.createmarkers(repo, relations, metadata=metadata)
-
-        # informs that changeset have been pruned
-        ui.status(_('%i changesets pruned\n') % len(precs))
-
         wdp = repo['.']
 
         if len(sucs) == 1 and len(precs) == 1 and wdp in precs:
@@ -1847,9 +1841,10 @@
             # update to an unkilled parent
             newnode = wdp
 
-            while newnode.obsolete():
+            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
@@ -1876,6 +1871,13 @@
         # update bookmarks
         if bookmark:
             _deletebookmark(ui, marks, bookmark)
+
+        # create markers
+        obsolete.createmarkers(repo, relations, metadata=metadata)
+        
+        # informs that changeset have been pruned
+        ui.status(_('%i changesets pruned\n') % len(precs))
+
         for ctx in repo.unfiltered().set('bookmark() and %ld', precs):
             # used to be:
             #
--- a/tests/test-evolve.t	Fri Apr 03 11:35:46 2015 -0700
+++ b/tests/test-evolve.t	Thu Apr 02 18:33:44 2015 -0700
@@ -69,9 +69,9 @@
   $ hg id -n
   5
   $ hg kill .
-  1 changesets pruned
   0 files updated, 0 files merged, 1 files removed, 0 files unresolved
   working directory now at fbb94e3a0ecf
+  1 changesets pruned
   $ hg qlog
   4 - fbb94e3a0ecf add e (draft)
   3 - 47d2a3944de8 add d (draft)
@@ -82,9 +82,9 @@
 test multiple kill
 
   $ hg kill 4 -r 3
-  2 changesets pruned
   0 files updated, 0 files merged, 1 files removed, 0 files unresolved
   working directory now at 7c3bad9141dc
+  2 changesets pruned
   $ hg qlog
   2 - 4538525df7e2 add c (draft)
   1 - 7c3bad9141dc add b (public)
@@ -97,9 +97,9 @@
   $ echo 4 > g
   $ hg add g
   $ hg kill .
-  1 changesets pruned
   0 files updated, 0 files merged, 1 files removed, 0 files unresolved
   working directory now at 7c3bad9141dc
+  1 changesets pruned
   $ hg st
   A g
   $ cd ..
--- a/tests/test-exchange-D2.t	Fri Apr 03 11:35:46 2015 -0700
+++ b/tests/test-exchange-D2.t	Thu Apr 02 18:33:44 2015 -0700
@@ -37,9 +37,9 @@
   created new head
   $ hg debugobsolete `getid 'desc(A0)'` `getid 'desc(A1)'`
   $ hg prune --date '0 0' .
-  1 changesets pruned
   0 files updated, 0 files merged, 1 files removed, 0 files unresolved
   working directory now at a9bdc8b26820
+  1 changesets pruned
   $ hg strip --hidden -q 'desc(A1)'
   $ hg log -G --hidden
   x  28b51eb45704 (draft): A0
--- a/tests/test-exchange-D3.t	Fri Apr 03 11:35:46 2015 -0700
+++ b/tests/test-exchange-D3.t	Thu Apr 02 18:33:44 2015 -0700
@@ -39,9 +39,9 @@
   $ mkcommit A1
   $ hg debugobsolete `getid 'desc(A0)'` `getid 'desc(A1)'`
   $ hg prune -d '0 0' .
-  1 changesets pruned
   0 files updated, 0 files merged, 1 files removed, 0 files unresolved
   working directory now at 35b183996678
+  1 changesets pruned
   $ hg strip --hidden -q 'desc(A1)'
   $ hg log -G --hidden
   @  35b183996678 (draft): B
--- a/tests/test-inhibit.t	Fri Apr 03 11:35:46 2015 -0700
+++ b/tests/test-inhibit.t	Thu Apr 02 18:33:44 2015 -0700
@@ -154,9 +154,9 @@
   
   $ hg phase --public 7
   $ hg prune 9
-  1 changesets pruned
   0 files updated, 0 files merged, 1 files removed, 0 files unresolved
   working directory now at cf5c4f4554ce
+  1 changesets pruned
   $ hg log -G
   o  7:18214586bf78 add cJ
   |
--- a/tests/test-prune.t	Fri Apr 03 11:35:46 2015 -0700
+++ b/tests/test-prune.t	Thu Apr 02 18:33:44 2015 -0700
@@ -38,10 +38,10 @@
 prune current and tip changeset
 
   $ hg prune --user blah --date '1979-12-15' .
-  1 changesets pruned
   0 files updated, 0 files merged, 1 files removed, 0 files unresolved
   (leaving bookmark BABAR)
   working directory now at 47d2a3944de8
+  1 changesets pruned
   $ hg debugobsolete
   9d206ffc875e1bc304590549be293be36821e66c 0 {47d2a3944de8b013de3be9578e8e344ea2e6c097} (Sat Dec 15 00:00:00 1979 +0000) {'user': 'blah'}
 
@@ -57,9 +57,9 @@
 pruning multiple changeset at once
 
   $ hg prune 2:
-  2 changesets pruned
   0 files updated, 0 files merged, 3 files removed, 0 files unresolved
   working directory now at 1f0dee641bb7
+  2 changesets pruned
   $ hg debugobsolete
   9d206ffc875e1bc304590549be293be36821e66c 0 {47d2a3944de8b013de3be9578e8e344ea2e6c097} (Sat Dec 15 00:00:00 1979 +0000) {'user': 'blah'}
   7c3bad9141dcb46ff89abf5f61856facd56e476c 0 {1f0dee641bb7258c56bd60e93edfa2405381c41e} (*) {'user': 'test'} (glob)
@@ -118,9 +118,9 @@
   $ hg up 'desc("add ee")'
   4 files updated, 0 files merged, 4 files removed, 0 files unresolved
   $ hg prune 'desc("add ee")' -s 'desc("add nE")'
-  1 changesets pruned
   4 files updated, 0 files merged, 4 files removed, 0 files unresolved
   working directory now at 6e8148413dd5
+  1 changesets pruned
   $ hg debugobsolete
   9d206ffc875e1bc304590549be293be36821e66c 0 {47d2a3944de8b013de3be9578e8e344ea2e6c097} (Sat Dec 15 00:00:00 1979 +0000) {'user': 'blah'}
   7c3bad9141dcb46ff89abf5f61856facd56e476c 0 {1f0dee641bb7258c56bd60e93edfa2405381c41e} (*) {'user': 'test'} (glob)
@@ -208,9 +208,9 @@
   $ mkcommit n2
 
   $ hg prune 'desc("add n1")::desc("add n2")' -s 'desc("add nD")::desc("add nE")' --biject
-  2 changesets pruned
   0 files updated, 0 files merged, 2 files removed, 0 files unresolved
   working directory now at 1f0dee641bb7
+  2 changesets pruned
   $ hg debugobsolete
   9d206ffc875e1bc304590549be293be36821e66c 0 {47d2a3944de8b013de3be9578e8e344ea2e6c097} (Sat Dec 15 00:00:00 1979 +0000) {'user': 'blah'}
   7c3bad9141dcb46ff89abf5f61856facd56e476c 0 {1f0dee641bb7258c56bd60e93edfa2405381c41e} (*) {'user': 'test'} (glob)
@@ -231,9 +231,9 @@
   created new head
   $ mkcommit n2
   $ hg --config extensions.strip= --config experimental.prunestrip=True strip -r .
-  1 changesets pruned
   0 files updated, 0 files merged, 1 files removed, 0 files unresolved
   working directory now at c7e58696a948
+  1 changesets pruned
   $ hg --config extensions.strip= --config experimental.prunestrip=True strip -r . --bundle
   0 files updated, 0 files merged, 1 files removed, 0 files unresolved
   saved backup bundle to $TESTTMP/repo/.hg/strip-backup/c7e58696a948-69ca36d3-backup.hg (glob)
@@ -272,11 +272,11 @@
   [255]
   $ hg tag --remove --local a
   $ hg prune -B todelete
-  1 changesets pruned
   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
   (leaving bookmark todelete)
   working directory now at d62d843c9a01
   bookmark 'todelete' deleted
+  1 changesets pruned
   $ hg id -ir dcbb326fdec2
   abort: hidden revision 'dcbb326fdec2'!
   (use --hidden to access hidden revisions)
@@ -287,8 +287,8 @@
      B                         10:ff43616e5d0f
      delete                    6:2702dd0c91e7
   $ hg prune -B delete
+  bookmark 'delete' deleted
   3 changesets pruned
-  bookmark 'delete' deleted
   $ hg tag --remove --local c
   $ hg id -ir 6:2702dd0c91e7
   abort: hidden revision '6'!
--- a/tests/test-tutorial.t	Fri Apr 03 11:35:46 2015 -0700
+++ b/tests/test-tutorial.t	Thu Apr 02 18:33:44 2015 -0700
@@ -289,9 +289,9 @@
 not fit well in my standard shopping list)
 
   $ hg prune . # "." is for working directory parent
-  1 changesets pruned
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   working directory now at 41aff6a42b75
+  1 changesets pruned
 
 The silly changeset is gone.
 
@@ -804,9 +804,9 @@
 In the mean time I noticed you can't buy animals in a super market and I prune the animal changeset:
 
   $ hg prune ee942144f952
-  1 changesets pruned
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   working directory now at a44c85f957d3
+  1 changesets pruned
   1 new unstable changesets
 
 
--- a/tests/test-userguide.t	Fri Apr 03 11:35:46 2015 -0700
+++ b/tests/test-userguide.t	Thu Apr 02 18:33:44 2015 -0700
@@ -66,9 +66,9 @@
   $ echo 'debug hack' >> file1.c
   $ hg commit -m 'debug hack'
   $ hg prune .
-  1 changesets pruned
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   working directory now at 934359450037
+  1 changesets pruned
   $ hg parents --template '{rev}:{node|short}  {desc|firstline}\n'
   3:934359450037  implement feature Y
   $ hg --hidden shortlog -G -r 3: