keyword: make kwdemo less verbose
authorChristian Ebert <blacktrash@gmx.net>
Tue, 16 Mar 2010 22:28:58 +0100
changeset 10713 b9c3f8e88e4f
parent 10712 fbe138da6b38
child 10714 9c0a1887bd4b
keyword: make kwdemo less verbose 1) Set the branchname always silently with dirstate.setbranch(). We create a branch so that testing the {branches} template does not come up empty. But kwdemo is hardly the place to inform the user by inference why {branches} is empty on the default branch. "demobranch" is ascii and cannot be changed, so using the internal command instead of commands.branch() is safe. 2) Do not show full path to temporary directory (distracting long lines on Mac OS X). 3) No special debug output. Output only related to keyword, no internals like unsetting of commit hooks etc.
hgext/keyword.py
--- a/hgext/keyword.py	Tue Mar 16 22:28:23 2010 +0100
+++ b/hgext/keyword.py	Tue Mar 16 22:28:58 2010 +0100
@@ -287,7 +287,6 @@
             ui.write('%s = %s\n' % (k, v))
 
     fn = 'demo.txt'
-    branchname = 'demobranch'
     tmpdir = tempfile.mkdtemp('', 'kwdemo.')
     ui.note(_('creating temporary repository at %s\n') % tmpdir)
     repo = localrepo.localrepository(ui, tmpdir, True)
@@ -333,25 +332,17 @@
     keywords = '$' + '$\n$'.join(sorted(kwmaps.keys())) + '$\n'
     repo.wopener(fn, 'w').write(keywords)
     repo.add([fn])
-    path = repo.wjoin(fn)
-    ui.note(_('\nkeywords written to %s:\n') % path)
+    ui.note(_('\nkeywords written to %s:\n') % fn)
     ui.note(keywords)
-    ui.note('\nhg -R "%s" branch "%s"\n' % (tmpdir, branchname))
-    # silence branch command if not verbose
-    quiet = ui.quiet
-    ui.quiet = not ui.verbose
-    commands.branch(ui, repo, branchname)
-    ui.quiet = quiet
+    repo.dirstate.setbranch('demobranch')
     for name, cmd in ui.configitems('hooks'):
         if name.split('.', 1)[0].find('commit') > -1:
             repo.ui.setconfig('hooks', name, '')
-    ui.note(_('unhooked all commit hooks\n'))
     msg = _('hg keyword configuration and expansion example')
-    ui.note("hg -R '%s' ci -m '%s'\n" % (tmpdir, msg))
+    ui.note("hg ci -m '%s'\n" % msg)
     repo.commit(text=msg)
     ui.status(_('\n\tkeywords expanded\n'))
     ui.write(repo.wread(fn))
-    ui.debug('\nremoving temporary repository %s\n' % tmpdir)
     shutil.rmtree(tmpdir, ignore_errors=True)
 
 def expand(ui, repo, *pats, **opts):