# HG changeset patch # User Christian Ebert # Date 1193179107 -7200 # Node ID 0aa02d36b3b1d61c4b1e84a3919c18a2be622475 # Parent bc19ab02c5f996b435613fb97bd24bd297434fa3 Arrange commands and cmdtable in alphabetical order diff -r bc19ab02c5f9 -r 0aa02d36b3b1 hgkw/keyword.py --- a/hgkw/keyword.py Tue Oct 23 09:10:11 2007 +0200 +++ b/hgkw/keyword.py Wed Oct 24 00:38:27 2007 +0200 @@ -339,57 +339,6 @@ del wlock, lock -def shrink(ui, repo, *pats, **opts): - '''revert expanded keywords in working directory - - Run before changing/disabling active keywords - or if you experience problems with "hg import" or "hg merge". - - kwshrink refuses to run if given files contain local changes. - ''' - # 3rd argument sets expansion to False - _kwfwrite(ui, repo, False, *pats, **opts) - -def expand(ui, repo, *pats, **opts): - '''expand keywords in working directory - - Run after (re)enabling keyword expansion. - - kwexpand refuses to run if given files contain local changes. - ''' - # 3rd argument sets expansion to True - _kwfwrite(ui, repo, True, *pats, **opts) - -def files(ui, repo, *pats, **opts): - '''print files currently configured for keyword expansion - - Crosscheck which files in working directory are potential targets for - keyword expansion. - That is, files matched by [keyword] config patterns but not symlinks. - ''' - status = _status(ui, repo, *pats, **opts) - modified, added, removed, deleted, unknown, ignored, clean = status - if opts['untracked']: - files = modified + added + unknown + clean - else: - files = modified + added + clean - files.sort() - # use the full definition of repo._link for backwards compatibility - kwfiles = [f for f in files if ui.kwfmatcher(f) - and not os.path.islink(repo.wjoin(f))] - cwd = pats and repo.getcwd() or '' - allf = opts['all'] - ignore = opts['ignore'] - flag = (allf or ui.verbose) and 1 or 0 - if not ignore: - format = ('%s\n', 'K %s\n')[flag] - for k in kwfiles: - ui.write(format % _pathto(repo, k, cwd)) - if allf or ignore: - format = ('%s\n', 'I %s\n')[flag] - for i in [f for f in files if f not in kwfiles]: - ui.write(format % _pathto(repo, i, cwd)) - def demo(ui, repo, *args, **opts): '''print [keywordmaps] configuration and an expansion example @@ -467,6 +416,57 @@ ui.debug(_('\nremoving temporary repo %s\n') % tmpdir) shutil.rmtree(tmpdir, ignore_errors=True) +def expand(ui, repo, *pats, **opts): + '''expand keywords in working directory + + Run after (re)enabling keyword expansion. + + kwexpand refuses to run if given files contain local changes. + ''' + # 3rd argument sets expansion to True + _kwfwrite(ui, repo, True, *pats, **opts) + +def files(ui, repo, *pats, **opts): + '''print files currently configured for keyword expansion + + Crosscheck which files in working directory are potential targets for + keyword expansion. + That is, files matched by [keyword] config patterns but not symlinks. + ''' + status = _status(ui, repo, *pats, **opts) + modified, added, removed, deleted, unknown, ignored, clean = status + if opts['untracked']: + files = modified + added + unknown + clean + else: + files = modified + added + clean + files.sort() + # use the full definition of repo._link for backwards compatibility + kwfiles = [f for f in files if ui.kwfmatcher(f) + and not os.path.islink(repo.wjoin(f))] + cwd = pats and repo.getcwd() or '' + allf = opts['all'] + ignore = opts['ignore'] + flag = (allf or ui.verbose) and 1 or 0 + if not ignore: + format = ('%s\n', 'K %s\n')[flag] + for k in kwfiles: + ui.write(format % _pathto(repo, k, cwd)) + if allf or ignore: + format = ('%s\n', 'I %s\n')[flag] + for i in [f for f in files if f not in kwfiles]: + ui.write(format % _pathto(repo, i, cwd)) + +def shrink(ui, repo, *pats, **opts): + '''revert expanded keywords in working directory + + Run before changing/disabling active keywords + or if you experience problems with "hg import" or "hg merge". + + kwshrink refuses to run if given files contain local changes. + ''' + # 3rd argument sets expansion to False + _kwfwrite(ui, repo, False, *pats, **opts) + def reposetup(ui, repo): '''Sets up repo as kwrepo for keyword substitution. @@ -557,6 +557,8 @@ [('d', 'default', None, _('show default keyword template maps')), ('f', 'rcfile', [], _('read maps from rcfile'))], _('hg kwdemo [-d] [-f RCFILE] [TEMPLATEMAP]...')), + 'kwexpand': (expand, commands.walkopts, + _('hg kwexpand [OPTION]... [FILE]...')), 'kwfiles': (files, [('a', 'all', None, _('show keyword status flags of all files')), @@ -566,6 +568,4 @@ _('hg kwfiles [OPTION]... [FILE]...')), 'kwshrink': (shrink, commands.walkopts, _('hg kwshrink [OPTION]... [FILE]...')), - 'kwexpand': (expand, commands.walkopts, - _('hg kwexpand [OPTION]... [FILE]...')), }