D6975: fix: add :enabled sub-config for fixer tools

hooper (Danny Hooper) phabricator at mercurial-scm.org
Sat Oct 5 14:29:59 EDT 2019


Closed by commit rHG808a57a08470: fix: add :enabled sub-config for fixer tools (authored by hooper).
This revision was automatically updated to reflect the committed changes.
This revision was not accepted when it landed; it landed in state "Needs Review".

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6975?vs=16824&id=16852

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

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

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

CHANGE DETAILS

diff --git a/tests/test-fix.t b/tests/test-fix.t
--- a/tests/test-fix.t
+++ b/tests/test-fix.t
@@ -1341,6 +1341,22 @@
 
   $ cd ..
 
+Tools can be disabled. Disabled tools do nothing but print a debug message.
+
+  $ hg init disabled
+  $ cd disabled
+
+  $ printf "foo\n" > foo
+  $ hg add -q
+  $ hg fix --debug --working-dir --config "fix.disabled:command=echo fixed" \
+  >                              --config "fix.disabled:pattern=foo" \
+  >                              --config "fix.disabled:enabled=false"
+  ignoring disabled fixer tool: disabled
+  $ cat foo
+  foo
+
+  $ cd ..
+
 Test that we can configure a fixer to affect all files regardless of the cwd.
 The way we invoke matching must not prohibit this.
 
diff --git a/hgext/fix.py b/hgext/fix.py
--- a/hgext/fix.py
+++ b/hgext/fix.py
@@ -173,6 +173,7 @@
     'priority': 0,
     'metadata': 'false',
     'skipclean': 'true',
+    'enabled': 'true',
 }
 
 for key, default in FIXER_ATTRS.items():
@@ -726,6 +727,7 @@
         fixers[name]._priority = int(fixers[name]._priority)
         fixers[name]._metadata = stringutil.parsebool(fixers[name]._metadata)
         fixers[name]._skipclean = stringutil.parsebool(fixers[name]._skipclean)
+        fixers[name]._enabled = stringutil.parsebool(fixers[name]._enabled)
         # Don't use a fixer if it has no pattern configured. It would be
         # dangerous to let it affect all files. It would be pointless to let it
         # affect no files. There is no reasonable subset of files to use as the
@@ -734,6 +736,9 @@
             ui.warn(
                 _('fixer tool has no pattern configuration: %s\n') % (name,))
             del fixers[name]
+        elif not fixers[name]._enabled:
+            ui.debug('ignoring disabled fixer tool: %s\n' % (name,))
+            del fixers[name]
     return collections.OrderedDict(
         sorted(fixers.items(), key=lambda item: item[1]._priority,
                reverse=True))



To: hooper, #hg-reviewers
Cc: mercurial-devel


More information about the Mercurial-devel mailing list