hgkw/keyword.py
changeset 286 0dac9b324b03
parent 285 0aa02d36b3b1
child 287 62eff490c844
equal deleted inserted replaced
285:0aa02d36b3b1 286:0dac9b324b03
   313 def _iskwfile(ui, man, f):
   313 def _iskwfile(ui, man, f):
   314     return not man.linkf(f) and ui.kwfmatcher(f)
   314     return not man.linkf(f) and ui.kwfmatcher(f)
   315 
   315 
   316 def _overwrite(ui, repo, files, node, man, expand, commit):
   316 def _overwrite(ui, repo, files, node, man, expand, commit):
   317     '''Passes given files to kwtemplater for overwriting.'''
   317     '''Passes given files to kwtemplater for overwriting.'''
   318     if files:
   318     files.sort()
   319         files.sort()
   319     kwt = kwtemplater(ui, repo, expand, node=node)
   320         kwt = kwtemplater(ui, repo, expand, node=node)
   320     kwt.overwrite(files, man, commit)
   321         kwt.overwrite(files, man, commit)
       
   322 
   321 
   323 def _kwfwrite(ui, repo, expand, *pats, **opts):
   322 def _kwfwrite(ui, repo, expand, *pats, **opts):
   324     '''Selects files and passes them to _overwrite.'''
   323     '''Selects files and passes them to _overwrite.'''
   325     status = _status(ui, repo, *pats, **opts)
   324     status = _status(ui, repo, *pats, **opts)
   326     modified, added, removed, deleted, unknown, ignored, clean = status
   325     modified, added, removed, deleted, unknown, ignored, clean = status
   331         wlock = repo.wlock()
   330         wlock = repo.wlock()
   332         lock = repo.lock()
   331         lock = repo.lock()
   333         ctx = repo.changectx()
   332         ctx = repo.changectx()
   334         man = ctx.manifest()
   333         man = ctx.manifest()
   335         candidates = [f for f in clean if _iskwfile(ui, man, f)]
   334         candidates = [f for f in clean if _iskwfile(ui, man, f)]
   336         # 7th argument sets commit to False
   335         if candidates:
   337         _overwrite(ui, repo, candidates, ctx.node(), man, expand, False)
   336             # 7th argument sets commit to False
       
   337             _overwrite(ui, repo, candidates, ctx.node(), man, expand, False)
   338     finally:
   338     finally:
   339         del wlock, lock
   339         del wlock, lock
   340 
   340 
   341 
   341 
   342 def demo(ui, repo, *args, **opts):
   342 def demo(ui, repo, *args, **opts):
   540                 if node is not None:
   540                 if node is not None:
   541                     cl = self.changelog.read(node)
   541                     cl = self.changelog.read(node)
   542                     mn = self.manifest.read(cl[0])
   542                     mn = self.manifest.read(cl[0])
   543                     candidates = [f for f in cl[3] if mn.has_key(f)
   543                     candidates = [f for f in cl[3] if mn.has_key(f)
   544                                   and _iskwfile(ui, mn, f)]
   544                                   and _iskwfile(ui, mn, f)]
   545                     # 6th, 7th arguments set expansion, commit to True
   545                     if candidates:
   546                     _overwrite(ui, self, candidates, node, mn, True, True)
   546                         # 6th, 7th arguments set expansion, commit to True
       
   547                         _overwrite(ui, self, candidates, node, mn, True, True)
   547                 return node
   548                 return node
   548             finally:
   549             finally:
   549                 del _wlock, _lock
   550                 del _wlock, _lock
   550 
   551 
   551     repo.__class__ = kwrepo
   552     repo.__class__ = kwrepo