Patchwork [5,of,8,evolve-ext,V2] metaedit: use faster setparents instead of full update

login
register
mail settings
Submitter Mateusz Kwapich
Date Dec. 6, 2016, 4:41 p.m.
Message ID <651b6258e993f6d45e4e.1481042474@devvm314.lla2.facebook.com>
Download mbox | patch
Permalink /patch/17835/
State Changes Requested
Headers show

Comments

Mateusz Kwapich - Dec. 6, 2016, 4:41 p.m.
# HG changeset patch
# User Mateusz Kwapich <mitrandir@fb.com>
# Date 1479325623 0
#      Wed Nov 16 19:47:03 2016 +0000
# Branch stable
# Node ID 651b6258e993f6d45e4ef7b324303201db5639b2
# Parent  d4a8c386a14b3e455e60fffec7fb315f9629ff12
metaedit: use faster setparents instead of full update

The working copy is not changing so there is no need to extra status call.
This makes metaedit work on dirty wc.
Pierre-Yves David - Dec. 20, 2016, 6:45 p.m.
On 12/06/2016 05:41 PM, Mateusz Kwapich wrote:
> # HG changeset patch
> # User Mateusz Kwapich <mitrandir@fb.com>
> # Date 1479325623 0
> #      Wed Nov 16 19:47:03 2016 +0000
> # Branch stable
> # Node ID 651b6258e993f6d45e4ef7b324303201db5639b2
> # Parent  d4a8c386a14b3e455e60fffec7fb315f9629ff12
> metaedit: use faster setparents instead of full update
>
> The working copy is not changing so there is no need to extra status call.

Urg, not very enthusiastic. Can we have at least number about this speedup ?

> This makes metaedit work on dirty wc.

Note that since the file are identical on both side, we are sure there 
won't be merge conflict so we could use the update logic (enabling 
"merging"  and that would work as well. I would probably be move 
comfortable accepting something enable fold from a dirty WC using update 
and then another one moving to set parent.

> diff --git a/hgext/evolve.py b/hgext/evolve.py
> --- a/hgext/evolve.py
> +++ b/hgext/evolve.py
> @@ -3303,7 +3303,7 @@ def metaedit(ui, repo, *revs, **opts):
>          if opts['fold']:
>              ui.status('%i changesets folded\n' % len(revs))
>          if newp1 is not None:
> -            hg.update(repo, newp1)
> +            repo.setparents(newp1)
>      finally:
>          lockmod.release(lock, wlock)
>
> diff --git a/tests/test-evolve.t b/tests/test-evolve.t
> --- a/tests/test-evolve.t
> +++ b/tests/test-evolve.t
> @@ -1489,7 +1489,6 @@ check that metaedit respects allowunstab
>    abort: cannot fold chain not ending with a head or with branching
>    [255]
>    $ hg metaedit --user foobar
> -  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
>    $ hg log --template '{rev}: {author}\n' -r '42:' --hidden
>    42: test
>    43: foobar
> @@ -1497,7 +1496,6 @@ check that metaedit respects allowunstab
>    43: foobar
>
>    $ HGEDITOR="sed -i'' -e 's/safely/quickly/g'" hg metaedit '.^::.'
> -  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
>
>    $ HGEDITOR=cat hg metaedit '.^::.' --fold
>    HG: This is a fold of 2 changesets.
> @@ -1519,7 +1517,6 @@ check that metaedit respects allowunstab
>    HG: changed a
>    HG: changed newfile
>    2 changesets folded
> -  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
>
>    $ glog -r .
>    @  45:ca7a9e928b25@default(draft) amended
> @@ -1553,7 +1550,6 @@ no new commit is created here because th
>
>  TODO: don't create a new commit in this case
>    $ hg metaedit --config defaults.metaedit=
> -  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
>    $ hg log -r '.^::.' --template '{rev}: {desc|firstline}\n'
>    36: add uu
>    46: amended
> @@ -1570,8 +1566,11 @@ TODO: don't create a new commit in this
>    47: foobar2
>    $ hg diff -r 45 -r 46 --hidden
>
> -'fold' one commit
> +'fold' one commit with dirty wc
> +  $ echo x > newfile
>    $ hg metaedit 39 --fold --user foobar3
>    1 changesets folded
>    $ hg log -r 48 --template '{rev}: {author}\n'
>    48: foobar3
> +  $ hg st -amr
> +  M newfile

Cheers,

Patch

diff --git a/hgext/evolve.py b/hgext/evolve.py
--- a/hgext/evolve.py
+++ b/hgext/evolve.py
@@ -3303,7 +3303,7 @@  def metaedit(ui, repo, *revs, **opts):
         if opts['fold']:
             ui.status('%i changesets folded\n' % len(revs))
         if newp1 is not None:
-            hg.update(repo, newp1)
+            repo.setparents(newp1)
     finally:
         lockmod.release(lock, wlock)
 
diff --git a/tests/test-evolve.t b/tests/test-evolve.t
--- a/tests/test-evolve.t
+++ b/tests/test-evolve.t
@@ -1489,7 +1489,6 @@  check that metaedit respects allowunstab
   abort: cannot fold chain not ending with a head or with branching
   [255]
   $ hg metaedit --user foobar
-  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ hg log --template '{rev}: {author}\n' -r '42:' --hidden
   42: test
   43: foobar
@@ -1497,7 +1496,6 @@  check that metaedit respects allowunstab
   43: foobar
 
   $ HGEDITOR="sed -i'' -e 's/safely/quickly/g'" hg metaedit '.^::.'
-  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
 
   $ HGEDITOR=cat hg metaedit '.^::.' --fold
   HG: This is a fold of 2 changesets.
@@ -1519,7 +1517,6 @@  check that metaedit respects allowunstab
   HG: changed a
   HG: changed newfile
   2 changesets folded
-  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
 
   $ glog -r .
   @  45:ca7a9e928b25@default(draft) amended
@@ -1553,7 +1550,6 @@  no new commit is created here because th
 
 TODO: don't create a new commit in this case
   $ hg metaedit --config defaults.metaedit=
-  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ hg log -r '.^::.' --template '{rev}: {desc|firstline}\n'
   36: add uu
   46: amended
@@ -1570,8 +1566,11 @@  TODO: don't create a new commit in this 
   47: foobar2
   $ hg diff -r 45 -r 46 --hidden
 
-'fold' one commit
+'fold' one commit with dirty wc
+  $ echo x > newfile
   $ hg metaedit 39 --fold --user foobar3
   1 changesets folded
   $ hg log -r 48 --template '{rev}: {author}\n'
   48: foobar3
+  $ hg st -amr
+  M newfile