hgkw/keyword.py
changeset 441 4bf8ea03d7ac
parent 440 856fde439a0a
child 442 1bb9230b055d
equal deleted inserted replaced
440:856fde439a0a 441:4bf8ea03d7ac
   169         '''Returns true if path matches [keyword] pattern
   169         '''Returns true if path matches [keyword] pattern
   170         and is not a symbolic link.
   170         and is not a symbolic link.
   171         Caveat: localrepository._link fails on Windows.'''
   171         Caveat: localrepository._link fails on Windows.'''
   172         return self.matcher(path) and not islink(path)
   172         return self.matcher(path) and not islink(path)
   173 
   173 
   174     def overwrite(self, node=None, expand=True, files=None):
   174     def overwrite(self, node, expand, files):
   175         '''Overwrites selected files expanding/shrinking keywords.'''
   175         '''Overwrites selected files expanding/shrinking keywords.'''
   176         ctx = self.repo.changectx(node)
   176         ctx = self.repo.changectx(node)
   177         mf = ctx.manifest()
   177         mf = ctx.manifest()
   178         if node is not None:     # commit
   178         if node is not None:     # commit
   179             files = [f for f in ctx.files() if f in mf]
   179             files = [f for f in ctx.files() if f in mf]
   272         raise util.Abort(_('outstanding uncommitted changes in given files'))
   272         raise util.Abort(_('outstanding uncommitted changes in given files'))
   273     wlock = lock = None
   273     wlock = lock = None
   274     try:
   274     try:
   275         wlock = repo.wlock()
   275         wlock = repo.wlock()
   276         lock = repo.lock()
   276         lock = repo.lock()
   277         kwt.overwrite(expand=expand, files=clean)
   277         kwt.overwrite(None, expand, clean)
   278     finally:
   278     finally:
   279         del wlock, lock
   279         del wlock, lock
   280 
   280 
   281 
   281 
   282 def demo(ui, repo, *args, **opts):
   282 def demo(ui, repo, *args, **opts):
   489 
   489 
   490                 # restore commit hooks
   490                 # restore commit hooks
   491                 for name, cmd in commithooks.iteritems():
   491                 for name, cmd in commithooks.iteritems():
   492                     ui.setconfig('hooks', name, cmd)
   492                     ui.setconfig('hooks', name, cmd)
   493                 if n is not None:
   493                 if n is not None:
   494                     kwt.overwrite(node=n)
   494                     kwt.overwrite(n, True, None)
   495                     repo.hook('commit', node=n, parent1=_p1, parent2=_p2)
   495                     repo.hook('commit', node=n, parent1=_p1, parent2=_p2)
   496                 return n
   496                 return n
   497             finally:
   497             finally:
   498                 del wlock, lock
   498                 del wlock, lock
   499 
   499