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

login
register
mail settings
Submitter phabricator
Date March 14, 2020, 9:33 a.m.
Message ID <71d49bf2112b6aa1ca17449b508f1b8d@localhost.localdomain>
Download mbox | patch
Permalink /patch/45794/
State Not Applicable
Headers show

Comments

phabricator - March 14, 2020, 9:33 a.m.
Closed by commit rHG05654ea5137c: rebase: accept multiple --source arguments (BC) (authored by martinvonz).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D8292?vs=20791&id=20795

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D8292/new/

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, mharbison72, pulkit
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'),
         ),
         (
@@ -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: