changeset 24772:8f6494eb16eb

histedit: move finishfold into fold class Let's move the finishfold function into the fold class so we can modify it from the roll class more easily.
author Durham Goode <durham@fb.com>
date Sat, 04 Apr 2015 02:12:24 -0700
parents 3133e246c912
children 090da03361c5
files hgext/histedit.py
diffstat 1 files changed, 43 insertions(+), 43 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/histedit.py	Sat Apr 04 02:03:27 2015 -0700
+++ b/hgext/histedit.py	Sat Apr 04 02:12:24 2015 -0700
@@ -546,53 +546,53 @@
         if isinstance(self, rollup):
             foldopts['rollup'] = True
 
-        return finishfold(repo.ui, repo, parentctx, rulectx, ctx.node(),
-                          foldopts, middlecommits)
+        return self.finishfold(repo.ui, repo, parentctx, rulectx, ctx.node(),
+                               foldopts, middlecommits)
+
+    def finishfold(self, ui, repo, ctx, oldctx, newnode, opts, internalchanges):
+        parent = ctx.parents()[0].node()
+        hg.update(repo, parent)
+        ### prepare new commit data
+        commitopts = opts.copy()
+        commitopts['user'] = ctx.user()
+        # commit message
+        if opts.get('rollup'):
+            newmessage = ctx.description()
+        else:
+            newmessage = '\n***\n'.join(
+                [ctx.description()] +
+                [repo[r].description() for r in internalchanges] +
+                [oldctx.description()]) + '\n'
+        commitopts['message'] = newmessage
+        # date
+        commitopts['date'] = max(ctx.date(), oldctx.date())
+        extra = ctx.extra().copy()
+        # histedit_source
+        # note: ctx is likely a temporary commit but that the best we can do
+        #       here. This is sufficient to solve issue3681 anyway.
+        extra['histedit_source'] = '%s,%s' % (ctx.hex(), oldctx.hex())
+        commitopts['extra'] = extra
+        phasebackup = repo.ui.backupconfig('phases', 'new-commit')
+        try:
+            phasemin = max(ctx.phase(), oldctx.phase())
+            repo.ui.setconfig('phases', 'new-commit', phasemin, 'histedit')
+            n = collapse(repo, ctx, repo[newnode], commitopts)
+        finally:
+            repo.ui.restoreconfig(phasebackup)
+        if n is None:
+            return ctx, []
+        hg.update(repo, n)
+        replacements = [(oldctx.node(), (newnode,)),
+                        (ctx.node(), (n,)),
+                        (newnode, (n,)),
+                       ]
+        for ich in internalchanges:
+            replacements.append((ich, (n,)))
+        return repo[n], replacements
 
 class rollup(fold):
     pass
 
-def finishfold(ui, repo, ctx, oldctx, newnode, opts, internalchanges):
-    parent = ctx.parents()[0].node()
-    hg.update(repo, parent)
-    ### prepare new commit data
-    commitopts = opts.copy()
-    commitopts['user'] = ctx.user()
-    # commit message
-    if opts.get('rollup'):
-        newmessage = ctx.description()
-    else:
-        newmessage = '\n***\n'.join(
-            [ctx.description()] +
-            [repo[r].description() for r in internalchanges] +
-            [oldctx.description()]) + '\n'
-    commitopts['message'] = newmessage
-    # date
-    commitopts['date'] = max(ctx.date(), oldctx.date())
-    extra = ctx.extra().copy()
-    # histedit_source
-    # note: ctx is likely a temporary commit but that the best we can do here
-    #       This is sufficient to solve issue3681 anyway
-    extra['histedit_source'] = '%s,%s' % (ctx.hex(), oldctx.hex())
-    commitopts['extra'] = extra
-    phasebackup = repo.ui.backupconfig('phases', 'new-commit')
-    try:
-        phasemin = max(ctx.phase(), oldctx.phase())
-        repo.ui.setconfig('phases', 'new-commit', phasemin, 'histedit')
-        n = collapse(repo, ctx, repo[newnode], commitopts)
-    finally:
-        repo.ui.restoreconfig(phasebackup)
-    if n is None:
-        return ctx, []
-    hg.update(repo, n)
-    replacements = [(oldctx.node(), (newnode,)),
-                    (ctx.node(), (n,)),
-                    (newnode, (n,)),
-                   ]
-    for ich in internalchanges:
-        replacements.append((ich, (n,)))
-    return repo[n], replacements
-
 class drop(histeditaction):
     def run(self):
         parentctx = self.repo[self.state.parentctxnode]