hgkw/keyword.py
changeset 310 574128f982a2
parent 309 a5f5bbf4a668
child 314 d9f84b36de26
equal deleted inserted replaced
309:a5f5bbf4a668 310:574128f982a2
   110     }
   110     }
   111 
   111 
   112     def __init__(self, ui, repo, inc, exc):
   112     def __init__(self, ui, repo, inc, exc):
   113         self.ui = ui
   113         self.ui = ui
   114         self.repo = repo
   114         self.repo = repo
   115         self.match = util.matcher(repo.root, inc=inc, exc=exc)[1]
   115         self.matcher = util.matcher(repo.root, inc=inc, exc=exc)[1]
   116         self.node = None
   116         self.node = None
   117         self.path = ''
   117         self.path = ''
   118 
   118 
   119         kwmaps = self.ui.configitems('keywordmaps')
   119         kwmaps = self.ui.configitems('keywordmaps')
   120         if kwmaps: # override default templates
   120         if kwmaps: # override default templates
   201         if self.renamed(node):
   201         if self.renamed(node):
   202             t2 = super(kwfilelog, self).read(node)
   202             t2 = super(kwfilelog, self).read(node)
   203             return t2 != text
   203             return t2 != text
   204         return revlog.revlog.cmp(self, node, text)
   204         return revlog.revlog.cmp(self, node, text)
   205 
   205 
       
   206 def _iskwfile(f, kwtemplater, link):
       
   207     return not link(f) and kwtemplater.matcher(f)
       
   208 
   206 def _status(ui, repo, kwtemplater, *pats, **opts):
   209 def _status(ui, repo, kwtemplater, *pats, **opts):
   207     '''Bails out if [keyword] configuration is not active.
   210     '''Bails out if [keyword] configuration is not active.
   208     Returns status of working directory.'''
   211     Returns status of working directory.'''
   209     if kwtemplater:
   212     if kwtemplater:
   210         files, match, anypats = cmdutil.matchpats(repo, pats, opts)
   213         files, match, anypats = cmdutil.matchpats(repo, pats, opts)
   220     if files is None:
   223     if files is None:
   221         notify = ui.debug # commit
   224         notify = ui.debug # commit
   222         files = [f for f in ctx.files() if mf.has_key(f)]
   225         files = [f for f in ctx.files() if mf.has_key(f)]
   223     else:
   226     else:
   224         notify = ui.note  # kwexpand/kwshrink
   227         notify = ui.note  # kwexpand/kwshrink
   225     candidates = [f for f in files if not mf.linkf(f) and kwtemplater.match(f)]
   228     candidates = [f for f in files if _iskwfile(f, kwtemplater, mf.linkf)]
   226     if candidates:
   229     if candidates:
   227         candidates.sort()
   230         candidates.sort()
   228         action = expand and 'expanding' or 'shrinking'
   231         action = expand and 'expanding' or 'shrinking'
   229         kwtemplater.node = node or ctx.node()
   232         kwtemplater.node = node or ctx.node()
   230         for f in candidates:
   233         for f in candidates:
   355     if opts['untracked']:
   358     if opts['untracked']:
   356         files = modified + added + unknown + clean
   359         files = modified + added + unknown + clean
   357     else:
   360     else:
   358         files = modified + added + clean
   361         files = modified + added + clean
   359     files.sort()
   362     files.sort()
   360     kwfiles = [f for f in files if _kwtemplater.match(f) and not repo._link(f)]
   363     kwfiles = [f for f in files if _iskwfile(f, _kwtemplater, repo._link)]
   361     cwd = pats and repo.getcwd() or ''
   364     cwd = pats and repo.getcwd() or ''
   362     allf = opts['all']
   365     allf = opts['all']
   363     ignore = opts['ignore']
   366     ignore = opts['ignore']
   364     if ignore:
   367     if ignore:
   365         kwfstats = ()
   368         kwfstats = ()
   421 
   424 
   422     class kwrepo(repo.__class__):
   425     class kwrepo(repo.__class__):
   423         def file(self, f, kwmatch=False):
   426         def file(self, f, kwmatch=False):
   424             if f[0] == '/':
   427             if f[0] == '/':
   425                 f = f[1:]
   428                 f = f[1:]
   426             if kwmatch or _kwtemplater.match(f):
   429             if kwmatch or _kwtemplater.matcher(f):
   427                 return kwfilelog(self.sopener, f, _kwtemplater)
   430                 return kwfilelog(self.sopener, f, _kwtemplater)
   428             return filelog.filelog(self.sopener, f)
   431             return filelog.filelog(self.sopener, f)
   429 
   432 
   430         def commit(self, files=None, text='', user=None, date=None,
   433         def commit(self, files=None, text='', user=None, date=None,
   431                    match=util.always, force=False, force_editor=False,
   434                    match=util.always, force=False, force_editor=False,