hgkw/keyword.py
changeset 815 1c9959ca570a
parent 814 0588121c815b
child 816 00570f650792
equal deleted inserted replaced
814:0588121c815b 815:1c9959ca570a
   189         if not self.restrict and self.match(path) and not util.binary(data):
   189         if not self.restrict and self.match(path) and not util.binary(data):
   190             ctx = self.repo.filectx(path, fileid=node).changectx()
   190             ctx = self.repo.filectx(path, fileid=node).changectx()
   191             return self.substitute(data, path, ctx, self.re_kw.sub)
   191             return self.substitute(data, path, ctx, self.re_kw.sub)
   192         return data
   192         return data
   193 
   193 
   194     def iskwfile(self, path, flagfunc):
   194     def iskwfile(self, cand, ctx):
   195         '''Returns true if path matches [keyword] pattern
   195         '''Returns subset of candidates which are configured for keyword
   196         and is not a symbolic link.
   196         expansion are not symbolic links.'''
   197         Caveat: localrepository._link fails on Windows.'''
   197         return [f for f in cand if self.match(f) and not 'l' in ctx.flags(f)]
   198         return self.match(path) and not 'l' in flagfunc(path)
       
   199 
   198 
   200     def overwrite(self, ctx, candidates, lookup, expand):
   199     def overwrite(self, ctx, candidates, lookup, expand):
   201         '''Overwrites selected files expanding/shrinking keywords.'''
   200         '''Overwrites selected files expanding/shrinking keywords.'''
   202         if self.restrict or lookup: # exclude kw_copy
   201         if self.restrict or lookup: # exclude kw_copy
   203             candidates = [f for f in candidates if self.iskwfile(f, ctx.flags)]
   202             candidates = self.iskwfile(candidates, ctx)
   204         if not candidates:
   203         if not candidates:
   205             return
   204             return
   206         commit = self.restrict and not lookup
   205         commit = self.restrict and not lookup
   207         if self.restrict or expand and lookup:
   206         if self.restrict or expand and lookup:
   208             mf = ctx.manifest()
   207             mf = ctx.manifest()
   415     modified, added, removed, deleted, unknown, ignored, clean = status
   414     modified, added, removed, deleted, unknown, ignored, clean = status
   416     files = []
   415     files = []
   417     if not opts.get('unknown') or opts.get('all'):
   416     if not opts.get('unknown') or opts.get('all'):
   418         files = sorted(modified + added + clean)
   417         files = sorted(modified + added + clean)
   419     wctx = repo[None]
   418     wctx = repo[None]
   420     kwfiles = [f for f in files if kwt.iskwfile(f, wctx.flags)]
   419     kwfiles = kwt.iskwfile(files, wctx)
   421     kwunknown = [f for f in unknown if kwt.iskwfile(f, wctx.flags)]
   420     kwunknown = kwt.iskwfile(unknown, wctx)
   422     if not opts.get('ignore') or opts.get('all'):
   421     if not opts.get('ignore') or opts.get('all'):
   423         showfiles = kwfiles, kwunknown
   422         showfiles = kwfiles, kwunknown
   424     else:
   423     else:
   425         showfiles = [], []
   424         showfiles = [], []
   426     if opts.get('all') or opts.get('ignore'):
   425     if opts.get('all') or opts.get('ignore'):