Patchwork D7101: fix: match patterns relative to root

login
register
mail settings
Submitter phabricator
Date Oct. 15, 2019, 12:58 p.m.
Message ID <5725e35988545aa61b07dc07ad5daa6e@localhost.localdomain>
Download mbox | patch
Permalink /patch/42352/
State Not Applicable
Headers show

Comments

phabricator - Oct. 15, 2019, 12:58 p.m.
Closed by commit rHGf02d3c0eed18: fix: match patterns relative to root (authored by martinvonz).
This revision was automatically updated to reflect the committed changes.

CHANGED PRIOR TO COMMIT
  https://phab.mercurial-scm.org/D7101?vs=17164&id=17169#toc

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D7101?vs=17164&id=17169

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D7101/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D7101

AFFECTED FILES
  hgext/fix.py
  tests/test-fix.t

CHANGE DETAILS




To: martinvonz, #hg-reviewers, mharbison72, pulkit
Cc: mharbison72, mercurial-devel

Patch

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 @@ 
   :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':
@@ -1321,7 +1323,7 @@ 
   $ echo modified > bar
   $ hg fix -w bar
   $ cat bar
-  modified
+  $TESTTMP/subprocesscwd
 
   $ cd ../..
 
diff --git a/hgext/fix.py b/hgext/fix.py
--- a/hgext/fix.py
+++ b/hgext/fix.py
@@ -46,8 +46,10 @@ 
 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`::
@@ -140,6 +142,7 @@ 
     context,
     copies,
     error,
+    match as matchmod,
     mdiff,
     merge,
     obsolete,
@@ -843,7 +846,11 @@ 
 
     def affects(self, opts, fixctx, path):
         """Should this fixer run on the file at the given path and context?"""
-        return scmutil.match(fixctx, [self._pattern], opts)(path)
+        repo = fixctx.repo()
+        matcher = matchmod.match(
+            repo.root, repo.root, [self._pattern], ctx=fixctx
+        )
+        return matcher(path)
 
     def shouldoutputmetadata(self):
         """Should the stdout of this fixer start with JSON and a null byte?"""