D6842: uncommit: make -D/--date and -U/--user mutually exclusive

mharbison72 (Matt Harbison) phabricator at mercurial-scm.org
Wed Sep 11 03:01:38 EDT 2019


Closed by commit rHG4690902850df: uncommit: make -D/--date and -U/--user mutually exclusive (authored by mharbison72).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6842?vs=16510&id=16512

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6842/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D6842

AFFECTED FILES
  mercurial/cmdutil.py
  tests/test-uncommit.t

CHANGE DETAILS

diff --git a/tests/test-uncommit.t b/tests/test-uncommit.t
--- a/tests/test-uncommit.t
+++ b/tests/test-uncommit.t
@@ -549,10 +549,18 @@
   date:        Mon Jun 30 12:12:12 1980 +0000
   summary:     uncommit with message
   
+Bad option combinations
+
+  $ hg rollback -q --config ui.rollback=True
+  $ hg uncommit -U --user 'user'
+  abort: --user and --currentuser are mutually exclusive
+  [255]
+  $ hg uncommit -D --date today
+  abort: --date and --currentdate are mutually exclusive
+  [255]
 
 `uncommit <dir>` and `cd <dir> && uncommit .` behave the same...
 
-  $ hg rollback -q --config ui.rollback=True
   $ echo 2 > dir/file2.txt
   $ hg ci -Aqm 'add file2 in directory'
   $ hg uncommit dir
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -185,10 +185,17 @@
 def resolvecommitoptions(ui, opts):
     """modify commit options dict to handle related options
     """
+    if opts.get('date') and opts.get('currentdate'):
+        raise error.Abort(_('--date and --currentdate are mutually '
+                            'exclusive'))
+    if opts.get(b'user') and opts.get(b'currentuser'):
+        raise error.Abort(_('--user and --currentuser are mutually '
+                            'exclusive'))
+
     # N.B. this is extremely similar to setupheaderopts() in mq.py
-    if not opts.get(b'date') and opts.get(b'currentdate'):
+    if opts.get(b'currentdate'):
         opts[b'date'] = b'%d %d' % dateutil.makedate()
-    if not opts.get(b'user') and opts.get(b'currentuser'):
+    if opts.get(b'currentuser'):
         opts[b'user'] = ui.username()
 
 def ishunk(x):



To: mharbison72, #hg-reviewers, pulkit
Cc: mercurial-devel


More information about the Mercurial-devel mailing list