hgkw/keyword.py
changeset 1360 e7fa36b2bd23
parent 1357 a9e00192f30a
equal deleted inserted replaced
1356:d9c3f8002e7c 1360:e7fa36b2bd23
   382 
   382 
   383     fn = 'demo.txt'
   383     fn = 'demo.txt'
   384     tmpdir = tempfile.mkdtemp('', 'kwdemo.')
   384     tmpdir = tempfile.mkdtemp('', 'kwdemo.')
   385     ui.note(_('creating temporary repository at %s\n') % tmpdir)
   385     ui.note(_('creating temporary repository at %s\n') % tmpdir)
   386     repo = localrepo.localrepository(repo.baseui, tmpdir, True)
   386     repo = localrepo.localrepository(repo.baseui, tmpdir, True)
   387     ui.setconfig('keyword', fn, '')
   387     ui.setconfig('keyword', fn, '', 'keyword')
   388     svn = ui.configbool('keywordset', 'svn')
   388     svn = ui.configbool('keywordset', 'svn')
   389     # explicitly set keywordset for demo output
   389     # explicitly set keywordset for demo output
   390     ui.setconfig('keywordset', 'svn', svn)
   390     ui.setconfig('keywordset', 'svn', svn, 'keyword')
   391 
   391 
   392     uikwmaps = ui.configitems('keywordmaps')
   392     uikwmaps = ui.configitems('keywordmaps')
   393     if args or opts.get('rcfile'):
   393     if args or opts.get('rcfile'):
   394         ui.status(_('\n\tconfiguration using custom keyword template maps\n'))
   394         ui.status(_('\n\tconfiguration using custom keyword template maps\n'))
   395         if uikwmaps:
   395         if uikwmaps:
   416             ui.status(_('\n\tconfiguration using default cvs keywordset\n'))
   416             ui.status(_('\n\tconfiguration using default cvs keywordset\n'))
   417         kwmaps = _defaultkwmaps(ui)
   417         kwmaps = _defaultkwmaps(ui)
   418         if uikwmaps:
   418         if uikwmaps:
   419             ui.status(_('\tdisabling current template maps\n'))
   419             ui.status(_('\tdisabling current template maps\n'))
   420             for k, v in kwmaps.iteritems():
   420             for k, v in kwmaps.iteritems():
   421                 ui.setconfig('keywordmaps', k, v)
   421                 ui.setconfig('keywordmaps', k, v, 'keyword')
   422     else:
   422     else:
   423         ui.status(_('\n\tconfiguration using current keyword template maps\n'))
   423         ui.status(_('\n\tconfiguration using current keyword template maps\n'))
   424         if uikwmaps:
   424         if uikwmaps:
   425             kwmaps = dict(uikwmaps)
   425             kwmaps = dict(uikwmaps)
   426         else:
   426         else:
   442         repo.dirstate.setbranch('demobranch')
   442         repo.dirstate.setbranch('demobranch')
   443     finally:
   443     finally:
   444         wlock.release()
   444         wlock.release()
   445     for name, cmd in ui.configitems('hooks'):
   445     for name, cmd in ui.configitems('hooks'):
   446         if name.split('.', 1)[0].find('commit') > -1:
   446         if name.split('.', 1)[0].find('commit') > -1:
   447             repo.ui.setconfig('hooks', name, '')
   447             repo.ui.setconfig('hooks', name, '', 'keyword')
   448     msg = _('hg keyword configuration and expansion example')
   448     msg = _('hg keyword configuration and expansion example')
   449     ui.note(("hg ci -m '%s'\n" % msg))
   449     ui.note(("hg ci -m '%s'\n" % msg))
   450     repo.commit(text=msg)
   450     repo.commit(text=msg)
   451     ui.status(_('\n\tkeywords expanded\n'))
   451     ui.status(_('\n\tkeywords expanded\n'))
   452     ui.write(repo.wread(fn))
   452     ui.write(repo.wread(fn))