Patchwork [5,of,8,v8] rebase: move local variable 'extrafn' to the RR class

login
register
mail settings
Submitter Kostia Balytskyi
Date July 1, 2016, 12:30 p.m.
Message ID <AM3PR06MB1478EC5F48E367B80E32326D3250@AM3PR06MB147.eurprd06.prod.outlook.com>
Download mbox | patch
Permalink /patch/15709/
State Accepted
Delegated to: Yuya Nishihara
Headers show

Comments

Kostia Balytskyi - July 1, 2016, 12:30 p.m.
# HG changeset patch
# User Kostia Balytskyi <ikostia@fb.com>
# Date 1467374993 -7200
#      Fri Jul 01 14:09:53 2016 +0200
# Node ID a6e711ccd5e72d1642f4d6408a2ac4be59a11f08
# Parent  cbde74c620450392d7e95f9f9664d79a9f6b8e9a
rebase: move local variable 'extrafn' to the RR class
Yuya Nishihara - July 3, 2016, 9:29 a.m.
On Fri, 1 Jul 2016 12:30:13 +0000, Kostiantyn Balytskyi wrote:
> # HG changeset patch
> # User Kostia Balytskyi <ikostia@fb.com>
> # Date 1467374993 -7200
> #      Fri Jul 01 14:09:53 2016 +0200
> # Node ID a6e711ccd5e72d1642f4d6408a2ac4be59a11f08
> # Parent  cbde74c620450392d7e95f9f9664d79a9f6b8e9a
> rebase: move local variable 'extrafn' to the RR class
> 
> diff --git a/hgext/rebase.py b/hgext/rebase.py
> --- a/hgext/rebase.py
> +++ b/hgext/rebase.py
> @@ -148,6 +148,7 @@ class rebaseruntime(object):
>          self.extrafns = [_savegraft]
>          if e:
>              self.extrafns = [e]
> +        self.extrafn = None
>  
>          self.keepf = opts.get('keep', False)
>          self.keepbranchesf = opts.get('keepbranches', False)
> @@ -498,7 +499,7 @@ def rebase(ui, repo, **opts):
>          if rbsrt.activebookmark:
>              bookmarks.deactivate(repo)
>  
> -        extrafn = _makeextrafn(rbsrt.extrafns)
> +        rbsrt.extrafn = _makeextrafn(rbsrt.extrafns)

I think rbrst.makeextrafn() would be better than making rbrst more stateful.
extrafn is used only twice.

Patch

diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -148,6 +148,7 @@  class rebaseruntime(object):
         self.extrafns = [_savegraft]
         if e:
             self.extrafns = [e]
+        self.extrafn = None
 
         self.keepf = opts.get('keep', False)
         self.keepbranchesf = opts.get('keepbranches', False)
@@ -498,7 +499,7 @@  def rebase(ui, repo, **opts):
         if rbsrt.activebookmark:
             bookmarks.deactivate(repo)
 
-        extrafn = _makeextrafn(rbsrt.extrafns)
+        rbsrt.extrafn = _makeextrafn(rbsrt.extrafns)
 
         rbsrt.sortedstate = sorted(rbsrt.state)
         total = len(rbsrt.sortedstate)
@@ -542,7 +543,8 @@  def rebase(ui, repo, **opts):
                     merging = p2 != nullrev
                     editform = cmdutil.mergeeditform(merging, 'rebase')
                     editor = cmdutil.getcommiteditor(editform=editform, **opts)
-                    newnode = concludenode(repo, rev, p1, p2, extrafn=extrafn,
+                    newnode = concludenode(repo, rev, p1, p2,
+                                           extrafn=rbsrt.extrafn,
                                            editor=editor,
                                            keepbranches=rbsrt.keepbranchesf,
                                            date=rbsrt.date)
@@ -603,7 +605,7 @@  def rebase(ui, repo, **opts):
             revtoreuse = rbsrt.sortedstate[-1]
             newnode = concludenode(repo, revtoreuse, p1, rbsrt.external,
                                    commitmsg=commitmsg,
-                                   extrafn=extrafn, editor=editor,
+                                   extrafn=rbsrt.extrafn, editor=editor,
                                    keepbranches=rbsrt.keepbranchesf,
                                    date=rbsrt.date)
             if newnode is None: