fix: rename :fileset subconfig to :pattern
This name was always inaccurate, since the config accepts any pattern.
Hopefully so few people use this right now that it won't matter, but there will
now be a warning if the old config name is used.
Differential Revision: https://phab.mercurial-scm.org/D5226
--- a/hgext/fix.py Wed Oct 31 13:11:51 2018 -0700
+++ b/hgext/fix.py Mon Nov 05 16:05:45 2018 -0800
@@ -15,7 +15,7 @@
[fix]
clang-format:command=clang-format --assume-filename={rootpath}
clang-format:linerange=--lines={first}:{last}
- clang-format:fileset=set:**.cpp or **.hpp
+ clang-format:pattern=set:**.cpp or **.hpp
The :command suboption forms the first part of the shell command that will be
used to fix a file. The content of the file is passed on standard input, and the
@@ -36,9 +36,9 @@
{first} The 1-based line number of the first line in the modified range
{last} The 1-based line number of the last line in the modified range
-The :fileset suboption determines which files will be passed through each
-configured tool. See :hg:`help fileset` for possible values. If there are file
-arguments to :hg:`fix`, the intersection of these filesets is used.
+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.
There is also a configurable limit for the maximum size of file that will be
processed by :hg:`fix`::
@@ -100,7 +100,7 @@
configitem = registrar.configitem(configtable)
# Register the suboptions allowed for each configured fixer.
-FIXER_ATTRS = ('command', 'linerange', 'fileset')
+FIXER_ATTRS = ('command', 'linerange', 'fileset', 'pattern')
for key in FIXER_ATTRS:
configitem('fix', '.*(:%s)?' % key, default=None, generic=True)
@@ -606,6 +606,10 @@
for name in fixernames(ui):
result[name] = Fixer()
attrs = ui.configsuboptions('fix', name)[1]
+ if 'fileset' in attrs and 'pattern' not in attrs:
+ ui.warn(_('the fix.tool:fileset config name is deprecated; '
+ 'please rename it to fix.tool:pattern\n'))
+ attrs['pattern'] = attrs['fileset']
for key in FIXER_ATTRS:
setattr(result[name], pycompat.sysstr('_' + key),
attrs.get(key, ''))
@@ -624,7 +628,7 @@
def affects(self, opts, fixctx, path):
"""Should this fixer run on the file at the given path and context?"""
- return scmutil.match(fixctx, [self._fileset], opts)(path)
+ return scmutil.match(fixctx, [self._pattern], opts)(path)
def command(self, ui, path, rangesfn):
"""A shell command to use to invoke this fixer on the given file/lines
--- a/tests/test-fix-clang-format.t Wed Oct 31 13:11:51 2018 -0700
+++ b/tests/test-fix-clang-format.t Mon Nov 05 16:05:45 2018 -0800
@@ -11,7 +11,7 @@
> [fix]
> clang-format:command=clang-format --style=Google --assume-filename={rootpath}
> clang-format:linerange=--lines={first}:{last}
- > clang-format:fileset=set:**.cpp or **.hpp
+ > clang-format:pattern=set:**.cpp or **.hpp
> EOF
$ hg init repo
--- a/tests/test-fix-topology.t Wed Oct 31 13:11:51 2018 -0700
+++ b/tests/test-fix-topology.t Mon Nov 05 16:05:45 2018 -0800
@@ -23,7 +23,7 @@
> fix =
> [fix]
> uppercase-whole-file:command="$PYTHON" $UPPERCASEPY
- > uppercase-whole-file:fileset=set:**
+ > uppercase-whole-file:pattern=set:**
> EOF
This tests the only behavior that should really be affected by obsolescence, so
--- a/tests/test-fix.t Wed Oct 31 13:11:51 2018 -0700
+++ b/tests/test-fix.t Mon Nov 05 16:05:45 2018 -0800
@@ -66,10 +66,10 @@
> evolution.allowunstable=True
> [fix]
> uppercase-whole-file:command="$PYTHON" $UPPERCASEPY all
- > uppercase-whole-file:fileset=set:**.whole
+ > uppercase-whole-file:pattern=set:**.whole
> uppercase-changed-lines:command="$PYTHON" $UPPERCASEPY
> uppercase-changed-lines:linerange={first}-{last}
- > uppercase-changed-lines:fileset=set:**.changed
+ > uppercase-changed-lines:pattern=set:**.changed
> EOF
Help text for fix.
@@ -126,7 +126,7 @@
[fix]
clang-format:command=clang-format --assume-filename={rootpath}
clang-format:linerange=--lines={first}:{last}
- clang-format:fileset=set:**.cpp or **.hpp
+ clang-format:pattern=set:**.cpp or **.hpp
The :command suboption forms the first part of the shell command that will be
used to fix a file. The content of the file is passed on standard input, and
@@ -147,9 +147,9 @@
{first} The 1-based line number of the first line in the modified range
{last} The 1-based line number of the last line in the modified range
- The :fileset suboption determines which files will be passed through each
- configured tool. See 'hg help fileset' for possible values. If there are file
- arguments to 'hg fix', the intersection of these filesets is used.
+ 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.
There is also a configurable limit for the maximum size of file that will be
processed by 'hg fix':
@@ -371,7 +371,7 @@
$ hg --config "fix.fail:command=echo" \
> --config "fix.fail:linerange={first}:{last}" \
- > --config "fix.fail:fileset=foo.txt" \
+ > --config "fix.fail:pattern=foo.txt" \
> fix --working-dir
$ cat foo.txt
1:1 4:6 8:8
@@ -534,7 +534,7 @@
> exit 0 # success despite the stderr output
> EOF
$ hg --config "fix.work:command=sh $TESTTMP/work.sh {rootpath}" \
- > --config "fix.work:fileset=hello.txt" \
+ > --config "fix.work:pattern=hello.txt" \
> fix --working-dir
[wdir] work: hello.txt: some
[wdir] work: error that didn't stop the tool
@@ -551,7 +551,7 @@
> exit 42 # success despite the stdout output
> EOF
$ hg --config "fix.fail:command=sh $TESTTMP/fail.sh {rootpath}" \
- > --config "fix.fail:fileset=hello.txt" \
+ > --config "fix.fail:pattern=hello.txt" \
> --config "fix.failure=abort" \
> fix --working-dir
[wdir] fail: hello.txt: some
@@ -565,7 +565,7 @@
foo
$ hg --config "fix.fail:command=sh $TESTTMP/fail.sh {rootpath}" \
- > --config "fix.fail:fileset=hello.txt" \
+ > --config "fix.fail:pattern=hello.txt" \
> fix --working-dir
[wdir] fail: hello.txt: some
[wdir] fail: error that did stop the tool
@@ -575,7 +575,7 @@
FOO
$ hg --config "fix.fail:command=exit 42" \
- > --config "fix.fail:fileset=hello.txt" \
+ > --config "fix.fail:pattern=hello.txt" \
> fix --working-dir
[wdir] fail: exited with status 42
@@ -1027,7 +1027,7 @@
adding foo/bar
$ hg --config "fix.fail:command=printf '%s\n' '{rootpath}' '{basename}'" \
> --config "fix.fail:linerange='{first}' '{last}'" \
- > --config "fix.fail:fileset=foo/bar" \
+ > --config "fix.fail:pattern=foo/bar" \
> fix --working-dir
$ cat foo/bar
foo/bar
@@ -1105,3 +1105,25 @@
FOO2
$ cd ..
+
+The :fileset subconfig was a misnomer, so we renamed it to :pattern. We will
+still accept :fileset by itself as if it were :pattern, but this will issue a
+warning.
+
+ $ hg init filesetispattern
+ $ cd filesetispattern
+
+ $ printf "foo\n" > foo.whole
+ $ printf "first\nsecond\n" > bar.txt
+ $ hg add -q
+ $ hg fix -w --config fix.sometool:fileset=bar.txt \
+ > --config fix.sometool:command=tac
+ the fix.tool:fileset config name is deprecated; please rename it to fix.tool:pattern
+
+ $ cat foo.whole
+ FOO
+ $ cat bar.txt
+ second
+ first
+
+ $ cd ..