This is an archive of the discontinued Mercurial Phabricator instance.

fix: match patterns relative to root
ClosedPublic

Authored by martinvonz on Oct 14 2019, 6:51 PM.

Details

Summary

I was surprised fixer patterns (used to determine which fixers to run)
are applies to the parent directory, not the repo root
directory. Danny Hooper (the author of the extension) seemed to agree
that it's better to apply them to the repo root, so that's what this
patch does.

Diff Detail

Repository
rHG Mercurial
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

martinvonz created this revision.Oct 14 2019, 6:51 PM
mharbison72 requested changes to this revision.Oct 14 2019, 9:18 PM
mharbison72 added a subscriber: mharbison72.

The part of the help text that documents :pattern and points to hg help patterns should probably explicitly state that they are all relative to repo root, regardless of what the latter says.

I can’t tell from my phone, but should the matcher in getworkqueue and the status call in pathstofix also be adjusted? (Not sure if there are others.)

This revision now requires changes to proceed.Oct 14 2019, 9:18 PM

The part of the help text that documents :pattern and points to hg help patterns should probably explicitly state that they are all relative to repo root, regardless of what the latter says.

Good point! Done.

I can’t tell from my phone, but should the matcher in getworkqueue and the status call in pathstofix also be adjusted? (Not sure if there are others.)

No, that matcher (it's the same instance that's passed between them) is created based on pats and opts, i.e. command line arguments.

mharbison72 accepted this revision.Oct 15 2019, 12:10 AM

I can’t tell from my phone, but should the matcher in getworkqueue and the status call in pathstofix also be adjusted? (Not sure if there are others.)

No, that matcher (it's the same instance that's passed between them) is created based on pats and opts, i.e. command line arguments.

Oh, OK. That makes sense.

pulkit accepted this revision.Oct 15 2019, 8:12 AM
This revision is now accepted and ready to land.Oct 15 2019, 8:12 AM

Amended the following in flight:

diff --git a/tests/test-fix.t b/tests/test-fix.t
--- a/tests/test-fix.t
+++ b/tests/test-fix.t
@@ -157,8 +157,10 @@ Help text for fix.
   :skipclean suboption to false.
   
   The :pattern suboption determines which files will be passed through each
-  configured tool. See 'hg help patterns' for possible values. If there are file
-  arguments to 'hg fix', the intersection of these patterns is used.
+  configured tool. See 'hg help patterns' for possible values. However, all
+  patterns are relative to the repo root, even if that text says they are
+  relative to the current working directory. If there are file arguments to 'hg
+  fix', the intersection of these patterns is used.
   
   There is also a configurable limit for the maximum size of file that will be
   processed by 'hg fix':
This revision was automatically updated to reflect the committed changes.