Patchwork [1,of,2] shelve: Move commitfunc closer to use site

login
register
mail settings
Submitter Simon Farnsworth
Date Jan. 14, 2016, 9:09 p.m.
Message ID <727b137e82bed8ac97cf.1452805772@devvm148.ash3.facebook.com>
Download mbox | patch
Permalink /patch/12768/
State Accepted
Commit 6c740218215dc48a307295eb93c762444fb0f00b
Delegated to: Pierre-Yves David
Headers show

Comments

Simon Farnsworth - Jan. 14, 2016, 9:09 p.m.
# HG changeset patch
# User Simon Farnsworth <simonfar@fb.com>
# Date 1452804779 28800
#      Thu Jan 14 12:52:59 2016 -0800
# Node ID 727b137e82bed8ac97cfa4d9ddaa29e92bf393f3
# Parent  4571c0b383378f5eec5189e3a39c672a169ce566
shelve: Move commitfunc closer to use site

Supporting shelving of unknown files needs this code motion.

No functional changes.
Matt Mackall - Jan. 18, 2016, 1:33 a.m.
On Thu, 2016-01-14 at 13:09 -0800, Simon Farnsworth wrote:
> # HG changeset patch
> # User Simon Farnsworth <simonfar@fb.com>
> # Date 1452804779 28800
> #      Thu Jan 14 12:52:59 2016 -0800
> # Node ID 727b137e82bed8ac97cfa4d9ddaa29e92bf393f3
> # Parent  4571c0b383378f5eec5189e3a39c672a169ce566
> shelve: Move commitfunc closer to use site

Queued this patch, thanks. contrib/check-commit sends its greetings.

-- 
Mathematics is the supreme nostalgia of our time.

Patch

diff --git a/hgext/shelve.py b/hgext/shelve.py
--- a/hgext/shelve.py
+++ b/hgext/shelve.py
@@ -267,21 +267,6 @@ 
         for i in xrange(1, 100):
             yield '%s-%02d' % (label, i)
 
-    def commitfunc(ui, repo, message, match, opts):
-        hasmq = util.safehasattr(repo, 'mq')
-        if hasmq:
-            saved, repo.mq.checkapplied = repo.mq.checkapplied, False
-        backup = repo.ui.backupconfig('phases', 'new-commit')
-        try:
-            repo.ui. setconfig('phases', 'new-commit', phases.secret)
-            editor = cmdutil.getcommiteditor(editform='shelve.shelve', **opts)
-            return repo.commit(message, user, opts.get('date'), match,
-                               editor=editor)
-        finally:
-            repo.ui.restoreconfig(backup)
-            if hasmq:
-                repo.mq.checkapplied = saved
-
     if parent.node() != nullid:
         desc = "changes to: %s" % parent.description().split('\n', 1)[0]
     else:
@@ -320,6 +305,22 @@ 
             raise error.Abort(_("shelved change names may not start with '.'"))
         interactive = opts.get('interactive', False)
 
+        def commitfunc(ui, repo, message, match, opts):
+            hasmq = util.safehasattr(repo, 'mq')
+            if hasmq:
+                saved, repo.mq.checkapplied = repo.mq.checkapplied, False
+            backup = repo.ui.backupconfig('phases', 'new-commit')
+            try:
+                repo.ui. setconfig('phases', 'new-commit', phases.secret)
+                editor = cmdutil.getcommiteditor(editform='shelve.shelve',
+                                                 **opts)
+                return repo.commit(message, user, opts.get('date'), match,
+                                   editor=editor)
+            finally:
+                repo.ui.restoreconfig(backup)
+                if hasmq:
+                    repo.mq.checkapplied = saved
+
         def interactivecommitfunc(ui, repo, *pats, **opts):
             match = scmutil.match(repo['.'], pats, {})
             message = opts['message']