Patchwork [03,of,10] histedit: use cg?unpacker.apply() instead of changegroup.addchangegroup()

login
register
mail settings
Submitter Augie Fackler
Date Oct. 14, 2015, 5:34 p.m.
Message ID <a2cf25ebbe3d6eaa5e2d.1444844068@augie-macbookair2.roam.corp.google.com>
Download mbox | patch
Permalink /patch/11053/
State Accepted
Headers show

Comments

Augie Fackler - Oct. 14, 2015, 5:34 p.m.
# HG changeset patch
# User Augie Fackler <augie@google.com>
# Date 1444770861 14400
#      Tue Oct 13 17:14:21 2015 -0400
# Node ID a2cf25ebbe3d6eaa5e2dcddd355ff8384dc35028
# Parent  2c2ad8c31a6d64c9186a7260d82aef79c61c75ac
histedit: use cg?unpacker.apply() instead of changegroup.addchangegroup()
Gregory Szorc - Oct. 14, 2015, 6:10 p.m.
On Wed, Oct 14, 2015 at 10:34 AM, Augie Fackler <raf@durin42.com> wrote:

> # HG changeset patch
> # User Augie Fackler <augie@google.com>
> # Date 1444770861 14400
> #      Tue Oct 13 17:14:21 2015 -0400
> # Node ID a2cf25ebbe3d6eaa5e2dcddd355ff8384dc35028
> # Parent  2c2ad8c31a6d64c9186a7260d82aef79c61c75ac
> histedit: use cg?unpacker.apply() instead of changegroup.addchangegroup()
>
> diff --git a/hgext/histedit.py b/hgext/histedit.py
> --- a/hgext/histedit.py
> +++ b/hgext/histedit.py
> @@ -163,7 +163,6 @@ import sys
>  from mercurial import cmdutil
>  from mercurial import discovery
>  from mercurial import error
> -from mercurial import changegroup
>  from mercurial import copies
>  from mercurial import context
>  from mercurial import exchange
> @@ -823,8 +822,7 @@ def _histedit(ui, repo, state, *freeargs
>                  backupfile = repo.join(state.backupfile)
>                  f = hg.openpath(ui, backupfile)
>                  gen = exchange.readbundle(ui, f, backupfile)
> -                changegroup.addchangegroup(repo, gen, 'histedit',
> -                                        'bundle:' + backupfile)
> +                gen.apply(repo, 'histedit', 'bundle:' + backupfile)
>

FWIW, this code is already wrong because it fails to handle bundle2. But
this is probably orthogonal to this series (we need a high level "apply
this bundle" API).
Augie Fackler - Oct. 14, 2015, 6:43 p.m.
> On Oct 14, 2015, at 14:10, Gregory Szorc <gregory.szorc@gmail.com> wrote:
> 
> On Wed, Oct 14, 2015 at 10:34 AM, Augie Fackler <raf@durin42.com <mailto:raf@durin42.com>> wrote:
> # HG changeset patch
> # User Augie Fackler <augie@google.com <mailto:augie@google.com>>
> # Date 1444770861 14400
> #      Tue Oct 13 17:14:21 2015 -0400
> # Node ID a2cf25ebbe3d6eaa5e2dcddd355ff8384dc35028
> # Parent  2c2ad8c31a6d64c9186a7260d82aef79c61c75ac
> histedit: use cg?unpacker.apply() instead of changegroup.addchangegroup()
> 
> diff --git a/hgext/histedit.py b/hgext/histedit.py
> --- a/hgext/histedit.py
> +++ b/hgext/histedit.py
> @@ -163,7 +163,6 @@ import sys
>  from mercurial import cmdutil
>  from mercurial import discovery
>  from mercurial import error
> -from mercurial import changegroup
>  from mercurial import copies
>  from mercurial import context
>  from mercurial import exchange
> @@ -823,8 +822,7 @@ def _histedit(ui, repo, state, *freeargs
>                  backupfile = repo.join(state.backupfile)
>                  f = hg.openpath(ui, backupfile)
>                  gen = exchange.readbundle(ui, f, backupfile)
> -                changegroup.addchangegroup(repo, gen, 'histedit',
> -                                        'bundle:' + backupfile)
> +                gen.apply(repo, 'histedit', 'bundle:' + backupfile)
> 
> FWIW, this code is already wrong because it fails to handle bundle2. But this is probably orthogonal to this series (we need a high level "apply this bundle" API). 

Yep. I'm trying to avoid scope creep on this refactor - totally agree that bundle application needs to be its own thing distinct from changegroups.

Patch

diff --git a/hgext/histedit.py b/hgext/histedit.py
--- a/hgext/histedit.py
+++ b/hgext/histedit.py
@@ -163,7 +163,6 @@  import sys
 from mercurial import cmdutil
 from mercurial import discovery
 from mercurial import error
-from mercurial import changegroup
 from mercurial import copies
 from mercurial import context
 from mercurial import exchange
@@ -823,8 +822,7 @@  def _histedit(ui, repo, state, *freeargs
                 backupfile = repo.join(state.backupfile)
                 f = hg.openpath(ui, backupfile)
                 gen = exchange.readbundle(ui, f, backupfile)
-                changegroup.addchangegroup(repo, gen, 'histedit',
-                                        'bundle:' + backupfile)
+                gen.apply(repo, 'histedit', 'bundle:' + backupfile)
                 os.remove(backupfile)
 
             # check whether we should update away