hgkw/keyword.py
changeset 837 448a71a24a84
parent 836 53a9228f13de
child 838 c793c1a87f1c
equal deleted inserted replaced
836:53a9228f13de 837:448a71a24a84
   192     def iskwfile(self, cand, ctx):
   192     def iskwfile(self, cand, ctx):
   193         '''Returns subset of candidates which are configured for keyword
   193         '''Returns subset of candidates which are configured for keyword
   194         expansion are not symbolic links.'''
   194         expansion are not symbolic links.'''
   195         return [f for f in cand if self.match(f) and not 'l' in ctx.flags(f)]
   195         return [f for f in cand if self.match(f) and not 'l' in ctx.flags(f)]
   196 
   196 
   197     def overwrite(self, ctx, candidates, lookup, expand, recsubn=None):
   197     def overwrite(self, ctx, candidates, lookup, expand, rekw=False):
   198         '''Overwrites selected files expanding/shrinking keywords.'''
   198         '''Overwrites selected files expanding/shrinking keywords.'''
   199         if self.restrict or lookup: # exclude kw_copy
   199         if self.restrict or lookup: # exclude kw_copy
   200             candidates = self.iskwfile(candidates, ctx)
   200             candidates = self.iskwfile(candidates, ctx)
   201         if not candidates:
   201         if not candidates:
   202             return
   202             return
   203         commit = self.restrict and not lookup
   203         commit = self.restrict and not lookup
   204         if self.restrict or expand and lookup:
   204         if self.restrict or expand and lookup:
   205             mf = ctx.manifest()
   205             mf = ctx.manifest()
   206         fctx = ctx
   206         fctx = ctx
   207         subn = (self.restrict and self.re_kw.subn or
   207         subn = (self.restrict or rekw) and self.re_kw.subn or self.re_kwexp.subn
   208                 recsubn or self.re_kwexp.subn)
       
   209         msg = (expand and _('overwriting %s expanding keywords\n')
   208         msg = (expand and _('overwriting %s expanding keywords\n')
   210                or _('overwriting %s shrinking keywords\n'))
   209                or _('overwriting %s shrinking keywords\n'))
   211         for f in candidates:
   210         for f in candidates:
   212             if self.restrict:
   211             if self.restrict:
   213                 data = self.repo.file(f).read(mf[f])
   212                 data = self.repo.file(f).read(mf[f])
   576             if ctx != recctx:
   575             if ctx != recctx:
   577                 changed = recctx.files()
   576                 changed = recctx.files()
   578                 modified = [f for f in modified if f in changed]
   577                 modified = [f for f in modified if f in changed]
   579                 added = [f for f in added if f in changed]
   578                 added = [f for f in added if f in changed]
   580                 kwt.restrict = False
   579                 kwt.restrict = False
   581                 kwt.overwrite(recctx, modified, False, True, kwt.re_kwexp.subn)
   580                 kwt.overwrite(recctx, modified, False, True)
   582                 kwt.overwrite(recctx, added, False, True, kwt.re_kw.subn)
   581                 kwt.overwrite(recctx, added, False, True, True)
   583                 kwt.restrict = True
   582                 kwt.restrict = True
   584             return ret
   583             return ret
   585         finally:
   584         finally:
   586             wlock.release()
   585             wlock.release()
   587 
   586