changeset 4298:a98fa6c0d4f3

split: only accept explicit revision through the `-r` option We are about to introduce new non-optionnal arguments to defines files patterns. To avoid confusion and to be closer to the standard options, only accepts revisions with the `-r` option.
author Boris Feld <boris.feld@octobus.net>
date Wed, 21 Feb 2018 12:39:17 +0100
parents b8cb1bdbc8d7
children 4af0235e7b0b
files CHANGELOG hgext3rd/evolve/cmdrewrite.py tests/test-evolve-obshistory-complex.t tests/test-split.t
diffstat 4 files changed, 18 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/CHANGELOG	Thu Dec 13 17:26:26 2018 +0100
+++ b/CHANGELOG	Wed Feb 21 12:39:17 2018 +0100
@@ -6,6 +6,7 @@
 
   * split: improve and update the user prompt (BC)
   * split: make it possible to drop change during a split
+  * split: no longer accept revision with --rev (BC)
   * push: have `--publish` overrule the `auto-publish` config
   * next: evolve aspiring children by default (use --no-evolve to skip)
   * next: pick lower part of a split as destination
--- a/hgext3rd/evolve/cmdrewrite.py	Thu Dec 13 17:26:26 2018 +0100
+++ b/hgext3rd/evolve/cmdrewrite.py	Wed Feb 21 12:39:17 2018 +0100
@@ -1135,9 +1135,9 @@
     [('r', 'rev', [], _("revision to split"), _('REV')),
      ('n', 'note', '', _("store a note on split"), _('TEXT')),
     ] + commitopts + commitopts2 + commitopts3,
-    _('hg split [OPTION]... [-r] REV'),
+    _('hg split [OPTION]... [-r REV]'),
     helpbasic=True)
-def cmdsplit(ui, repo, *revs, **opts):
+def cmdsplit(ui, repo, **opts):
     """split a changeset into smaller changesets
 
     By default, split the current revision by prompting for all its hunks to be
@@ -1150,11 +1150,15 @@
     tr = wlock = lock = None
     newcommits = []
 
-    revarg = (list(revs) + opts.get('rev')) or ['.']
-    if len(revarg) != 1:
-        msg = _("more than one revset is given")
-        hnt = _("use either `hg split <rs>` or `hg split --rev <rs>`, not both")
-        raise error.Abort(msg, hint=hnt)
+    revs = opts.get('rev') or '.'
+    if not revs:
+        revarg = '.'
+    elif len(revs) == 1:
+        revarg = revs[0]
+    else:
+        # XXX --rev often accept multiple value, it seems safer to explicitly
+        # complains here instead of just taking the last value.
+        raise error.Abort(_('more than one revset is given'))
 
     # Save the current branch to restore it in the end
     savedbranch = repo.dirstate.branch()
@@ -1162,7 +1166,7 @@
     try:
         wlock = repo.wlock()
         lock = repo.lock()
-        ctx = scmutil.revsingle(repo, revarg[0])
+        ctx = scmutil.revsingle(repo, revarg)
         rev = ctx.rev()
         cmdutil.bailifchanged(repo)
         rewriteutil.precheck(repo, [rev], action='split')
--- a/tests/test-evolve-obshistory-complex.t	Thu Dec 13 17:26:26 2018 +0100
+++ b/tests/test-evolve-obshistory-complex.t	Wed Feb 21 12:39:17 2018 +0100
@@ -140,7 +140,7 @@
 Then split
 ----------
 
-  $ hg split "desc(fold0)" -d "0 0" << EOF
+  $ hg split --rev "desc(fold0)" -d "0 0" << EOF
   > Y
   > Y
   > N
@@ -174,7 +174,7 @@
   record this change to 'B'? [Ynesfdaq?] Y
   
   no more change to split
-  $ hg split "desc(fold1)" -d "0 0" << EOF
+  $ hg split --rev "desc(fold1)" -d "0 0" << EOF
   > Y
   > Y
   > N
@@ -209,7 +209,7 @@
   
   no more change to split
   1 new orphan changesets
-  $ hg split "desc(fold2)" -d "0 0" << EOF
+  $ hg split --rev "desc(fold2)" -d "0 0" << EOF
   > Y
   > Y
   > N
--- a/tests/test-split.t	Thu Dec 13 17:26:26 2018 +0100
+++ b/tests/test-split.t	Wed Feb 21 12:39:17 2018 +0100
@@ -366,7 +366,7 @@
   [255]
 
 Running split with tip revision, specified as unnamed argument
-  $ hg split . << EOF
+  $ hg split --rev . << EOF
   > q
   > EOF
   0 files updated, 0 files merged, 1 files removed, 0 files unresolved
@@ -379,11 +379,10 @@
   [255]
 
 Running split with both unnamed and named revision arguments shows an error msg
-  $ hg split . --rev .^ << EOF
+  $ hg split  --rev . --rev .^ << EOF
   > q
   > EOF
   abort: more than one revset is given
-  (use either `hg split <rs>` or `hg split --rev <rs>`, not both)
   [255]
 
 Split empty commit (issue5191)