Page MenuHomePhabricator

fix: let fixer tools inherit hg's cwd so they can look at the working copy
Needs ReviewPublic

Authored by hooper on May 22 2019, 8:00 PM.


Group Reviewers

This lets fixer tools do things like find configuration files, with the caveat
that they'll only see the version of that file in the working copy, regardless
of what revisions are being fixed.

Diff Detail

rHG Mercurial
Lint Skipped
Unit Tests Skipped

Event Timeline

hooper created this revision.May 22 2019, 8:00 PM
durin42 added inline comments.

I wonder if it'd be more generally useful to run the fixer in the repo root than the same pwd as the command invocation. WDYT?

hooper added inline comments.May 23 2019, 9:02 PM

It depends on whether we want to make it easier for tools that want to examine the tree upward from the cwd or tools that want to examine the tree downward from the root. I suspect that "upward" will be more important because of the way some tools use config files that apply to subtrees. For some tools it's weird because reading code to format from stdin is often an afterthought. Either way, for completeness, the root and cwd would both need to be available in either subprocess cwd or the command template. There may also be some room to prefer configs like "cd {root} && mycommand".

durin42 added inline comments.May 24 2019, 9:15 AM

Hm. Is {root} in the templater for the command? Maybe have a sample in the test demonstrating that?

I'm still dubious that cwd is the right thing, simply because it's unpredictable. I could see $(dirname filepath) or repo root as consistent, but cwd feels off to me somehow. I don't feel strongly though, so as long as {root} exists I can get what I need for hg's fixer definitions...

martinvonz added inline comments.

FWIW, I agree that running using cwd-relative path feels wrong.