Page MenuHomePhabricator

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

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

Details

Summary

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

Repository
rHG Mercurial
Lint
Lint Skipped
Unit
Unit Tests Skipped

Event Timeline

hooper created this revision.May 22 2019, 8:00 PM
durin42 added inline comments.
hgext/fix.py
106

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
hgext/fix.py
106

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
hgext/fix.py
106

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.
hgext/fix.py
106

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

I still think we should fix the cwd for fixers, but it seems Martin and I agree that repo-root is more consistent. Would you be willing to reroll with repo-root instead of cwd?

hooper updated this revision to Diff 16083.Jul 26 2019, 1:57 PM

I still think we should fix the cwd for fixers, but it seems Martin and I agree that repo-root is more consistent. Would you be willing to reroll with repo-root instead of cwd?

Done.

Queued with updated log message. Thanks!

This revision was not accepted when it landed; it landed in state Needs Review.
This revision was automatically updated to reflect the committed changes.