Patchwork [evolve] prune: update to successor rather than parent when killing '.'

login
register
mail settings
Submitter Dan Villiom Podlaski Christiansen
Date Jan. 9, 2014, 10:37 a.m.
Message ID <5d03689228e8b7006f22.1389263875@dork.local>
Download mbox | patch
Permalink /patch/3282/
State Superseded
Headers show

Comments

Dan Villiom Podlaski Christiansen - Jan. 9, 2014, 10:37 a.m.
# HG changeset patch
# User Dan Villiom Podlaski Christiansen <dan@cabo.dk>
# Date 1389263595 -3600
#      Thu Jan 09 11:33:15 2014 +0100
# Node ID 5d03689228e8b7006f22d2c6da219f9136a64421
# Parent  d5e25eaaee317a4bcf238b3adba7526d807dd0cc
prune: update to successor rather than parent when killing '.'
Sean Farley - Jan. 9, 2014, 6:52 p.m.
dan@cabo.dk writes:

> # HG changeset patch
> # User Dan Villiom Podlaski Christiansen <dan@cabo.dk>
> # Date 1389263595 -3600
> #      Thu Jan 09 11:33:15 2014 +0100
> # Node ID 5d03689228e8b7006f22d2c6da219f9136a64421
> # Parent  d5e25eaaee317a4bcf238b3adba7526d807dd0cc
> prune: update to successor rather than parent when killing '.'

I'm unsure about this change. At the very least, it should have a flag
to turn it off. There are operations I do where I prune a lot of
contiguous changesets in a for loop where doing an update would
dramatically increase the time.

I'm open to changing my ways, though, if prune could take a range for
both the -r and -s arguments.
Pierre-Yves David - Jan. 11, 2014, 1:53 a.m.
On 01/09/2014 02:37 AM, Dan Villiom Podlaski Christiansen wrote:
> # HG changeset patch
> # User Dan Villiom Podlaski Christiansen <dan@cabo.dk>
> # Date 1389263595 -3600
> #      Thu Jan 09 11:33:15 2014 +0100
> # Node ID 5d03689228e8b7006f22d2c6da219f9136a64421
> # Parent  d5e25eaaee317a4bcf238b3adba7526d807dd0cc
> prune: update to successor rather than parent when killing '.'

The change looks great and the test sound good, Thanks!
But if you expect me to accept patches with a one line description, I 
need to work on my reputation. Can you extend it a bit please?

>
> diff --git a/hgext/evolve.py b/hgext/evolve.py
> --- a/hgext/evolve.py
> +++ b/hgext/evolve.py
> @@ -1437,11 +1437,19 @@ def cmdprune(ui, repo, *revs, **opts):
>   
>           # informs that changeset have been pruned
>           ui.status(_('%i changesets pruned\n') % len(precs))
> -        # update to an unkilled parent
> +
>           wdp = repo['.']
> -        newnode = wdp
> -        while newnode.obsolete():
> -            newnode = newnode.parents()[0]
> +
> +        if len(sucs) == 1 and len(precs) == 1 and wdp in precs:
> +            # '.' killed, so update to the successor
> +            newnode = sucs[0]
> +        else:
> +            # update to an unkilled parent
> +            newnode = wdp
> +
> +            while newnode.obsolete():
> +                newnode = newnode.parents()[0]
> +
>           if newnode.node() != wdp.node():
>               commands.update(ui, repo, newnode.rev())
>               ui.status(_('working directory now at %s\n') % newnode)
> diff --git a/tests/test-prune.t b/tests/test-prune.t
> --- a/tests/test-prune.t
> +++ b/tests/test-prune.t
> @@ -115,8 +115,12 @@ Check successors addition
>   
>   one old, one new
>   
> +  $ 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
>     $ hg debugobsolete
>     9d206ffc875e1bc304590549be293be36821e66c 0 {'date': '314064000 0', 'user': 'blah'} (glob)
>     7c3bad9141dcb46ff89abf5f61856facd56e476c 0 {'date': '*', 'user': 'test'} (glob)
> @@ -231,4 +235,3 @@ yoinked from test-mq-strip.t
>     $ hg id -ir 6:2702dd0c91e7
>     abort: unknown revision '2702dd0c91e7'!
>     [255]
> -
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
Pierre-Yves David - Jan. 11, 2014, 1:55 a.m.
On 01/09/2014 10:52 AM, Sean Farley wrote:
> dan@cabo.dk writes:
>
>> # HG changeset patch
>> # User Dan Villiom Podlaski Christiansen <dan@cabo.dk>
>> # Date 1389263595 -3600
>> #      Thu Jan 09 11:33:15 2014 +0100
>> # Node ID 5d03689228e8b7006f22d2c6da219f9136a64421
>> # Parent  d5e25eaaee317a4bcf238b3adba7526d807dd0cc
>> prune: update to successor rather than parent when killing '.'
> I'm unsure about this change. At the very least, it should have a flag
> to turn it off. There are operations I do where I prune a lot of
> contiguous changesets in a for loop where doing an update would
> dramatically increase the time.
>
> I'm open to changing my ways, though, if prune could take a range for
> both the -r and -s arguments.

This behavior could be done with an extra flag. I'm doing it all the 
time too. But if we get a way to have Matt creating marker when queuing 
I believe it would be less useful (but still useful)

Patch

diff --git a/hgext/evolve.py b/hgext/evolve.py
--- a/hgext/evolve.py
+++ b/hgext/evolve.py
@@ -1437,11 +1437,19 @@  def cmdprune(ui, repo, *revs, **opts):
 
         # informs that changeset have been pruned
         ui.status(_('%i changesets pruned\n') % len(precs))
-        # update to an unkilled parent
+
         wdp = repo['.']
-        newnode = wdp
-        while newnode.obsolete():
-            newnode = newnode.parents()[0]
+
+        if len(sucs) == 1 and len(precs) == 1 and wdp in precs:
+            # '.' killed, so update to the successor
+            newnode = sucs[0]
+        else:
+            # update to an unkilled parent
+            newnode = wdp
+
+            while newnode.obsolete():
+                newnode = newnode.parents()[0]
+
         if newnode.node() != wdp.node():
             commands.update(ui, repo, newnode.rev())
             ui.status(_('working directory now at %s\n') % newnode)
diff --git a/tests/test-prune.t b/tests/test-prune.t
--- a/tests/test-prune.t
+++ b/tests/test-prune.t
@@ -115,8 +115,12 @@  Check successors addition
 
 one old, one new
 
+  $ 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
   $ hg debugobsolete
   9d206ffc875e1bc304590549be293be36821e66c 0 {'date': '314064000 0', 'user': 'blah'} (glob)
   7c3bad9141dcb46ff89abf5f61856facd56e476c 0 {'date': '*', 'user': 'test'} (glob)
@@ -231,4 +235,3 @@  yoinked from test-mq-strip.t
   $ hg id -ir 6:2702dd0c91e7
   abort: unknown revision '2702dd0c91e7'!
   [255]
-