hgkw/keyword.py
changeset 590 527257649f20
parent 584 763d20224433
child 592 ee684f9da112
child 593 23da65f04361
equal deleted inserted replaced
588:ed69ef4bd191 590:527257649f20
   279     Extend current configuration by specifying maps as arguments and
   279     Extend current configuration by specifying maps as arguments and
   280     optionally by reading from an additional hgrc file.
   280     optionally by reading from an additional hgrc file.
   281 
   281 
   282     Override current keyword template maps with "default" option.
   282     Override current keyword template maps with "default" option.
   283     '''
   283     '''
   284     def demostatus(stat):
       
   285         ui.status(_('\n\t%s\n') % stat)
       
   286 
       
   287     def demoitems(section, items):
   284     def demoitems(section, items):
   288         ui.write('[%s]\n' % section)
   285         ui.write('[%s]\n' % section)
   289         for k, v in items:
   286         for k, v in items:
   290             ui.write('%s = %s\n' % (k, v))
   287             ui.write('%s = %s\n' % (k, v))
   291 
   288 
   321     reposetup(ui, repo)
   318     reposetup(ui, repo)
   322     for k, v in ui.configitems('extensions'):
   319     for k, v in ui.configitems('extensions'):
   323         if k.endswith('keyword'):
   320         if k.endswith('keyword'):
   324             extension = '%s = %s' % (k, v)
   321             extension = '%s = %s' % (k, v)
   325             break
   322             break
   326     demostatus('config using %s keyword template maps' % kwstatus)
   323     ui.status(_('\n\tconfig using %s keyword template maps\n') % kwstatus)
   327     ui.write('[extensions]\n%s\n' % extension)
   324     ui.write('[extensions]\n%s\n' % extension)
   328     demoitems('keyword', ui.configitems('keyword'))
   325     demoitems('keyword', ui.configitems('keyword'))
   329     demoitems('keywordmaps', kwmaps.iteritems())
   326     demoitems('keywordmaps', kwmaps.iteritems())
   330     keywords = '$' + '$\n$'.join(kwmaps.keys()) + '$\n'
   327     keywords = '$' + '$\n$'.join(kwmaps.keys()) + '$\n'
   331     repo.wopener(fn, 'w').write(keywords)
   328     repo.wopener(fn, 'w').write(keywords)
   344             repo.ui.setconfig('hooks', name, '')
   341             repo.ui.setconfig('hooks', name, '')
   345     ui.note(_('unhooked all commit hooks\n'))
   342     ui.note(_('unhooked all commit hooks\n'))
   346     ui.note('hg -R "%s" ci -m "%s"\n' % (tmpdir, msg))
   343     ui.note('hg -R "%s" ci -m "%s"\n' % (tmpdir, msg))
   347     repo.commit(text=msg)
   344     repo.commit(text=msg)
   348     fmt = ui.verbose and ' in %s' % path or ''
   345     fmt = ui.verbose and ' in %s' % path or ''
   349     demostatus('%s keywords expanded%s' % (kwstatus, fmt))
   346     ui.status(_('\n\t%s keywords expanded%s\n') % (kwstatus, fmt))
   350     ui.write(repo.wread(fn))
   347     ui.write(repo.wread(fn))
   351     ui.debug(_('\nremoving temporary repository %s\n') % tmpdir)
   348     ui.debug(_('\nremoving temporary repository %s\n') % tmpdir)
   352     shutil.rmtree(tmpdir, ignore_errors=True)
   349     shutil.rmtree(tmpdir, ignore_errors=True)
   353 
   350 
   354 def expand(ui, repo, *pats, **opts):
   351 def expand(ui, repo, *pats, **opts):