hgkw/keyword.py
branchkwmap-templates
changeset 183 80fa00250c6d
parent 182 de32fbee75a4
child 184 30b3e6a09a9d
--- a/hgkw/keyword.py	Tue Jul 17 09:17:03 2007 +0200
+++ b/hgkw/keyword.py	Tue Jul 17 09:24:27 2007 +0200
@@ -217,11 +217,10 @@
 def demo(ui, repo, **opts):
     '''print [keywordmaps] configuration and an expansion example
     '''
-    log = 'hg keyword config and expansion example'
+    msg = 'hg keyword config and expansion example'
     fn = 'demo.txt'
     tmpdir = tempfile.mkdtemp('', 'kwdemo.')
-    if ui.verbose:
-        ui.status(_('creating temporary repo at %s\n') % tmpdir)
+    ui.note(_('creating temporary repo at %s\n') % tmpdir)
     _repo = localrepo.localrepository(ui, path=tmpdir, create=True)
     _repo.ui.setconfig('keyword', fn, '')
     if opts['default']:
@@ -234,25 +233,22 @@
         for k, v in kwmaps.items():
             _repo.ui.setconfig('keywordmaps', k, v)
     reposetup(_repo.ui, _repo)
-    ui.status(_('config with %s keyword maps:\n') % kwstatus)
+    ui.status(_('config with %s keyword template maps:\n') % kwstatus)
     ui.write('[keyword]\n%s =\n[keywordmaps]\n' % fn)
     for k, v in kwmaps.items():
         ui.write('%s = %s\n' % (k, v))
     path = _repo.wjoin(fn)
     keywords = '$' + '$\n$'.join(kwmaps.keys()) + '$\n'
-    _repo.wfile(fn, 'w').write(keywords)
+    _repo.wopener(fn, 'w').write(keywords)
     _repo.add([fn])
-    if ui.verbose:
-        ui.status(_('\n%s keywords written to %s:\n') % (kwstatus, path))
-        ui.write(keywords)
-        ui.status(_("\nhg --repository '%s' commit\n") % tmpdir)
-    _repo.commit(text=log)
-    if ui.verbose:
-        ui.status(_('\n%s keywords expanded in %s:\n') % (kwstatus, path))
-    else:
-        ui.status(_('\n%s keywords expanded:\n') % kwstatus)
+    ui.note(_('\n%s keywords written to %s:\n') % (kwstatus, path))
+    ui.note(keywords)
+    ui.note(_("\nhg --repository '%s' commit\n") % tmpdir)
+    _repo.commit(text=msg)
+    pathinfo = ('', ' in %s' % path)[ui.verbose]
+    ui.status(_('\n%s keywords expanded%s:\n') % (kwstatus, pathinfo))
     ui.write(_repo.wread(fn))
-    ui.debug(_('\nremoving temporary repo\n'))
+    ui.debug(_('\nremoving temporary repo %s\n') % tmpdir)
     shutil.rmtree(tmpdir)
 
 
@@ -272,6 +268,7 @@
     if kwfmatcher is None:
         return
 
+    # for backwards compatibility
     ui = repo.ui
 
     class kwrepo(repo.__class__):