Details
Details
- Reviewers
yuja - Group Reviewers
hg-reviewers - Commits
- rHG3fbc30f7b9f0: py3: handle keyword arguments in hgext/keyword.py
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Lint
Lint Skipped - Unit
Unit Tests Skipped
( )
| yuja |
| hg-reviewers |
| Lint Skipped |
| Unit Tests Skipped |
| dispatch, | dispatch, | ||||
| error, | error, | ||||
| extensions, | extensions, | ||||
| filelog, | filelog, | ||||
| localrepo, | localrepo, | ||||
| match, | match, | ||||
| patch, | patch, | ||||
| pathutil, | pathutil, | ||||
| pycompat, | |||||
| registrar, | registrar, | ||||
| scmutil, | scmutil, | ||||
| templatefilters, | templatefilters, | ||||
| util, | util, | ||||
| ) | ) | ||||
| cmdtable = {} | cmdtable = {} | ||||
| command = registrar.command(cmdtable) | command = registrar.command(cmdtable) | ||||
| '''Removes keyword substitutions for comparison.''' | '''Removes keyword substitutions for comparison.''' | ||||
| text = self.kwt.shrink(self.path, text) | text = self.kwt.shrink(self.path, text) | ||||
| return super(kwfilelog, self).cmp(node, text) | return super(kwfilelog, self).cmp(node, text) | ||||
| def _status(ui, repo, wctx, kwt, *pats, **opts): | def _status(ui, repo, wctx, kwt, *pats, **opts): | ||||
| '''Bails out if [keyword] configuration is not active. | '''Bails out if [keyword] configuration is not active. | ||||
| Returns status of working directory.''' | Returns status of working directory.''' | ||||
| if kwt: | if kwt: | ||||
| opts = pycompat.byteskwargs(opts) | |||||
| return repo.status(match=scmutil.match(wctx, pats, opts), clean=True, | return repo.status(match=scmutil.match(wctx, pats, opts), clean=True, | ||||
| unknown=opts.get('unknown') or opts.get('all')) | unknown=opts.get('unknown') or opts.get('all')) | ||||
| if ui.configitems('keyword'): | if ui.configitems('keyword'): | ||||
| raise error.Abort(_('[keyword] patterns cannot match')) | raise error.Abort(_('[keyword] patterns cannot match')) | ||||
| raise error.Abort(_('no [keyword] patterns configured')) | raise error.Abort(_('no [keyword] patterns configured')) | ||||
| def _kwfwrite(ui, repo, expand, *pats, **opts): | def _kwfwrite(ui, repo, expand, *pats, **opts): | ||||
| '''Selects files and passes them to kwtemplater.overwrite.''' | '''Selects files and passes them to kwtemplater.overwrite.''' | ||||
| baseui = repo.baseui | baseui = repo.baseui | ||||
| repo = localrepo.localrepository(baseui, tmpdir, True) | repo = localrepo.localrepository(baseui, tmpdir, True) | ||||
| ui.setconfig('keyword', fn, '', 'keyword') | ui.setconfig('keyword', fn, '', 'keyword') | ||||
| svn = ui.configbool('keywordset', 'svn') | svn = ui.configbool('keywordset', 'svn') | ||||
| # explicitly set keywordset for demo output | # explicitly set keywordset for demo output | ||||
| ui.setconfig('keywordset', 'svn', svn, 'keyword') | ui.setconfig('keywordset', 'svn', svn, 'keyword') | ||||
| uikwmaps = ui.configitems('keywordmaps') | uikwmaps = ui.configitems('keywordmaps') | ||||
| if args or opts.get('rcfile'): | if args or opts.get(r'rcfile'): | ||||
| ui.status(_('\n\tconfiguration using custom keyword template maps\n')) | ui.status(_('\n\tconfiguration using custom keyword template maps\n')) | ||||
| if uikwmaps: | if uikwmaps: | ||||
| ui.status(_('\textending current template maps\n')) | ui.status(_('\textending current template maps\n')) | ||||
| if opts.get('default') or not uikwmaps: | if opts.get(r'default') or not uikwmaps: | ||||
| if svn: | if svn: | ||||
| ui.status(_('\toverriding default svn keywordset\n')) | ui.status(_('\toverriding default svn keywordset\n')) | ||||
| else: | else: | ||||
| ui.status(_('\toverriding default cvs keywordset\n')) | ui.status(_('\toverriding default cvs keywordset\n')) | ||||
| if opts.get('rcfile'): | if opts.get(r'rcfile'): | ||||
| ui.readconfig(opts.get('rcfile')) | ui.readconfig(opts.get('rcfile')) | ||||
| if args: | if args: | ||||
| # simulate hgrc parsing | # simulate hgrc parsing | ||||
| rcmaps = '[keywordmaps]\n%s\n' % '\n'.join(args) | rcmaps = '[keywordmaps]\n%s\n' % '\n'.join(args) | ||||
| repo.vfs.write('hgrc', rcmaps) | repo.vfs.write('hgrc', rcmaps) | ||||
| ui.readconfig(repo.vfs.join('hgrc')) | ui.readconfig(repo.vfs.join('hgrc')) | ||||
| kwmaps = dict(ui.configitems('keywordmaps')) | kwmaps = dict(ui.configitems('keywordmaps')) | ||||
| elif opts.get('default'): | elif opts.get(r'default'): | ||||
| if svn: | if svn: | ||||
| ui.status(_('\n\tconfiguration using default svn keywordset\n')) | ui.status(_('\n\tconfiguration using default svn keywordset\n')) | ||||
| else: | else: | ||||
| ui.status(_('\n\tconfiguration using default cvs keywordset\n')) | ui.status(_('\n\tconfiguration using default cvs keywordset\n')) | ||||
| kwmaps = _defaultkwmaps(ui) | kwmaps = _defaultkwmaps(ui) | ||||
| if uikwmaps: | if uikwmaps: | ||||
| ui.status(_('\tdisabling current template maps\n')) | ui.status(_('\tdisabling current template maps\n')) | ||||
| for k, v in kwmaps.iteritems(): | for k, v in kwmaps.iteritems(): | ||||
| kwt = getattr(repo, '_keywordkwt', None) | kwt = getattr(repo, '_keywordkwt', None) | ||||
| wctx = repo[None] | wctx = repo[None] | ||||
| status = _status(ui, repo, wctx, kwt, *pats, **opts) | status = _status(ui, repo, wctx, kwt, *pats, **opts) | ||||
| if pats: | if pats: | ||||
| cwd = repo.getcwd() | cwd = repo.getcwd() | ||||
| else: | else: | ||||
| cwd = '' | cwd = '' | ||||
| files = [] | files = [] | ||||
| opts = pycompat.byteskwargs(opts) | |||||
| if not opts.get('unknown') or opts.get('all'): | if not opts.get('unknown') or opts.get('all'): | ||||
| files = sorted(status.modified + status.added + status.clean) | files = sorted(status.modified + status.added + status.clean) | ||||
| kwfiles = kwt.iskwfile(files, wctx) | kwfiles = kwt.iskwfile(files, wctx) | ||||
| kwdeleted = kwt.iskwfile(status.deleted, wctx) | kwdeleted = kwt.iskwfile(status.deleted, wctx) | ||||
| kwunknown = kwt.iskwfile(status.unknown, wctx) | kwunknown = kwt.iskwfile(status.unknown, wctx) | ||||
| if not opts.get('ignore') or opts.get('all'): | if not opts.get('ignore') or opts.get('all'): | ||||
| showfiles = kwfiles, kwdeleted, kwunknown | showfiles = kwfiles, kwdeleted, kwunknown | ||||
| else: | else: | ||||