D5299: phabricator: fallback reading arcanist config files

Kwan (Ian Moody) phabricator at mercurial-scm.org
Sat May 11 13:56:06 EDT 2019

Kwan added inline comments.


> Kwan wrote in phabricator.py:201
> I think you could do
>   url = util.url(conduit_uri)
>   url.path = None
>   url = b'%s' % url
> Also I think you need to check for `phabricator.uri` first, then fall back to `conduit_uri`, see change to phabricator's .arcconfig <https://github.com/phacility/phabricator/commit/f0e6dc122109bcc2c3cade0af04b3f06af2fe50b> and mozilla-central's current one <https://hg.mozilla.org/mozilla-central/file/f7a15eb24f3d/.arcconfig> (and perhaps rename conduit_uri variable appropriately)

Oh, and the `config.get('hosts', {}).get(uri)` would have to use a uri with `.path = b'api/'`

> phabricator.py:193
> +        paths = [
> +            vfsmod.vfs('/etc').join('.arconfig'),
> +            os.path.expanduser('~/.arcrc'),

Typo: should be `arcconfig` (two 'c's).
Also no dot for the "/etc/" one according to the docs

> phabricator.py:217-222
> +        url, token, __ = readarcconfig(repo)
> +        if not url or not token:
> +            raise error.Abort(_(b'unable to read phabricator conduit url and '
> +                                b'token from config %s.%s or from arc config '
> +                                b'files') % (b'phabricator', b'url'))
> +        return url, token

Something I realised with some testing is that this requires both .arcconfig and .arcrc, one can't rely on the repo's .arcconfig for the repo settings while using .hg/hgrc for the auth settings (or use hgrc for phab url with .arcrc for auth).  Maybe it could instead do the following:

  hgrcurl = repo.ui.config(b'phabricator', b'url')
  arcurl, arctoken, __ = readarcconfig(repo)
  url = hgrcurl or arcurl
  if not url:
  res = [etc...]
  hgrctoken = None
  if res:
      hgrctoken = auth.get(b'token')
  token = hgrctoken or arctoken
  if not token:

That way any mix of settings in hgrc or .arcconfig/.arcrc would work, with hgrc having precedence.

  rHG Mercurial


To: philpep, #hg-reviewers
Cc: Kwan, mharbison72, mercurial-devel

More information about the Mercurial-devel mailing list