hgkw/keyword.py
changeset 243 bbd5af3ec247
parent 242 71056c5042de
child 244 e449107a0501
equal deleted inserted replaced
242:71056c5042de 243:bbd5af3ec247
   339             files = [util.canonpath(repo.root, cwd, f) for f in files]
   339             files = [util.canonpath(repo.root, cwd, f) for f in files]
   340         files = _weedcandidates(man, kwfmatcher, files)
   340         files = _weedcandidates(man, kwfmatcher, files)
   341         if not files:
   341         if not files:
   342             ui.warn(_('files not configured for expansion or untracked\n'))
   342             ui.warn(_('files not configured for expansion or untracked\n'))
   343             return
   343             return
   344         commit = False
       
   345         kwt = kwtemplater(ui, repo, expand, node=ctx.node())
   344         kwt = kwtemplater(ui, repo, expand, node=ctx.node())
   346         kwt.overwrite(files, man, commit)
   345         # 3rd argument sets commit to False
       
   346         kwt.overwrite(files, man, False)
   347     finally:
   347     finally:
   348         del wlock, lock
   348         del wlock, lock
   349 
   349 
   350 
   350 
   351 def shrink(ui, repo, *args):
   351 def shrink(ui, repo, *args):
   352     '''revert expanded keywords in working directory
   352     '''revert expanded keywords in working directory
   353 
   353 
   354     run before changing/disabling active keywords
   354     run before changing/disabling active keywords
   355     or if you experience problems with "hg import" or "hg merge"
   355     or if you experience problems with "hg import" or "hg merge"
   356     '''
   356     '''
   357     expand = False
   357     # 4th argument sets expansion to False
   358     _overwrite(ui, repo, args, expand)
   358     _overwrite(ui, repo, args, False)
   359 
   359 
   360 def expand(ui, repo, *args):
   360 def expand(ui, repo, *args):
   361     '''expand keywords in working directory
   361     '''expand keywords in working directory
   362 
   362 
   363     run after (re)enabling keyword expansion
   363     run after (re)enabling keyword expansion
   364     '''
   364     '''
   365     expand = True
   365     # 4th argument sets expansion to True
   366     _overwrite(ui, repo, args, expand)
   366     _overwrite(ui, repo, args, True)
   367 
   367 
   368 def demo(ui, repo, *args, **opts):
   368 def demo(ui, repo, *args, **opts):
   369     '''print [keywordmaps] configuration and an expansion example
   369     '''print [keywordmaps] configuration and an expansion example
   370 
   370 
   371     show current, custom, or default keyword template maps and their expansion
   371     show current, custom, or default keyword template maps and their expansion
   507                 if node is not None:
   507                 if node is not None:
   508                     cl = self.changelog.read(node)
   508                     cl = self.changelog.read(node)
   509                     mn = self.manifest.read(cl[0])
   509                     mn = self.manifest.read(cl[0])
   510                     candidates = _weedcandidates(mn, kwfmatcher, cl[3])
   510                     candidates = _weedcandidates(mn, kwfmatcher, cl[3])
   511                     if candidates:
   511                     if candidates:
   512                         expand = commit = True
   512                         # 3rd argument sets expansion to True
   513                         kwt = kwtemplater(ui, self, expand, node=node)
   513                         kwt = kwtemplater(ui, self, True, node=node)
   514                         kwt.overwrite(candidates, mn, commit)
   514                         # 3rd argument sets commit to True
       
   515                         kwt.overwrite(candidates, mn, True)
   515                 return node
   516                 return node
   516             finally:
   517             finally:
   517                 del _wlock, _lock
   518                 del _wlock, _lock
   518 
   519 
   519     repo.__class__ = kwrepo
   520     repo.__class__ = kwrepo