Mercurial > hg
view tests/test-phabricator.t @ 44127:59b3fe1e2021
phabricator: use .arcconfig for the callsign if not set locally (issue6243)
This makes things easier for people working with more than one repository
because this file can be committed to each repository. The bug report asks to
read <repo>/.arcrc, but AFAICT, that file lives in ~/ and holds the credentials.
And we already track an .arcconfig file. Any callsign set globally is still
used if that is all that is present, but .arcconfig will override it if
available. The idea behind letting the local hgrc override .arcconfig is that
the developer may need to do testing against another server, and not dirty the
working directory.
Originally I was going to just try to read the callsign in `getrepophid()` if it
wasn't present in the hg config. That works fine, but I think it also makes
sense to read the URL from this file too. That would have worked less well
because `readurltoken()` doesn't have access to the repo object to know where to
find the file. Supplimenting the config mechanism is less magical because it
reports the source and value of the properties used, and it doesn't need to read
the file twice.
Invalid hgrc files generally cause the program to abort. I only flagged it as a
warning here because it's not our config file, not crucial to the whole program
operating, and really shouldn't be corrupt in the typical case where it is
checked into the repo.
Differential Revision: https://phab.mercurial-scm.org/D7934
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Fri, 17 Jan 2020 14:21:40 -0500 |
parents | a5e3f38407cb |
children | ff396501e841 |
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. The VCR transcripts will be auto-sanitised to replace your real > # token with this value. > 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 # Date 1536771503 0 # Parent a5de21c9e3703f8e8eb064bd7d893ff2f703c66a 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 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" abort: Conduit Error (ERR-CONDUIT-CORE): Validation errors: - You can not accept this revision because it has already been closed. Only open revisions can be accepted. [255] $ hg phabupdate --accept D7913 -m 'LGTM' --test-vcr "$VCR/accept-7913.json" Create a differential diff: $ HGENCODING=utf-8; export HGENCODING $ echo alpha > alpha $ hg ci --addremove -m 'create alpha for phabricator test €' adding alpha $ hg phabsend -r . --test-vcr "$VCR/phabsend-create-alpha.json" D7915 - created - d386117f30e6: create alpha for phabricator test \xe2\x82\xac (esc) saved backup bundle to $TESTTMP/repo/.hg/strip-backup/d386117f30e6-24ffe649-phabsend.hg $ echo more >> alpha $ HGEDITOR=true hg ci --amend saved backup bundle to $TESTTMP/repo/.hg/strip-backup/347bf67801e5-3bf313e4-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" D7915 - updated - c44b38f24a45: create alpha for phabricator test \xe2\x82\xac (esc) D7916 - created - 9e6901f21d5b: create beta for phabricator test saved backup bundle to $TESTTMP/repo/.hg/strip-backup/9e6901f21d5b-1fcd4f0e-phabsend.hg $ unset HGENCODING The amend won't explode after posting a public commit. The local tag is left behind to identify it. $ echo 'public change' > beta $ hg ci -m 'create public change for phabricator testing' $ hg phase --public . $ echo 'draft change' > alpha $ hg ci -m 'create draft change for phabricator testing' $ hg phabsend --amend -r '.^::' --test-vcr "$VCR/phabsend-create-public.json" D7917 - created - 7b4185ab5d16: create public change for phabricator testing D7918 - created - 251c1c333fc6: create draft change for phabricator testing warning: not updating public commit 2:7b4185ab5d16 saved backup bundle to $TESTTMP/repo/.hg/strip-backup/251c1c333fc6-41cb7c3b-phabsend.hg $ hg tags -v tip 3:3244dc4a3334 D7917 2:7b4185ab5d16 local $ hg debugcallconduit user.search --test-vcr "$VCR/phab-conduit.json" <<EOF > { > "constraints": { > "isBot": true > } > } > EOF { "cursor": { "after": null, "before": null, "limit": 100, "order": null }, "data": [], "maps": {}, "query": { "queryKey": null } } Template keywords $ hg log -T'{rev} {phabreview|json}\n' 3 {"id": "D7918", "url": "https://phab.mercurial-scm.org/D7918"} 2 {"id": "D7917", "url": "https://phab.mercurial-scm.org/D7917"} 1 {"id": "D7916", "url": "https://phab.mercurial-scm.org/D7916"} 0 {"id": "D7915", "url": "https://phab.mercurial-scm.org/D7915"} $ hg log -T'{rev} {if(phabreview, "{phabreview.url} {phabreview.id}")}\n' 3 https://phab.mercurial-scm.org/D7918 D7918 2 https://phab.mercurial-scm.org/D7917 D7917 1 https://phab.mercurial-scm.org/D7916 D7916 0 https://phab.mercurial-scm.org/D7915 D7915 Commenting when phabsending: $ echo comment > comment $ hg ci --addremove -m "create comment for phabricator test" adding comment $ hg phabsend -r . -m "For default branch" --test-vcr "$VCR/phabsend-comment-created.json" D7919 - created - d5dddca9023d: create comment for phabricator test saved backup bundle to $TESTTMP/repo/.hg/strip-backup/d5dddca9023d-adf673ba-phabsend.hg $ echo comment2 >> comment $ hg ci --amend saved backup bundle to $TESTTMP/repo/.hg/strip-backup/f7db812bbe1d-8fcded77-amend.hg $ hg phabsend -r . -m "Address review comments" --test-vcr "$VCR/phabsend-comment-updated.json" D7919 - updated - 1849d7828727: create comment for phabricator test Phabsending a skipped commit: $ hg phabsend --no-amend -r . --test-vcr "$VCR/phabsend-skipped.json" D7919 - skipped - 1849d7828727: create comment for phabricator test Phabreading a DREV with a local:commits time as a string: $ hg phabread --test-vcr "$VCR/phabread-str-time.json" D1285 # HG changeset patch # User Pulkit Goyal <7895pulkit@gmail.com> # Date 1509404054 -19800 # Node ID 44fc1c1f1774a76423b9c732af6938435099bcc5 # Parent 8feef8ef8389a3b544e0a74624f1efc3a8d85d35 repoview: add a new attribute _visibilityexceptions and related API Currently we don't have a defined way in core to make some hidden revisions visible in filtered repo. Extensions to achieve the purpose of unhiding some hidden commits, wrap repoview.pinnedrevs() function. To make the above task simple and have well defined API, this patch adds a new attribute '_visibilityexceptions' to repoview class which will contains the hidden revs which should be exception. This will allow to set different exceptions for different repoview objects backed by the same unfiltered repo. This patch also adds API to add revs to the attribute set and get them. Thanks to Jun for suggesting the use of repoview class instead of localrepo. Differential Revision: https://phab.mercurial-scm.org/D1285 diff --git a/mercurial/repoview.py b/mercurial/repoview.py --- a/mercurial/repoview.py +++ b/mercurial/repoview.py @@ * @@ (glob) subclasses of `localrepo`. Eg: `bundlerepo` or `statichttprepo`. """ + # hidden revs which should be visible + _visibilityexceptions = set() + def __init__(self, repo, filtername): object.__setattr__(self, r'_unfilteredrepo', repo) object.__setattr__(self, r'filtername', filtername) @@ -231,6 +234,14 @@ return self return self.unfiltered().filtered(name) + def addvisibilityexceptions(self, revs): + """adds hidden revs which should be visible to set of exceptions""" + self._visibilityexceptions.update(revs) + + def getvisibilityexceptions(self): + """returns the set of hidden revs which should be visible""" + return self._visibilityexceptions + # everything access are forwarded to the proxied repo def __getattr__(self, attr): return getattr(self._unfilteredrepo, attr) diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py --- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -570,6 +570,14 @@ def close(self): self._writecaches() + def addvisibilityexceptions(self, exceptions): + # should be called on a filtered repository + pass + + def getvisibilityexceptions(self): + # should be called on a filtered repository + return set() + def _loadextensions(self): extensions.loadall(self.ui) A bad .arcconfig doesn't error out $ echo 'garbage' > .arcconfig $ hg config phabricator --debug invalid JSON in $TESTTMP/repo/.arcconfig read config from: */.hgrc (glob) $TESTTMP/repo/.hg/hgrc:*: phabricator.url=https://phab.mercurial-scm.org/ (glob) $TESTTMP/repo/.hg/hgrc:*: phabricator.callsign=HG (glob) The .arcconfig content overrides global config $ cat >> $HGRCPATH << EOF > [phabricator] > url = global > callsign = global > EOF $ cp $TESTDIR/../.arcconfig . $ mv .hg/hgrc .hg/hgrc.bak $ hg config phabricator --debug read config from: */.hgrc (glob) */.hgrc:*: phabricator.url=global (glob) $TESTTMP/repo/.arcconfig: phabricator.callsign=HG But it doesn't override local config $ cat >> .hg/hgrc << EOF > [phabricator] > url = local > callsign = local > EOF $ hg config phabricator --debug read config from: */.hgrc (glob) $TESTTMP/repo/.hg/hgrc:*: phabricator.url=local (glob) $TESTTMP/repo/.hg/hgrc:*: phabricator.callsign=local (glob) $ mv .hg/hgrc.bak .hg/hgrc $ cd ..