hgkw/keyword.py
branchstable
changeset 1073 bc8e57c1ae32
parent 1042 91e083fab1a3
child 1075 9c31017cb4b2
equal deleted inserted replaced
1072:bbf056e756cc 1073:bc8e57c1ae32
   236         return data
   236         return data
   237 
   237 
   238     def iskwfile(self, cand, ctx):
   238     def iskwfile(self, cand, ctx):
   239         '''Returns subset of candidates which are configured for keyword
   239         '''Returns subset of candidates which are configured for keyword
   240         expansion but are not symbolic links.'''
   240         expansion but are not symbolic links.'''
   241         return [f for f in cand if self.match(f) and not 'l' in ctx.flags(f)]
   241         return [f for f in cand if self.match(f) and 'l' not in ctx.flags(f)]
   242 
   242 
   243     def overwrite(self, ctx, candidates, lookup, expand, rekw=False):
   243     def overwrite(self, ctx, candidates, lookup, expand, rekw=False):
   244         '''Overwrites selected files expanding/shrinking keywords.'''
   244         '''Overwrites selected files expanding/shrinking keywords.'''
   245         if self.restrict or lookup or self.record: # exclude kw_copy
   245         if self.restrict or lookup or self.record: # exclude kw_copy
   246             candidates = self.iskwfile(candidates, ctx)
   246             candidates = self.iskwfile(candidates, ctx)
   649                 source = scmutil.canonpath(repo.root, cwd,
   649                 source = scmutil.canonpath(repo.root, cwd,
   650                                            os.path.realpath(source))
   650                                            os.path.realpath(source))
   651             return kwt.match(source)
   651             return kwt.match(source)
   652 
   652 
   653         candidates = [f for f in repo.dirstate.copies() if
   653         candidates = [f for f in repo.dirstate.copies() if
   654                       not 'l' in wctx.flags(f) and haskwsource(f)]
   654                       'l' not in wctx.flags(f) and haskwsource(f)]
   655         kwt.overwrite(wctx, candidates, False, False)
   655         kwt.overwrite(wctx, candidates, False, False)
   656 
   656 
   657     def kw_dorecord(orig, ui, repo, commitfunc, *pats, **opts):
   657     def kw_dorecord(orig, ui, repo, commitfunc, *pats, **opts):
   658         '''Wraps record.dorecord expanding keywords after recording.'''
   658         '''Wraps record.dorecord expanding keywords after recording.'''
   659         wlock = repo.wlock()
   659         wlock = repo.wlock()
   678     def kwfilectx_cmp(orig, self, fctx):
   678     def kwfilectx_cmp(orig, self, fctx):
   679         # keyword affects data size, comparing wdir and filelog size does
   679         # keyword affects data size, comparing wdir and filelog size does
   680         # not make sense
   680         # not make sense
   681         if (fctx._filerev is None and
   681         if (fctx._filerev is None and
   682             (self._repo._encodefilterpats or
   682             (self._repo._encodefilterpats or
   683              kwt.match(fctx.path()) and not 'l' in fctx.flags() or
   683              kwt.match(fctx.path()) and 'l' not in fctx.flags() or
   684              self.size() - 4 == fctx.size()) or
   684              self.size() - 4 == fctx.size()) or
   685             self.size() == fctx.size()):
   685             self.size() == fctx.size()):
   686             return self._filelog.cmp(self._filenode, fctx.data())
   686             return self._filelog.cmp(self._filenode, fctx.data())
   687         return True
   687         return True
   688 
   688