Patchwork [5,of,5] histedit: convert drop action into a class

login
register
mail settings
Submitter Durham Goode
Date April 14, 2015, 6:35 p.m.
Message ID <329572a4f5f2ec55d592.1429036522@dev2000.prn2.facebook.com>
Download mbox | patch
Permalink /patch/8662/
State Accepted
Delegated to: Augie Fackler
Headers show

Comments

Durham Goode - April 14, 2015, 6:35 p.m.
# HG changeset patch
# User Durham Goode <durham@fb.com>
# Date 1428132601 25200
#      Sat Apr 04 00:30:01 2015 -0700
# Node ID 329572a4f5f2ec55d592a6db3ea1ac2606bfdc91
# Parent  cc333abf57472637a5d33f0df2869cbe0bad0bde
histedit: convert drop action into a class

This converts the drop action into a histeditclass instance, as part of an
ongoing effort to refactor histedit for maintainability and robustness.
Augie Fackler - April 15, 2015, 10:32 p.m.
On Tue, Apr 14, 2015 at 11:35:22AM -0700, Durham Goode wrote:
> # HG changeset patch
> # User Durham Goode <durham@fb.com>
> # Date 1428132601 25200
> #      Sat Apr 04 00:30:01 2015 -0700
> # Node ID 329572a4f5f2ec55d592a6db3ea1ac2606bfdc91
> # Parent  cc333abf57472637a5d33f0df2869cbe0bad0bde
> histedit: convert drop action into a class

These are queued, but I thought you had more patches that finished
this and removed the old codepaths? Can you send that before I push?


>
> This converts the drop action into a histeditclass instance, as part of an
> ongoing effort to refactor histedit for maintainability and robustness.
>
> diff --git a/hgext/histedit.py b/hgext/histedit.py
> --- a/hgext/histedit.py
> +++ b/hgext/histedit.py
> @@ -501,11 +501,10 @@ def finishfold(ui, repo, ctx, oldctx, ne
>          replacements.append((ich, (n,)))
>      return repo[n], replacements
>
> -def drop(ui, state, ha, opts):
> -    repo, ctxnode = state.repo, state.parentctxnode
> -    ctx = repo[ctxnode]
> -    return ctx, [(repo[ha].node(), ())]
> -
> +class drop(histeditaction):
> +    def run(self):
> +        parentctx = self.repo[self.state.parentctxnode]
> +        return parentctx, [(self.node, tuple())]
>
>  def message(ui, state, ha, opts):
>      repo, ctxnode = state.repo, state.parentctxnode
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel

Patch

diff --git a/hgext/histedit.py b/hgext/histedit.py
--- a/hgext/histedit.py
+++ b/hgext/histedit.py
@@ -501,11 +501,10 @@  def finishfold(ui, repo, ctx, oldctx, ne
         replacements.append((ich, (n,)))
     return repo[n], replacements
 
-def drop(ui, state, ha, opts):
-    repo, ctxnode = state.repo, state.parentctxnode
-    ctx = repo[ctxnode]
-    return ctx, [(repo[ha].node(), ())]
-
+class drop(histeditaction):
+    def run(self):
+        parentctx = self.repo[self.state.parentctxnode]
+        return parentctx, [(self.node, tuple())]
 
 def message(ui, state, ha, opts):
     repo, ctxnode = state.repo, state.parentctxnode