hgkw/keyword.py
changeset 263 fc7f60b109b6
parent 262 397a5957cc48
child 264 7c637046c0e2
equal deleted inserted replaced
262:397a5957cc48 263:fc7f60b109b6
   298         if self.renamed(node):
   298         if self.renamed(node):
   299             t2 = super(kwfilelog, self).read(node)
   299             t2 = super(kwfilelog, self).read(node)
   300             return t2 != text
   300             return t2 != text
   301         return revlog.revlog.cmp(self, node, text)
   301         return revlog.revlog.cmp(self, node, text)
   302 
   302 
       
   303 _nokwfiles = 'no files configured for keyword expansion'
       
   304 
   303 def _weedcandidates(ui, man, candidates):
   305 def _weedcandidates(ui, man, candidates):
   304     '''Weeds out files that do not match keyword file matcher,
   306     '''Weeds out files that do not match keyword file matcher,
   305     are not tracked, or are links.'''
   307     are not tracked, or are links.'''
   306     files = man.keys()
   308     files = man.keys()
   307     if candidates:
   309     if candidates:
   310     return [f for f in files if ui.kwfmatcher(f) and not man.linkf(f)]
   312     return [f for f in files if ui.kwfmatcher(f) and not man.linkf(f)]
   311 
   313 
   312 def _overwrite(ui, repo, files, expand):
   314 def _overwrite(ui, repo, files, expand):
   313     '''Expands/shrinks keywords in working directory.'''
   315     '''Expands/shrinks keywords in working directory.'''
   314     if not hasattr(ui, 'kwfmatcher'):
   316     if not hasattr(ui, 'kwfmatcher'):
   315         ui.warn(_('no files configured for keyword expansion\n'))
   317         ui.warn(_('%s\n') % _nokwfiles)
   316         return
   318         return
   317     bail_if_changed(repo)
   319     bail_if_changed(repo)
   318     wlock = lock = None
   320     wlock = lock = None
   319     try:
   321     try:
   320         wlock = repo.wlock()
   322         wlock = repo.wlock()
   354     '''print files currently configured for keyword expansion
   356     '''print files currently configured for keyword expansion
   355 
   357 
   356     Crosscheck which files in working directory
   358     Crosscheck which files in working directory
   357     are matched by [keyword] config patterns.
   359     are matched by [keyword] config patterns.
   358     '''
   360     '''
   359     if hasattr(ui, 'kwfmatcher'):
   361     if not hasattr(ui, 'kwfmatcher'):
   360         ctx = repo.workingctx()
   362         ui.note(_('%s\n') % _nokwfiles)
   361         man = ctx.manifest().copy()
   363         return
   362         for f in ctx.unknown():
   364     ctx = repo.workingctx()
   363             del man[f]
   365     man = ctx.manifest().copy()
   364         files = _weedcandidates(ui, man, None)
   366     for f in ctx.unknown():
   365         files.sort()
   367         del man[f]
   366         ui.write('\n'.join(files) + '\n')
   368     files = _weedcandidates(ui, man, None)
       
   369     files.sort()
       
   370     ui.write('\n'.join(files) + '\n')
   367 
   371 
   368 def demo(ui, repo, *args, **opts):
   372 def demo(ui, repo, *args, **opts):
   369     '''print [keywordmaps] configuration and an expansion example
   373     '''print [keywordmaps] configuration and an expansion example
   370 
   374 
   371     Show current, custom, or default keyword template maps
   375     Show current, custom, or default keyword template maps