Patchwork fix: change the default fix pattern (issue6077)

login
register
mail settings
Submitter Jordi Gutiérrez Hermoso
Date Feb. 13, 2019, 10:48 p.m.
Message ID <c56534966c1641a50994.1550098096@chloe>
Download mbox | patch
Permalink /patch/38735/
State Superseded
Headers show

Comments

Jordi Gutiérrez Hermoso - Feb. 13, 2019, 10:48 p.m.
# HG changeset patch
# User Jordi Gutiérrez Hermoso <jordigh@octave.org>
# Date 1550096863 18000
#      Wed Feb 13 17:27:43 2019 -0500
# Node ID c56534966c1641a50994a02c746e5b17cb00aa0e
# 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.

Patch

diff --git a/hgext/fix.py b/hgext/fix.py
--- a/hgext/fix.py
+++ b/hgext/fix.py
@@ -122,7 +122,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 ..