# HG changeset patch # User Christian Ebert # Date 1184768224 -7200 # Node ID a01a0392f64855f6f698151a71ff72db9e942208 # Parent c1b7b1d052de0bacadf8fea16c771c68a2a7597c kwdemo accepts maps as arguments, reads from optional rcfile diff -r c1b7b1d052de -r a01a0392f648 hgkw/keyword.py --- a/hgkw/keyword.py Wed Jul 18 16:12:14 2007 +0200 +++ b/hgkw/keyword.py Wed Jul 18 16:17:04 2007 +0200 @@ -298,12 +298,13 @@ ''' overwrite(ui, repo, files=args) -def demo(ui, repo, **opts): +def demo(ui, repo, *args, **opts): '''print [keywordmaps] configuration and an expansion example - Show current or default keyword template maps and their expansion + show current, custom, or default keyword template maps and their expansion ''' msg = 'hg keyword config and expansion example' + kwstatus = 'current' fn = 'demo.txt' tmpdir = tempfile.mkdtemp('', 'kwdemo.') ui.note(_('creating temporary repo at %s\n') % tmpdir) @@ -315,7 +316,13 @@ kwstatus = 'default' kwmaps = deftemplates else: - kwstatus = 'current' + if args or opts['rcfile']: + kwstatus = 'custom' + for tmap in args: + k, v = tmap.split('=', 1) + ui.setconfig('keywordmaps', k.strip(), v.strip()) + if opts['rcfile']: + ui.readconfig(opts['rcfile']) kwmaps = dict(ui.configitems('keywordmaps')) or deftemplates if ui.configitems('keywordmaps'): for k, v in kwmaps.items(): @@ -408,8 +415,9 @@ cmdtable = { 'kwdemo': (demo, - [('d', 'default', None, _('show default keyword template maps'))], - _('hg kwdemo [-d]')), + [('d', 'default', None, _('show default keyword template maps')), + ('f', 'rcfile', [], _('read maps from RCFILE'))], + _('hg kwdemo [-d || [-f RCFILE] TEMPLATEMAP ...]')), 'kwshrink': (shrink, [], _('hg kwshrink [NAME] ...')), 'kwexpand': (expand, [], _('hg kwexpand [NAME] ...')), }