import: use ui.allowemptycommit to allow empty commits
authorDurham Goode <durham@fb.com>
Mon, 11 May 2015 20:15:41 -0700
changeset 25020 747055706e85
parent 25019 672e0558aed1
child 25021 9a74b9919581
import: use ui.allowemptycommit to allow empty commits Previously import used force=partial to allow empty commits to be made. Let's switch it to using the new ui.allowemptycommit option. Tests says we can drop the 'force' argument in the processs.
mercurial/cmdutil.py
--- a/mercurial/cmdutil.py	Mon May 11 17:51:22 2015 -0700
+++ b/mercurial/cmdutil.py	Mon May 11 20:15:41 2015 -0700
@@ -897,9 +897,15 @@
                     editor = None
                 else:
                     editor = getcommiteditor(editform=editform, **opts)
-                n = repo.commit(message, opts.get('user') or user,
-                                opts.get('date') or date, match=m,
-                                editor=editor, force=partial)
+                allowemptyback = repo.ui.backupconfig('ui', 'allowemptycommit')
+                try:
+                    if partial:
+                        repo.ui.setconfig('ui', 'allowemptycommit', True)
+                    n = repo.commit(message, opts.get('user') or user,
+                                    opts.get('date') or date, match=m,
+                                    editor=editor)
+                finally:
+                    repo.ui.restoreconfig(allowemptyback)
             dsguard.close()
         else:
             if opts.get('exact') or opts.get('import_branch'):