hgkw/keyword.py
changeset 874 272a8a316f7a
parent 873 05e160f8f8bc
child 875 e01f1b4a62e9
equal deleted inserted replaced
873:05e160f8f8bc 874:272a8a316f7a
   353     fn = 'demo.txt'
   353     fn = 'demo.txt'
   354     tmpdir = tempfile.mkdtemp('', 'kwdemo.')
   354     tmpdir = tempfile.mkdtemp('', 'kwdemo.')
   355     ui.note(_('creating temporary repository at %s\n') % tmpdir)
   355     ui.note(_('creating temporary repository at %s\n') % tmpdir)
   356     repo = localrepo.localrepository(ui, tmpdir, True)
   356     repo = localrepo.localrepository(ui, tmpdir, True)
   357     ui.setconfig('keyword', fn, '')
   357     ui.setconfig('keyword', fn, '')
       
   358     svn = ui.configbool('keywordset', 'svn')
       
   359     # explicitly set keywordset for demo output
       
   360     ui.setconfig('keywordset', 'svn', svn)
   358 
   361 
   359     uikwmaps = ui.configitems('keywordmaps')
   362     uikwmaps = ui.configitems('keywordmaps')
   360     if args or opts.get('rcfile'):
   363     if args or opts.get('rcfile'):
   361         ui.status(_('\n\tconfiguration using custom keyword template maps\n'))
   364         ui.status(_('\n\tconfiguration using custom keyword template maps\n'))
   362         if uikwmaps:
   365         if uikwmaps:
   363             ui.status(_('\textending current template maps\n'))
   366             ui.status(_('\textending current template maps\n'))
   364         if opts.get('default') or not uikwmaps:
   367         if opts.get('default') or not uikwmaps:
   365             ui.status(_('\toverriding default template maps\n'))
   368             if svn:
       
   369                 ui.status(_('\toverriding default svn keywordset\n'))
       
   370             else:
       
   371                 ui.status(_('\toverriding default cvs keywordset\n'))
   366         if opts.get('rcfile'):
   372         if opts.get('rcfile'):
   367             ui.readconfig(opts.get('rcfile'))
   373             ui.readconfig(opts.get('rcfile'))
   368         if args:
   374         if args:
   369             # simulate hgrc parsing
   375             # simulate hgrc parsing
   370             rcmaps = ['[keywordmaps]\n'] + [a + '\n' for a in args]
   376             rcmaps = ['[keywordmaps]\n'] + [a + '\n' for a in args]
   372             fp.writelines(rcmaps)
   378             fp.writelines(rcmaps)
   373             fp.close()
   379             fp.close()
   374             ui.readconfig(repo.join('hgrc'))
   380             ui.readconfig(repo.join('hgrc'))
   375         kwmaps = dict(ui.configitems('keywordmaps'))
   381         kwmaps = dict(ui.configitems('keywordmaps'))
   376     elif opts.get('default'):
   382     elif opts.get('default'):
   377         ui.status(_('\n\tconfiguration using default keyword template maps\n'))
   383         if svn:
       
   384             ui.status(_('\n\tconfiguration using default svn keywordset\n'))
       
   385         else:
       
   386             ui.status(_('\n\tconfiguration using default cvs keywordset\n'))
   378         kwmaps = _defaultkwmaps(ui)
   387         kwmaps = _defaultkwmaps(ui)
   379         if uikwmaps:
   388         if uikwmaps:
   380             ui.status(_('\tdisabling current template maps\n'))
   389             ui.status(_('\tdisabling current template maps\n'))
   381             for k, v in kwmaps.iteritems():
   390             for k, v in kwmaps.iteritems():
   382                 ui.setconfig('keywordmaps', k, v)
   391                 ui.setconfig('keywordmaps', k, v)
   386 
   395 
   387     uisetup(ui)
   396     uisetup(ui)
   388     reposetup(ui, repo)
   397     reposetup(ui, repo)
   389     ui.write('[extensions]\nkeyword =\n')
   398     ui.write('[extensions]\nkeyword =\n')
   390     demoitems('keyword', ui.configitems('keyword'))
   399     demoitems('keyword', ui.configitems('keyword'))
       
   400     demoitems('keywordset', ui.configitems('keywordset'))
   391     demoitems('keywordmaps', kwmaps.iteritems())
   401     demoitems('keywordmaps', kwmaps.iteritems())
   392     keywords = '$' + '$\n$'.join(sorted(kwmaps.keys())) + '$\n'
   402     keywords = '$' + '$\n$'.join(sorted(kwmaps.keys())) + '$\n'
   393     repo.wopener(fn, 'w').write(keywords)
   403     repo.wopener(fn, 'w').write(keywords)
   394     repo[None].add([fn])
   404     repo[None].add([fn])
   395     ui.note(_('\nkeywords written to %s:\n') % fn)
   405     ui.note(_('\nkeywords written to %s:\n') % fn)