Patchwork [2,of,2] graft: abort if --date/user specified with --currentdate/currentuser (BC)

login
register
mail settings
Submitter Yuya Nishihara
Date Jan. 10, 2019, 1:50 p.m.
Message ID <25fbe864cf9e28de2c9c.1547128215@mimosa>
Download mbox | patch
Permalink /patch/37620/
State Accepted
Headers show

Comments

Yuya Nishihara - Jan. 10, 2019, 1:50 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1547125041 -32400
#      Thu Jan 10 21:57:21 2019 +0900
# Node ID 25fbe864cf9e28de2c9c52cb9d7aa22c327be3ec
# Parent  d954358f5b9e810fadf9171d9724d99950b3358a
graft: abort if --date/user specified with --currentdate/currentuser (BC)

They are conflicting options. Let's explicitly ban such combination.

Note that this means you need "--no-currentdate --date" to override
--currentdate specified in aliases/defaults.

Patch

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -2393,6 +2393,10 @@  def _dograft(ui, repo, *revs, **opts):
     # list of new nodes created by ongoing graft
     statedata['newnodes'] = []
 
+    if opts.get('user') and opts.get('currentuser'):
+        raise error.Abort(_('--user and --currentuser are mutually exclusive'))
+    if opts.get('date') and opts.get('currentdate'):
+        raise error.Abort(_('--date and --currentdate are mutually exclusive'))
     if not opts.get('user') and opts.get('currentuser'):
         opts['user'] = ui.username()
     if not opts.get('date') and opts.get('currentdate'):
diff --git a/tests/test-graft.t b/tests/test-graft.t
--- a/tests/test-graft.t
+++ b/tests/test-graft.t
@@ -112,6 +112,16 @@  Specify revisions with -r:
   skipping ancestor revision 1:5d205f8b35b6
   [255]
 
+Conflicting date/user options:
+
+  $ hg up -q 0
+  $ hg graft -U --user foo 2
+  abort: --user and --currentuser are mutually exclusive
+  [255]
+  $ hg graft -D --date '0 0' 2
+  abort: --date and --currentdate are mutually exclusive
+  [255]
+
 Can't graft with dirty wd:
 
   $ hg up -q 0