changeset 44555:05654ea5137c

rebase: accept multiple --source arguments (BC) I think it's a little surprising that `hg rebase -s A -s B` rebases only `B::` and ignores `A`. That's because the `-s` flag is not a repeated flag. This patch makes it a repeated flag. Differential Revision: https://phab.mercurial-scm.org/D8292
author Martin von Zweigbergk <martinvonz@google.com>
date Fri, 13 Mar 2020 16:39:32 -0700
parents c4c97cabfc16
children f63598aa1c4b
files hgext/rebase.py relnotes/next tests/test-rebase-dest.t tests/test-rebase-parameters.t
diffstat 4 files changed, 19 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/rebase.py	Fri Mar 13 19:29:02 2020 -0700
+++ b/hgext/rebase.py	Fri Mar 13 16:39:32 2020 -0700
@@ -815,8 +815,8 @@
         (
             b's',
             b'source',
-            b'',
-            _(b'rebase the specified changeset and descendants'),
+            [],
+            _(b'rebase the specified changesets and their descendants'),
             _(b'REV'),
         ),
         (
@@ -871,7 +871,7 @@
     + cmdutil.dryrunopts
     + cmdutil.formatteropts
     + cmdutil.confirmopts,
-    _(b'[-s REV | -b REV | [-r REV]...] [-d REV] [OPTION]...'),
+    _(b'[[-s REV]... | -b REV | [-r REV]...] [-d REV] [OPTION]...'),
     helpcategory=command.CATEGORY_CHANGE_MANAGEMENT,
 )
 def rebase(ui, repo, **opts):
@@ -1186,7 +1186,7 @@
                 repo,
                 inmemory,
                 opts.get(b'dest', None),
-                opts.get(b'source', None),
+                opts.get(b'source', []),
                 opts.get(b'base', None),
                 opts.get(b'rev', []),
                 destspace=destspace,
@@ -1243,11 +1243,12 @@
             ui.status(_(b'empty "rev" revision set - nothing to rebase\n'))
             return None
     elif srcf:
-        src = scmutil.revrange(repo, [srcf])
+        src = scmutil.revrange(repo, srcf)
         if not src:
             ui.status(_(b'empty "source" revision set - nothing to rebase\n'))
             return None
-        rebaseset = repo.revs(b'(%ld)::', src) or src
+        # `+  (%ld)` to work around `wdir()::` being empty
+        rebaseset = repo.revs(b'(%ld):: + (%ld)', src, src)
     else:
         base = scmutil.revrange(repo, [basef or b'.'])
         if not base:
--- a/relnotes/next	Fri Mar 13 19:29:02 2020 -0700
+++ b/relnotes/next	Fri Mar 13 16:39:32 2020 -0700
@@ -58,6 +58,13 @@
    can use the new `conflictparents()` revset for finding the other
    parent during a conflict.
 
+ * `hg rebase` now accepts repeated `--source` arguments. For example,
+   `hg rebase --source 'A + B'` is equivalent to `hg rebase --source A
+   --source B`. This is a backwards-incompatible change because it
+   will break overriding an alias `myrebase = rebase --source A` by
+   `hg myrebase --source B` (it will now rebase `(A + B)::` instead of
+   `B::`).
+
  * `hg recover` does not verify the validity of the whole repository
    anymore. You can pass `--verify` or call `hg verify` if necessary.
 
--- a/tests/test-rebase-dest.t	Fri Mar 13 19:29:02 2020 -0700
+++ b/tests/test-rebase-dest.t	Fri Mar 13 16:39:32 2020 -0700
@@ -272,7 +272,7 @@
   
 Move to a previous parent:
 
-  $ rebasewithdag -s E+F+G -d 'SRC^^' <<'EOS'
+  $ rebasewithdag -s E -s F -s G -d 'SRC^^' <<'EOS'
   >     H
   >     |
   >   D G
--- a/tests/test-rebase-parameters.t	Fri Mar 13 19:29:02 2020 -0700
+++ b/tests/test-rebase-parameters.t	Fri Mar 13 16:39:32 2020 -0700
@@ -100,6 +100,10 @@
   abort: cannot rebase the working copy
   [255]
 
+  $ hg rebase --source 1 --source 'wdir()' --dest 6
+  abort: cannot rebase the working copy
+  [255]
+
   $ hg rebase --source '1 & !1' --dest 8
   empty "source" revision set - nothing to rebase
   [1]