hgkw/keyword.py
branch0.9.2compat
changeset 610 5b87f3ea105a
parent 607 783774a5eff3
child 613 cae62580bea3
equal deleted inserted replaced
607:783774a5eff3 610:5b87f3ea105a
   453     Extend current configuration by specifying maps as arguments and
   453     Extend current configuration by specifying maps as arguments and
   454     optionally by reading from an additional hgrc file.
   454     optionally by reading from an additional hgrc file.
   455 
   455 
   456     Override current keyword template maps with "default" option.
   456     Override current keyword template maps with "default" option.
   457     '''
   457     '''
   458     def demostatus(stat):
       
   459         ui.status(_('\n\t%s\n') % stat)
       
   460 
       
   461     def demoitems(section, items):
   458     def demoitems(section, items):
   462         ui.write('[%s]\n' % section)
   459         ui.write('[%s]\n' % section)
   463         for k, v in items:
   460         for k, v in items:
   464             ui.write('%s = %s\n' % (k, v))
   461             ui.write('%s = %s\n' % (k, v))
   465 
   462 
   494     reposetup(ui, repo)
   491     reposetup(ui, repo)
   495     for k, v in ui.configitems('extensions'):
   492     for k, v in ui.configitems('extensions'):
   496         if k.endswith('keyword'):
   493         if k.endswith('keyword'):
   497             extension = '%s = %s' % (k, v)
   494             extension = '%s = %s' % (k, v)
   498             break
   495             break
   499     demostatus('config using %s keyword template maps' % kwstatus)
   496     ui.status(_('\n\tconfig using %s keyword template maps\n') % kwstatus)
   500     ui.write('[extensions]\n%s\n' % extension)
   497     ui.write('[extensions]\n%s\n' % extension)
   501     demoitems('keyword', ui.configitems('keyword'))
   498     demoitems('keyword', ui.configitems('keyword'))
   502     demoitems('keywordmaps', kwmaps.iteritems())
   499     demoitems('keywordmaps', kwmaps.iteritems())
   503     keywords = '$' + '$\n$'.join(kwmaps.keys()) + '$\n'
   500     keywords = '$' + '$\n$'.join(kwmaps.keys()) + '$\n'
   504     repo.wopener(fn, 'w').write(keywords)
   501     repo.wopener(fn, 'w').write(keywords)
   517             repo.ui.setconfig('hooks', name, '')
   514             repo.ui.setconfig('hooks', name, '')
   518     ui.note(_('unhooked all commit hooks\n'))
   515     ui.note(_('unhooked all commit hooks\n'))
   519     ui.note('hg -R "%s" ci -m "%s"\n' % (tmpdir, msg))
   516     ui.note('hg -R "%s" ci -m "%s"\n' % (tmpdir, msg))
   520     repo.commit(text=msg)
   517     repo.commit(text=msg)
   521     fmt = ui.verbose and ' in %s' % path or ''
   518     fmt = ui.verbose and ' in %s' % path or ''
   522     demostatus('%s keywords expanded%s' % (kwstatus, fmt))
   519     ui.status(_('\n\t%s keywords expanded%s\n') % (kwstatus, fmt))
   523     ui.write(repo.wread(fn))
   520     ui.write(repo.wread(fn))
   524     ui.debug(_('\nremoving temporary repository %s\n') % tmpdir)
   521     ui.debug(_('\nremoving temporary repository %s\n') % tmpdir)
   525     shutil.rmtree(tmpdir, ignore_errors=True)
   522     shutil.rmtree(tmpdir, ignore_errors=True)
   526 
   523 
   527 def expand(ui, repo, *pats, **opts):
   524 def expand(ui, repo, *pats, **opts):