Mercurial > hg
view tests/test-phabricator.t @ 40176:41263df08109
wireprotov2: change how revisions are specified to changesetdata
Right now, we have a handful of arguments for specifying the revisions
whose data should be returned. Defining how all these arguments
interact when various combinations are present is difficult.
This commit establishes a new, generic mechanism for specifying
revisions. Instead of a hodgepodge of arguments defining things, we
have a list of dicts that specify revision selectors. The final set
of revisions is a union of all these selectors.
We implement support for specifying revisions based on:
* An explicit list of changeset revisions
* An explicit list of changeset revisions plus ancestry depth
* A DAG range between changeset roots and heads
If you squint hard enough, this problem has already been solved by
revsets. But I'm reluctant to expose revsets to the wire protocol
because that would require servers to implement a revset parser.
Plus there are security and performance implications: the set
of revision selectors needs to be narrowly and specifically tailored
for what is appropriate to be executing on a server. Perhaps there
would be a way for us to express the "parse tree" of a revset
query, for example. I'm not sure. We can explore this space another
time. For now, the new mechanism should bring sufficient flexibility
while remaining relatively simple.
The selector "types" are prefixed with "changeset" because I plan
to add manifest and file-flavored selectors as well. This will enable
us to e.g. select file revisions based on a range of changeset
revisions.
Differential Revision: https://phab.mercurial-scm.org/D4979
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Mon, 08 Oct 2018 18:17:12 -0700 |
parents | 4057e38bba76 |
children | d7d3164e6a31 |
line wrap: on
line source
#require vcr $ cat >> $HGRCPATH <<EOF > [extensions] > phabricator = > EOF $ hg init repo $ cd repo $ cat >> .hg/hgrc <<EOF > [phabricator] > url = https://phab.mercurial-scm.org/ > callsign = HG > > [auth] > hgphab.schemes = https > hgphab.prefix = phab.mercurial-scm.org > # When working on the extension and making phabricator interaction > # changes, edit this to be a real phabricator token. When done, edit > # it back, and make sure to also edit your VCR transcripts to match > # whatever value you put here. > hgphab.phabtoken = cli-hahayouwish > EOF $ VCR="$TESTDIR/phabricator" Error is handled reasonably. We override the phabtoken here so that when you're developing changes to phabricator.py you can edit the above config and have a real token in the test but not have to edit this test. $ hg phabread --config auth.hgphab.phabtoken=cli-notavalidtoken \ > --test-vcr "$VCR/phabread-conduit-error.json" D4480 | head abort: Conduit Error (ERR-INVALID-AUTH): API token "cli-notavalidtoken" has the wrong length. API tokens should be 32 characters long. Basic phabread: $ hg phabread --test-vcr "$VCR/phabread-4480.json" D4480 | head # HG changeset patch exchangev2: start to implement pull with wire protocol v2 Wire protocol version 2 will take a substantially different approach to exchange than version 1 (at least as far as pulling is concerned). This commit establishes a new exchangev2 module for holding code related to exchange using wire protocol v2. I could have added things to the existing exchange module. But it is already phabupdate with an accept: $ hg phabupdate --accept D4564 \ > -m 'I think I like where this is headed. Will read rest of series later.'\ > --test-vcr "$VCR/accept-4564.json" Create a differential diff: $ echo alpha > alpha $ hg ci --addremove -m 'create alpha for phabricator test' adding alpha $ hg phabsend -r . --test-vcr "$VCR/phabsend-create-alpha.json" D4596 - created - 5206a4fa1e6c: create alpha for phabricator test saved backup bundle to $TESTTMP/repo/.hg/strip-backup/5206a4fa1e6c-dec9e777-phabsend.hg $ echo more >> alpha $ HGEDITOR=true hg ci --amend saved backup bundle to $TESTTMP/repo/.hg/strip-backup/d8f232f7d799-c573510a-amend.hg $ echo beta > beta $ hg ci --addremove -m 'create beta for phabricator test' adding beta $ hg phabsend -r ".^::" --test-vcr "$VCR/phabsend-update-alpha-create-beta.json" D4596 - updated - f70265671c65: create alpha for phabricator test D4597 - created - 1a5640df7bbf: create beta for phabricator test saved backup bundle to $TESTTMP/repo/.hg/strip-backup/1a5640df7bbf-6daf3e6e-phabsend.hg Template keywords $ hg log -T'{rev} {phabreview|json}\n' 1 {"id": "D4597", "url": "https://phab.mercurial-scm.org/D4597"} 0 {"id": "D4596", "url": "https://phab.mercurial-scm.org/D4596"} $ hg log -T'{rev} {phabreview.url} {phabreview.id}\n' 1 https://phab.mercurial-scm.org/D4597 D4597 0 https://phab.mercurial-scm.org/D4596 D4596 $ cd ..