Mercurial > hg
changeset 44774:c1c922391314 stable
phabricator: ensure that `phabsend` is given a contiguous, linear commit range
Supplying a non-linear range was another orphan factory. While in theory there
could be a use case for skipping over garbage commits (like adding debugging)
and getting the valuable commits extracted out at the same time as posting a
review, it seems far more likely that specifying a non-linear range is a user
error. This is another case of issue6045, but predates both 0680b8a1992a and
601ce5392cb0.
Neither the `--no-amend` case nor resubmitting a previously submitted commit
would cause orphans. But for the sake of simplicity and to keep the parents
tracked on Phabricator in the proper state, ban missing commits unconditionally.
Differential Revision: https://phab.mercurial-scm.org/D8454
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Thu, 16 Apr 2020 19:05:25 -0400 |
parents | 5e788dc7fb5d |
children | cf3e07d7648a |
files | hgext/phabricator.py tests/test-phabricator.t |
diffstat | 2 files changed, 27 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/phabricator.py Fri Apr 24 12:37:43 2020 -0700 +++ b/hgext/phabricator.py Thu Apr 16 19:05:25 2020 -0400 @@ -1307,6 +1307,26 @@ if any(c for c in ctxs if c.obsolete()): raise error.Abort(_(b"obsolete commits cannot be posted for review")) + # Ensure the local commits are an unbroken range. The semantics of the + # --fold option implies this, and the auto restacking of orphans requires + # it. Otherwise A+C in A->B->C will cause B to be orphaned, and C' to + # get A' as a parent. + def _fail_nonlinear_revs(revs, skiprev, revtype): + badnodes = [repo[r].node() for r in revs if r != skiprev] + raise error.Abort( + _(b"cannot phabsend multiple %s revisions: %s") + % (revtype, scmutil.nodesummaries(repo, badnodes)), + hint=_(b"the revisions must form a linear chain"), + ) + + heads = repo.revs(b'heads(%ld)', revs) + if len(heads) > 1: + _fail_nonlinear_revs(heads, heads.max(), b"head") + + roots = repo.revs(b'roots(%ld)', revs) + if len(roots) > 1: + _fail_nonlinear_revs(roots, roots.min(), b"root") + fold = opts.get(b'fold') if fold: if len(revs) == 1: @@ -1322,13 +1342,6 @@ if not opts.get(b"amend"): raise error.Abort(_(b"cannot fold with --no-amend")) - # Ensure the local commits are an unbroken range - revrange = repo.revs(b'(first(%ld)::last(%ld))', revs, revs) - if any(r for r in revs if r not in revrange) or any( - r for r in revrange if r not in revs - ): - raise error.Abort(_(b"cannot fold non-linear revisions")) - # It might be possible to bucketize the revisions by the DREV value, and # iterate over those groups when posting, and then again when amending. # But for simplicity, require all selected revisions to be for the same
--- a/tests/test-phabricator.t Fri Apr 24 12:37:43 2020 -0700 +++ b/tests/test-phabricator.t Thu Apr 16 19:05:25 2020 -0400 @@ -589,6 +589,13 @@ applying patch from D7917 applying patch from D7918 +Phabsend requires a linear range of commits + + $ hg phabsend -r 0+2+3 + abort: cannot phabsend multiple head revisions: c44b38f24a45 + (the revisions must form a linear chain) + [255] + Validate arguments with --fold $ hg phabsend --fold -r 1 @@ -597,9 +604,6 @@ $ hg phabsend --fold --no-amend -r 1:: abort: cannot fold with --no-amend [255] - $ hg phabsend --fold -r 0+3 - abort: cannot fold non-linear revisions - [255] $ hg phabsend --fold -r 1:: abort: cannot fold revisions with different DREV values [255]