changeset 34291:624c53e4121d

uncommit: don't allow bare uncommit on dirty working directory As per IRC discussion and suggestion by Augie, we should not allow bare `hg uncommit` on dirty working directory. Differential Revision: https://phab.mercurial-scm.org/D734
author Pulkit Goyal <7895pulkit@gmail.com>
date Wed, 20 Sep 2017 02:18:01 +0530
parents f94442d46984
children 7b1e524ad73f
files hgext/uncommit.py tests/test-uncommit.t
diffstat 2 files changed, 7 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/uncommit.py	Sat Sep 16 02:34:13 2017 +0530
+++ b/hgext/uncommit.py	Wed Sep 20 02:18:01 2017 +0530
@@ -22,6 +22,7 @@
 from mercurial.i18n import _
 
 from mercurial import (
+    cmdutil,
     commands,
     context,
     copies,
@@ -148,6 +149,8 @@
     with repo.wlock(), repo.lock():
         wctx = repo[None]
 
+        if not pats:
+            cmdutil.bailifchanged(repo)
         if wctx.parents()[0].node() == node.nullid:
             raise error.Abort(_("cannot uncommit null changeset"))
         if len(wctx.parents()) > 1:
--- a/tests/test-uncommit.t	Sat Sep 16 02:34:13 2017 +0530
+++ b/tests/test-uncommit.t	Wed Sep 20 02:18:01 2017 +0530
@@ -149,6 +149,9 @@
   foo
   $ hg status
   M files
+  $ hg uncommit
+  abort: uncommitted changes
+  [255]
   $ hg uncommit files
   $ cat files
   abcde
@@ -337,7 +340,7 @@
   (branch merge, don't forget to commit)
 
   $ hg uncommit
-  abort: cannot uncommit while merging
+  abort: outstanding uncommitted merge
   [255]
 
   $ hg status