Page MenuHomePhabricator

[Wilds] When reading ".arcrc" files, modernize the data we read in-process if they're in an older format on disk
ClosedPublic

Authored by epriestley on Sep 19 2018, 6:07 PM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Apr 25, 3:38 AM
Unknown Object (File)
Wed, Apr 24, 12:42 AM
Unknown Object (File)
Fri, Apr 19, 7:59 PM
Unknown Object (File)
Thu, Apr 18, 8:18 AM
Unknown Object (File)
Thu, Apr 18, 1:37 AM
Unknown Object (File)
Wed, Apr 17, 11:55 PM
Unknown Object (File)
Tue, Apr 16, 7:45 AM
Unknown Object (File)
Sat, Apr 13, 1:01 PM
Subscribers
None

Details

Summary

See T13098. All ".arcconfig" files except "~/.arcrc" have config keys at top level.

"~/.arcrc" previously had "aliases" at top level, and currently has "hosts" at top level. "aliases" became standard configuration. I'd like to make "hosts" standard configuration too -- one reason to do this is to make automation with --config-file easier, so you can shove API tokens in a file somewhere (and not need a home directory). Another reason is just to standardize things.

If we read "~/.arcrc" and see a "config" key, put all those keys at top level and then fill in anything else left over so we end up with ~/.arcrc that effectively looks like other "arcconfig" files. I'd possibly like to rename this file to "arcconfig" at some point, too, but that can happen later.

Test Plan

Ran arc get-config, which barely works, but now read my ~/.arcrc somewhat more successfully.

Diff Detail

Repository
rARC Arcanist
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

Harbormaster returned this revision to the author for changes because remote builds failed.Sep 19 2018, 6:08 PM
Harbormaster failed remote builds in B20862: Diff 47050!

Do we have any other workflows that modify arcconfigs in place? This seems like it could be pretty fragile and state-destroying (in particular, this will totally blow away any commented-out lines in an arcconfig, right?)

Today, arcconfig files are JSON and won't parse if you have comments:

$ arc branch
 Exception 
Unable to parse '.arcconfig' file '/Users/epriestley/dev/core/lib/phabricator/.arcconfig'.
Parse error on line 1 at column 1: Expected one of: 'STRING', '}'
(Run with `--trace` for a full exception trace.)

Rewriting these files could still destroy formatting (if you indent things in a special way, or group keys together with blocks of newlines between them) or (possibly) change key ordering in JSON dictionaries (although I think we'll always retain it, today).

This code also isn't actually touching what's on disk (yet): we just pretend what's on disk is different from what's actually there while reading it, for now.

Later in this series, we do start writing to .arcrc via arc alias (and, somewhat later, via arc set-config). However, these commands have always rewritten ~/.arcrc. Specifically, it is completely rewritten on master by: arc alias, arc set-config, and arc install-certificate.

The "local" config file (usually path/to/project/.git/arc/config or similar) is also rewritten today by arc set-config --local ....

I currently expect to mostly retain these behaviors (so we should be in the same place after these changes as before). However, there's some argument for possibly trying to rewrite other files (/etc/arcconfig, path/to/project/.arcconfig), and/or for providing flags to arc set-config to let you interact with them, e.g. arc set-config --system ... and arc set-config --project .... This doesn't need to happen as part of this phase, though, I think. Some config format stuff is changing, but for now we can transparently read the old versions of things.

epriestley retitled this revision from [Wilds] When reading ".arcrc" files, modernize them if they're in an older format to [Wilds] When reading ".arcrc" files, modernize the data we read in-process if they're in an older format on disk.Sep 20 2018, 12:39 PM

Specifically, it is completely rewritten on master by: arc alias, arc set-config, and arc install-certificate.

Ahhh, I forgot about those flows, and I bet arc install-certificate has almost 100% usage since it's pretty much a required setup task. Sounds good.

This revision is now accepted and ready to land.Sep 20 2018, 5:26 PM