equal
deleted
inserted
replaced
13 formatting fixes to modified lines in C++ code:: |
13 formatting fixes to modified lines in C++ code:: |
14 |
14 |
15 [fix] |
15 [fix] |
16 clang-format:command=clang-format --assume-filename={rootpath} |
16 clang-format:command=clang-format --assume-filename={rootpath} |
17 clang-format:linerange=--lines={first}:{last} |
17 clang-format:linerange=--lines={first}:{last} |
18 clang-format:fileset=set:**.cpp or **.hpp |
18 clang-format:pattern=set:**.cpp or **.hpp |
19 |
19 |
20 The :command suboption forms the first part of the shell command that will be |
20 The :command suboption forms the first part of the shell command that will be |
21 used to fix a file. The content of the file is passed on standard input, and the |
21 used to fix a file. The content of the file is passed on standard input, and the |
22 fixed file content is expected on standard output. Any output on standard error |
22 fixed file content is expected on standard output. Any output on standard error |
23 will be displayed as a warning. If the exit status is not zero, the file will |
23 will be displayed as a warning. If the exit status is not zero, the file will |
34 substituted into the command:: |
34 substituted into the command:: |
35 |
35 |
36 {first} The 1-based line number of the first line in the modified range |
36 {first} The 1-based line number of the first line in the modified range |
37 {last} The 1-based line number of the last line in the modified range |
37 {last} The 1-based line number of the last line in the modified range |
38 |
38 |
39 The :fileset suboption determines which files will be passed through each |
39 The :pattern suboption determines which files will be passed through each |
40 configured tool. See :hg:`help fileset` for possible values. If there are file |
40 configured tool. See :hg:`help patterns` for possible values. If there are file |
41 arguments to :hg:`fix`, the intersection of these filesets is used. |
41 arguments to :hg:`fix`, the intersection of these patterns is used. |
42 |
42 |
43 There is also a configurable limit for the maximum size of file that will be |
43 There is also a configurable limit for the maximum size of file that will be |
44 processed by :hg:`fix`:: |
44 processed by :hg:`fix`:: |
45 |
45 |
46 [fix] |
46 [fix] |
98 |
98 |
99 configtable = {} |
99 configtable = {} |
100 configitem = registrar.configitem(configtable) |
100 configitem = registrar.configitem(configtable) |
101 |
101 |
102 # Register the suboptions allowed for each configured fixer. |
102 # Register the suboptions allowed for each configured fixer. |
103 FIXER_ATTRS = ('command', 'linerange', 'fileset') |
103 FIXER_ATTRS = ('command', 'linerange', 'fileset', 'pattern') |
104 |
104 |
105 for key in FIXER_ATTRS: |
105 for key in FIXER_ATTRS: |
106 configitem('fix', '.*(:%s)?' % key, default=None, generic=True) |
106 configitem('fix', '.*(:%s)?' % key, default=None, generic=True) |
107 |
107 |
108 # A good default size allows most source code files to be fixed, but avoids |
108 # A good default size allows most source code files to be fixed, but avoids |
604 """ |
604 """ |
605 result = {} |
605 result = {} |
606 for name in fixernames(ui): |
606 for name in fixernames(ui): |
607 result[name] = Fixer() |
607 result[name] = Fixer() |
608 attrs = ui.configsuboptions('fix', name)[1] |
608 attrs = ui.configsuboptions('fix', name)[1] |
|
609 if 'fileset' in attrs and 'pattern' not in attrs: |
|
610 ui.warn(_('the fix.tool:fileset config name is deprecated; ' |
|
611 'please rename it to fix.tool:pattern\n')) |
|
612 attrs['pattern'] = attrs['fileset'] |
609 for key in FIXER_ATTRS: |
613 for key in FIXER_ATTRS: |
610 setattr(result[name], pycompat.sysstr('_' + key), |
614 setattr(result[name], pycompat.sysstr('_' + key), |
611 attrs.get(key, '')) |
615 attrs.get(key, '')) |
612 return result |
616 return result |
613 |
617 |
622 class Fixer(object): |
626 class Fixer(object): |
623 """Wraps the raw config values for a fixer with methods""" |
627 """Wraps the raw config values for a fixer with methods""" |
624 |
628 |
625 def affects(self, opts, fixctx, path): |
629 def affects(self, opts, fixctx, path): |
626 """Should this fixer run on the file at the given path and context?""" |
630 """Should this fixer run on the file at the given path and context?""" |
627 return scmutil.match(fixctx, [self._fileset], opts)(path) |
631 return scmutil.match(fixctx, [self._pattern], opts)(path) |
628 |
632 |
629 def command(self, ui, path, rangesfn): |
633 def command(self, ui, path, rangesfn): |
630 """A shell command to use to invoke this fixer on the given file/lines |
634 """A shell command to use to invoke this fixer on the given file/lines |
631 |
635 |
632 May return None if there is no appropriate command to run for the given |
636 May return None if there is no appropriate command to run for the given |