[PATCH V2] fix: change the default fix pattern (issue6077)
Jordi Gutiérrez Hermoso
jordigh at octave.org
Wed Feb 13 22:54:18 UTC 2019
# HG changeset patch
# User Jordi Gutiérrez Hermoso <jordigh at octave.org>
# Date 1550096863 18000
# Wed Feb 13 17:27:43 2019 -0500
# Node ID d8ba3b6466b220a5e04d07a5eccd3c1d45a2f501
# Parent 5d383d9636d0b81b416398913b32b8c715e98db5
fix: change the default fix pattern (issue6077)
The matchutils functions don't know what to do with an empty pattern.
When a fixer doesn't have a pattern at all, a default of None will
make match functions unhappy and stack trace.
Change this default instead to a pattern that matches everything.
diff --git a/hgext/fix.py b/hgext/fix.py
--- a/hgext/fix.py
+++ b/hgext/fix.py
@@ -38,7 +38,8 @@ substituted into the command::
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.
+arguments to :hg:`fix`, the intersection of these patterns is used. If no patterns
+are specified, the default is to apply the tool to all files.
There is also a configurable limit for the maximum size of file that will be
processed by :hg:`fix`::
@@ -122,7 +123,7 @@ FIXER_ATTRS = {
'command': None,
'linerange': None,
'fileset': None,
- 'pattern': None,
+ 'pattern': '.',
'priority': 0,
}
diff --git a/tests/test-fix.t b/tests/test-fix.t
--- a/tests/test-fix.t
+++ b/tests/test-fix.t
@@ -288,17 +288,28 @@ we ignore a file that doesn't match any
$ cd ..
+A config file missing a :pattern suboption to match issue6077
+
+ $ REMOVE_WS=$TESTTMP/remove-trailing-whitespace.hgrc
+ $ cat >> $REMOVE_WS <<EOF
+ > [extensions]
+ > fix =
+ > [fix]
+ > trailing-whitespace:command = sed
+ > trailing-whitespace:linerange = -e '{first},{last}s/\s\+$//'
+ > EOF
+
Fixing the working directory should still work if there are no revisions.
$ hg init norevisions
$ cd norevisions
- $ printf "something\n" > something.whole
+ $ printf "something \n" > something.whole
$ hg add
adding something.whole
- $ hg fix --working-dir
+ $ HGRCPATH=$REMOVE_WS hg fix --working-dir
$ cat something.whole
- SOMETHING
+ something
$ cd ..
More information about the Mercurial-devel
mailing list