changeset 27888:6c740218215d

shelve: move commitfunc closer to use site Supporting shelving of unknown files needs this code motion. No functional changes.
author Simon Farnsworth <simonfar@fb.com>
date Thu, 14 Jan 2016 12:52:59 -0800
parents a30b582b8be4
children 88aa4da0cba8
files hgext/shelve.py
diffstat 1 files changed, 16 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/shelve.py	Thu Jan 14 21:21:59 2016 -0800
+++ b/hgext/shelve.py	Thu Jan 14 12:52:59 2016 -0800
@@ -264,21 +264,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:
@@ -317,6 +302,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']