hgkw/keyword.py
changeset 699 57f8b7f021e8
parent 696 2305f9255f04
child 700 bf7b214673e2
equal deleted inserted replaced
696:2305f9255f04 699:57f8b7f021e8
   287     def demoitems(section, items):
   287     def demoitems(section, items):
   288         ui.write('[%s]\n' % section)
   288         ui.write('[%s]\n' % section)
   289         for k, v in sorted(items):
   289         for k, v in sorted(items):
   290             ui.write('%s = %s\n' % (k, v))
   290             ui.write('%s = %s\n' % (k, v))
   291 
   291 
   292     msg = 'hg keyword config and expansion example'
       
   293     fn = 'demo.txt'
   292     fn = 'demo.txt'
   294     branchname = 'demobranch'
   293     branchname = 'demobranch'
   295     tmpdir = tempfile.mkdtemp('', 'kwdemo.')
   294     tmpdir = tempfile.mkdtemp('', 'kwdemo.')
   296     ui.note(_('creating temporary repository at %s\n') % tmpdir)
   295     ui.note(_('creating temporary repository at %s\n') % tmpdir)
   297     repo = localrepo.localrepository(ui, tmpdir, True)
   296     repo = localrepo.localrepository(ui, tmpdir, True)
   348     ui.quiet = quiet
   347     ui.quiet = quiet
   349     for name, cmd in ui.configitems('hooks'):
   348     for name, cmd in ui.configitems('hooks'):
   350         if name.split('.', 1)[0].find('commit') > -1:
   349         if name.split('.', 1)[0].find('commit') > -1:
   351             repo.ui.setconfig('hooks', name, '')
   350             repo.ui.setconfig('hooks', name, '')
   352     ui.note(_('unhooked all commit hooks\n'))
   351     ui.note(_('unhooked all commit hooks\n'))
   353     ui.note('hg -R "%s" ci -m "%s"\n' % (tmpdir, msg))
   352     msg = _('hg keyword configuration and expansion example')
       
   353     ui.note("hg -R '%s' ci -m '%s'\n" % (tmpdir, msg))
   354     repo.commit(text=msg)
   354     repo.commit(text=msg)
   355     ui.status(_('\n\tkeywords expanded\n'))
   355     ui.status(_('\n\tkeywords expanded\n'))
   356     ui.write(repo.wread(fn))
   356     ui.write(repo.wread(fn))
   357     ui.debug('\nremoving temporary repository %s\n' % tmpdir)
   357     ui.debug('\nremoving temporary repository %s\n' % tmpdir)
   358     shutil.rmtree(tmpdir, ignore_errors=True)
   358     shutil.rmtree(tmpdir, ignore_errors=True)