From patchwork Mon Oct 14 22:52:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: D7101: fix: match patterns relative to root From: phabricator X-Patchwork-Id: 42340 Message-Id: To: Phabricator Cc: mercurial-devel@mercurial-scm.org Date: Mon, 14 Oct 2019 22:52:00 +0000 martinvonz created this revision. Herald added a subscriber: mercurial-devel. Herald added a reviewer: hg-reviewers. REVISION 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. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D7101 AFFECTED FILES hgext/fix.py tests/test-fix.t CHANGE DETAILS To: martinvonz, #hg-reviewers Cc: mercurial-devel diff --git a/tests/test-fix.t b/tests/test-fix.t --- a/tests/test-fix.t +++ b/tests/test-fix.t @@ -1321,7 +1321,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 @@ -140,6 +140,7 @@ context, copies, error, + match as matchmod, mdiff, merge, obsolete, @@ -843,7 +844,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?"""