Patchwork D8292: rebase: accept multiple --source arguments (BC)

login
register
mail settings
Submitter phabricator
Date March 14, 2020, 12:23 a.m.
Message ID <differential-rev-PHID-DREV-skysepvmksm2myv4baax-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/45779/
State Superseded
Headers show

Comments

phabricator - March 14, 2020, 12:23 a.m.
martinvonz created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  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.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  hgext/rebase.py
  relnotes/next
  tests/test-rebase-dest.t
  tests/test-rebase-parameters.t

CHANGE DETAILS




To: martinvonz, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/tests/test-rebase-parameters.t b/tests/test-rebase-parameters.t
--- a/tests/test-rebase-parameters.t
+++ b/tests/test-rebase-parameters.t
@@ -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]
diff --git a/tests/test-rebase-dest.t b/tests/test-rebase-dest.t
--- a/tests/test-rebase-dest.t
+++ b/tests/test-rebase-dest.t
@@ -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
diff --git a/relnotes/next b/relnotes/next
--- a/relnotes/next
+++ b/relnotes/next
@@ -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.
 
diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -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'),
         ),
         (
@@ -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: