# HG changeset patch # User Matt Harbison # Date 1568170324 14400 # Node ID 4690902850df0e165be87d4846ea13f5b78035c5 # Parent a50661567f836d8cdb4fc92f14b26b2a97bdcc72 uncommit: make -D/--date and -U/--user mutually exclusive This is how amend and graft work (but not MQ). I'm not sure why this didn't work for me when I first tried it. Differential Revision: https://phab.mercurial-scm.org/D6842 diff -r a50661567f83 -r 4690902850df mercurial/cmdutil.py --- a/mercurial/cmdutil.py Tue Sep 10 22:04:22 2019 -0400 +++ b/mercurial/cmdutil.py Tue Sep 10 22:52:04 2019 -0400 @@ -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): diff -r a50661567f83 -r 4690902850df tests/test-uncommit.t --- a/tests/test-uncommit.t Tue Sep 10 22:04:22 2019 -0400 +++ b/tests/test-uncommit.t Tue Sep 10 22:52:04 2019 -0400 @@ -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 ` and `cd && 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