hgext/keyword.py
changeset 10713 b9c3f8e88e4f
parent 10712 fbe138da6b38
child 10714 9c0a1887bd4b
equal deleted inserted replaced
10712:fbe138da6b38 10713:b9c3f8e88e4f
   285         ui.write('[%s]\n' % section)
   285         ui.write('[%s]\n' % section)
   286         for k, v in sorted(items):
   286         for k, v in sorted(items):
   287             ui.write('%s = %s\n' % (k, v))
   287             ui.write('%s = %s\n' % (k, v))
   288 
   288 
   289     fn = 'demo.txt'
   289     fn = 'demo.txt'
   290     branchname = 'demobranch'
       
   291     tmpdir = tempfile.mkdtemp('', 'kwdemo.')
   290     tmpdir = tempfile.mkdtemp('', 'kwdemo.')
   292     ui.note(_('creating temporary repository at %s\n') % tmpdir)
   291     ui.note(_('creating temporary repository at %s\n') % tmpdir)
   293     repo = localrepo.localrepository(ui, tmpdir, True)
   292     repo = localrepo.localrepository(ui, tmpdir, True)
   294     ui.setconfig('keyword', fn, '')
   293     ui.setconfig('keyword', fn, '')
   295 
   294 
   331     demoitems('keyword', ui.configitems('keyword'))
   330     demoitems('keyword', ui.configitems('keyword'))
   332     demoitems('keywordmaps', kwmaps.iteritems())
   331     demoitems('keywordmaps', kwmaps.iteritems())
   333     keywords = '$' + '$\n$'.join(sorted(kwmaps.keys())) + '$\n'
   332     keywords = '$' + '$\n$'.join(sorted(kwmaps.keys())) + '$\n'
   334     repo.wopener(fn, 'w').write(keywords)
   333     repo.wopener(fn, 'w').write(keywords)
   335     repo.add([fn])
   334     repo.add([fn])
   336     path = repo.wjoin(fn)
   335     ui.note(_('\nkeywords written to %s:\n') % fn)
   337     ui.note(_('\nkeywords written to %s:\n') % path)
       
   338     ui.note(keywords)
   336     ui.note(keywords)
   339     ui.note('\nhg -R "%s" branch "%s"\n' % (tmpdir, branchname))
   337     repo.dirstate.setbranch('demobranch')
   340     # silence branch command if not verbose
       
   341     quiet = ui.quiet
       
   342     ui.quiet = not ui.verbose
       
   343     commands.branch(ui, repo, branchname)
       
   344     ui.quiet = quiet
       
   345     for name, cmd in ui.configitems('hooks'):
   338     for name, cmd in ui.configitems('hooks'):
   346         if name.split('.', 1)[0].find('commit') > -1:
   339         if name.split('.', 1)[0].find('commit') > -1:
   347             repo.ui.setconfig('hooks', name, '')
   340             repo.ui.setconfig('hooks', name, '')
   348     ui.note(_('unhooked all commit hooks\n'))
       
   349     msg = _('hg keyword configuration and expansion example')
   341     msg = _('hg keyword configuration and expansion example')
   350     ui.note("hg -R '%s' ci -m '%s'\n" % (tmpdir, msg))
   342     ui.note("hg ci -m '%s'\n" % msg)
   351     repo.commit(text=msg)
   343     repo.commit(text=msg)
   352     ui.status(_('\n\tkeywords expanded\n'))
   344     ui.status(_('\n\tkeywords expanded\n'))
   353     ui.write(repo.wread(fn))
   345     ui.write(repo.wread(fn))
   354     ui.debug('\nremoving temporary repository %s\n' % tmpdir)
       
   355     shutil.rmtree(tmpdir, ignore_errors=True)
   346     shutil.rmtree(tmpdir, ignore_errors=True)
   356 
   347 
   357 def expand(ui, repo, *pats, **opts):
   348 def expand(ui, repo, *pats, **opts):
   358     '''expand keywords in the working directory
   349     '''expand keywords in the working directory
   359 
   350