Show More
@@ -132,11 +132,9 b' import subprocess' | |||
|
132 | 132 | from mercurial.i18n import _ |
|
133 | 133 | from mercurial.node import nullrev |
|
134 | 134 | from mercurial.node import wdirrev |
|
135 | from mercurial.pycompat import setattr | |
|
136 | 135 | |
|
137 | 136 | from mercurial.utils import ( |
|
138 | 137 | procutil, |
|
139 | stringutil, | |
|
140 | 138 | ) |
|
141 | 139 | |
|
142 | 140 | from mercurial import ( |
@@ -172,9 +170,9 b' FIXER_ATTRS = {' | |||
|
172 | 170 | b'linerange': None, |
|
173 | 171 | b'pattern': None, |
|
174 | 172 | b'priority': 0, |
|
175 |
b'metadata': |
|
|
176 |
b'skipclean': |
|
|
177 |
b'enabled': |
|
|
173 | b'metadata': False, | |
|
174 | b'skipclean': True, | |
|
175 | b'enabled': True, | |
|
178 | 176 | } |
|
179 | 177 | |
|
180 | 178 | for key, default in FIXER_ATTRS.items(): |
@@ -793,29 +791,27 b' def getfixers(ui):' | |||
|
793 | 791 | """ |
|
794 | 792 | fixers = {} |
|
795 | 793 | for name in fixernames(ui): |
|
796 | fixers[name] = Fixer() | |
|
797 | for key in FIXER_ATTRS: | |
|
798 | setattr( | |
|
799 | fixers[name], | |
|
800 | pycompat.sysstr(b'_' + key), | |
|
801 |
|
|
|
802 | ) | |
|
803 | fixers[name]._priority = int(fixers[name]._priority) | |
|
804 | fixers[name]._metadata = stringutil.parsebool(fixers[name]._metadata) | |
|
805 | fixers[name]._skipclean = stringutil.parsebool(fixers[name]._skipclean) | |
|
806 | fixers[name]._enabled = stringutil.parsebool(fixers[name]._enabled) | |
|
794 | enabled = ui.configbool(b'fix', name + b':enabled') | |
|
795 | command = ui.config(b'fix', name + b':command') | |
|
796 | pattern = ui.config(b'fix', name + b':pattern') | |
|
797 | linerange = ui.config(b'fix', name + b':linerange') | |
|
798 | priority = ui.configint(b'fix', name + b':priority') | |
|
799 | metadata = ui.configbool(b'fix', name + b':metadata') | |
|
800 | skipclean = ui.configbool(b'fix', name + b':skipclean') | |
|
807 | 801 | # Don't use a fixer if it has no pattern configured. It would be |
|
808 | 802 | # dangerous to let it affect all files. It would be pointless to let it |
|
809 | 803 | # affect no files. There is no reasonable subset of files to use as the |
|
810 | 804 | # default. |
|
811 |
if |
|
|
805 | if pattern is None: | |
|
812 | 806 | ui.warn( |
|
813 | 807 | _(b'fixer tool has no pattern configuration: %s\n') % (name,) |
|
814 | 808 | ) |
|
815 | del fixers[name] | |
|
816 | elif not fixers[name]._enabled: | |
|
809 | elif not enabled: | |
|
817 | 810 | ui.debug(b'ignoring disabled fixer tool: %s\n' % (name,)) |
|
818 | del fixers[name] | |
|
811 | else: | |
|
812 | fixers[name] = Fixer( | |
|
813 | command, pattern, linerange, priority, metadata, skipclean | |
|
814 | ) | |
|
819 | 815 | return collections.OrderedDict( |
|
820 | 816 | sorted(fixers.items(), key=lambda item: item[1]._priority, reverse=True) |
|
821 | 817 | ) |
@@ -833,6 +829,16 b' def fixernames(ui):' | |||
|
833 | 829 | class Fixer(object): |
|
834 | 830 | """Wraps the raw config values for a fixer with methods""" |
|
835 | 831 | |
|
832 | def __init__( | |
|
833 | self, command, pattern, linerange, priority, metadata, skipclean | |
|
834 | ): | |
|
835 | self._command = command | |
|
836 | self._pattern = pattern | |
|
837 | self._linerange = linerange | |
|
838 | self._priority = priority | |
|
839 | self._metadata = metadata | |
|
840 | self._skipclean = skipclean | |
|
841 | ||
|
836 | 842 | def affects(self, opts, fixctx, path): |
|
837 | 843 | """Should this fixer run on the file at the given path and context?""" |
|
838 | 844 | return self._pattern is not None and scmutil.match( |
General Comments 0
You need to be logged in to leave comments.
Login now