shelve: move commitfunc closer to use site
authorSimon Farnsworth <simonfar@fb.com>
Thu, 14 Jan 2016 12:52:59 -0800
changeset 27888 6c740218215d
parent 27887 a30b582b8be4
child 27889 88aa4da0cba8
shelve: move commitfunc closer to use site Supporting shelving of unknown files needs this code motion. No functional changes.
hgext/shelve.py
--- 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']