diff hgext/uncommit.py @ 41865:aa284d9a33ca

uncommit: add flag --allow-dirty-working-copy This adds a flag `--allow-dirty-working-copy` as an alias for the experimental config option `experimental.uncommitondirtydir`. Differential Revision: https://phab.mercurial-scm.org/D6069
author Navaneeth Suresh <navaneeths1998@gmail.com>
date Mon, 04 Mar 2019 20:18:13 +0530
parents bf22e370ae9a
children bf72e4c39f0b
line wrap: on
line diff
--- a/hgext/uncommit.py	Tue Feb 12 00:17:42 2019 +0530
+++ b/hgext/uncommit.py	Mon Mar 04 20:18:13 2019 +0530
@@ -140,6 +140,8 @@
 
 @command('uncommit',
     [('', 'keep', None, _('allow an empty commit after uncommiting')),
+     ('', 'allow-dirty-working-copy', False,
+    _('allow uncommit with outstanding changes'))
     ] + commands.walkopts,
     _('[OPTION]... [FILE]...'),
     helpcategory=command.CATEGORY_CHANGE_MANAGEMENT)
@@ -160,10 +162,11 @@
 
         m, a, r, d = repo.status()[:4]
         isdirtypath = any(set(m + a + r + d) & set(pats))
-        if (not repo.ui.configbool('experimental', 'uncommitondirtywdir') and
-            (not pats or isdirtypath)):
+        allowdirtywcopy = (opts['allow_dirty_working_copy'] or
+                    repo.ui.configbool('experimental', 'uncommitondirtywdir'))
+        if not allowdirtywcopy and (not pats or isdirtypath):
             cmdutil.bailifchanged(repo, hint=_('requires '
-                                'experimental.uncommitondirtywdir to uncommit'))
+                                '--allow-dirty-working-copy to uncommit'))
         old = repo['.']
         rewriteutil.precheck(repo, [old.rev()], 'uncommit')
         if len(old.parents()) > 1: