Closed by commit rHG59b3fe1e2021: phabricator: use .arcconfig for the callsign if not set locally (issue6243) (authored by mharbison72). This revision was automatically updated to reflect the committed changes. This revision was not accepted when it landed; it landed in state "Needs Review".
REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D7934?vs=19438&id=19485 CHANGES SINCE LAST ACTION https://phab.mercurial-scm.org/D7934/new/ REVISION DETAIL https://phab.mercurial-scm.org/D7934 AFFECTED FILES hgext/phabricator.py tests/test-phabricator.t CHANGE DETAILS diff --git a/tests/test-phabricator.t b/tests/test-phabricator.t --- a/tests/test-phabricator.t +++ b/tests/test-phabricator.t @@ -210,5 +210,37 @@ 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 .. diff --git a/hgext/phabricator.py b/hgext/phabricator.py --- a/hgext/phabricator.py +++ b/hgext/phabricator.py @@ -66,6 +66,7 @@ exthelper, graphmod, httpconnection as httpconnectionmod, + localrepo, logcmdutil, match, mdiff, @@ -101,6 +102,7 @@ command = eh.command configtable = eh.configtable templatekeyword = eh.templatekeyword +uisetup = eh.finaluisetup # developer config: phabricator.batchsize eh.configitem( @@ -152,6 +154,39 @@ ] +@eh.wrapfunction(localrepo, "loadhgrc") +def _loadhgrc(orig, ui, wdirvfs, hgvfs, requirements): + """Load ``.arcconfig`` content into a ui instance on repository open. + """ + result = False + arcconfig = {} + + try: + # json.loads only accepts bytes from 3.6+ + rawparams = encoding.unifromlocal(wdirvfs.read(b".arcconfig")) + # json.loads only returns unicode strings + arcconfig = pycompat.rapply( + lambda x: encoding.unitolocal(x) + if isinstance(x, pycompat.unicode) + else x, + pycompat.json_loads(rawparams), + ) + + result = True + except ValueError: + ui.warn(_(b"invalid JSON in %s\n") % wdirvfs.join(b".arcconfig")) + except IOError: + pass + + if b"repository.callsign" in arcconfig: + ui.applyconfig( + {(b"phabricator", b"callsign"): arcconfig[b"repository.callsign"]}, + source=wdirvfs.join(b".arcconfig"), + ) + + return orig(ui, wdirvfs, hgvfs, requirements) or result # Load .hg/hgrc + + def vcrcommand(name, flags, spec, helpcategory=None, optionalrepo=False): fullflags = flags + _VCR_FLAGS To: mharbison72, #hg-reviewers Cc: Kwan, mercurial-devel _______________________________________________ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel