Details
Details
- Reviewers
- None
- Group Reviewers
hg-reviewers - Commits
- rHG9ed63cd0026c: fix: remove support for :fileset sub-config in favor of :pattern
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Lint
Lint Skipped - Unit
Unit Tests Skipped
| hg-reviewers |
| Lint Skipped |
| Unit Tests Skipped |
| Path | Packages | |||
|---|---|---|---|---|
| M | hgext/fix.py (5 lines) | |||
| M | tests/test-fix.t (22 lines) |
| Commit | Parents | Author | Summary | Date |
|---|---|---|---|---|
| b67be195a032 | 770dfc91f98f | Danny Hooper | Jul 24 2019, 7:22 PM |
| configtable = {} | configtable = {} | ||||
| configitem = registrar.configitem(configtable) | configitem = registrar.configitem(configtable) | ||||
| # Register the suboptions allowed for each configured fixer, and default values. | # Register the suboptions allowed for each configured fixer, and default values. | ||||
| FIXER_ATTRS = { | FIXER_ATTRS = { | ||||
| 'command': None, | 'command': None, | ||||
| 'linerange': None, | 'linerange': None, | ||||
| 'fileset': None, | |||||
| 'pattern': None, | 'pattern': None, | ||||
| 'priority': 0, | 'priority': 0, | ||||
| 'metadata': False, | 'metadata': False, | ||||
| } | } | ||||
| for key, default in FIXER_ATTRS.items(): | for key, default in FIXER_ATTRS.items(): | ||||
| configitem('fix', '.*(:%s)?' % key, default=default, generic=True) | configitem('fix', '.*(:%s)?' % key, default=default, generic=True) | ||||
| Each value is a Fixer object with methods that implement the behavior of the | Each value is a Fixer object with methods that implement the behavior of the | ||||
| fixer's config suboptions. Does not validate the config values. | fixer's config suboptions. Does not validate the config values. | ||||
| """ | """ | ||||
| fixers = {} | fixers = {} | ||||
| for name in fixernames(ui): | for name in fixernames(ui): | ||||
| fixers[name] = Fixer() | fixers[name] = Fixer() | ||||
| attrs = ui.configsuboptions('fix', name)[1] | attrs = ui.configsuboptions('fix', name)[1] | ||||
| if 'fileset' in attrs and 'pattern' not in attrs: | |||||
| ui.warn(_('the fix.tool:fileset config name is deprecated; ' | |||||
| 'please rename it to fix.tool:pattern\n')) | |||||
| attrs['pattern'] = attrs['fileset'] | |||||
| for key, default in FIXER_ATTRS.items(): | for key, default in FIXER_ATTRS.items(): | ||||
| setattr(fixers[name], pycompat.sysstr('_' + key), | setattr(fixers[name], pycompat.sysstr('_' + key), | ||||
| attrs.get(key, default)) | attrs.get(key, default)) | ||||
| fixers[name]._priority = int(fixers[name]._priority) | fixers[name]._priority = int(fixers[name]._priority) | ||||
| # Don't use a fixer if it has no pattern configured. It would be | # 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 | # 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 | # affect no files. There is no reasonable subset of files to use as the | ||||
| # default. | # default. | ||||
| $ hg fix --working-dir --base 0 --whole | $ hg fix --working-dir --base 0 --whole | ||||
| $ cat *.changed | $ cat *.changed | ||||
| BAR | BAR | ||||
| FOO1 | FOO1 | ||||
| FOO2 | FOO2 | ||||
| $ cd .. | $ cd .. | ||||
| The :fileset subconfig was a misnomer, so we renamed it to :pattern. We will | |||||
| still accept :fileset by itself as if it were :pattern, but this will issue a | |||||
| warning. | |||||
| $ hg init filesetispattern | |||||
| $ cd filesetispattern | |||||
| $ printf "foo\n" > foo.whole | |||||
| $ printf "first\nsecond\n" > bar.txt | |||||
| $ hg add -q | |||||
| $ hg fix -w --config fix.sometool:fileset=bar.txt \ | |||||
| > --config fix.sometool:command="sort -r" | |||||
| the fix.tool:fileset config name is deprecated; please rename it to fix.tool:pattern | |||||
| $ cat foo.whole | |||||
| FOO | |||||
| $ cat bar.txt | |||||
| second | |||||
| first | |||||
| $ cd .. | |||||
| The execution order of tools can be controlled. This example doesn't work if | The execution order of tools can be controlled. This example doesn't work if | ||||
| you sort after truncating, but the config defines the correct order while the | you sort after truncating, but the config defines the correct order while the | ||||
| definitions are out of order (which might imply the incorrect order given the | definitions are out of order (which might imply the incorrect order given the | ||||
| implementation of fix). The goal is to use multiple tools to select the lowest | implementation of fix). The goal is to use multiple tools to select the lowest | ||||
| 5 numbers in the file. | 5 numbers in the file. | ||||
| $ hg init priorityexample | $ hg init priorityexample | ||||
| $ cd priorityexample | $ cd priorityexample | ||||