hgkw/keyword.py
changeset 973 82015736cc7e
parent 968 8d821e2fed38
child 979 6cabb1c47f21
equal deleted inserted replaced
972:0d4e44410b4d 973:82015736cc7e
   320     def cmp(self, node, text):
   320     def cmp(self, node, text):
   321         '''Removes keyword substitutions for comparison.'''
   321         '''Removes keyword substitutions for comparison.'''
   322         text = self.kwt.shrink(self.path, text)
   322         text = self.kwt.shrink(self.path, text)
   323         return super(kwfilelog, self).cmp(node, text)
   323         return super(kwfilelog, self).cmp(node, text)
   324 
   324 
   325 def _status(ui, repo, kwt, *pats, **opts):
   325 def _status(ui, repo, wctx, kwt, *pats, **opts):
   326     '''Bails out if [keyword] configuration is not active.
   326     '''Bails out if [keyword] configuration is not active.
   327     Returns status of working directory.'''
   327     Returns status of working directory.'''
   328     if kwt:
   328     if kwt:
   329         return repo.status(match=scmutil.match(repo[None], pats, opts), clean=True,
   329         return repo.status(match=scmutil.match(wctx, pats, opts), clean=True,
   330                            unknown=opts.get('unknown') or opts.get('all'))
   330                            unknown=opts.get('unknown') or opts.get('all'))
   331     if ui.configitems('keyword'):
   331     if ui.configitems('keyword'):
   332         raise util.Abort(_('[keyword] patterns cannot match'))
   332         raise util.Abort(_('[keyword] patterns cannot match'))
   333     raise util.Abort(_('no [keyword] patterns configured'))
   333     raise util.Abort(_('no [keyword] patterns configured'))
   334 
   334 
   338     if len(wctx.parents()) > 1:
   338     if len(wctx.parents()) > 1:
   339         raise util.Abort(_('outstanding uncommitted merge'))
   339         raise util.Abort(_('outstanding uncommitted merge'))
   340     kwt = kwtools['templater']
   340     kwt = kwtools['templater']
   341     wlock = repo.wlock()
   341     wlock = repo.wlock()
   342     try:
   342     try:
   343         status = _status(ui, repo, kwt, *pats, **opts)
   343         status = _status(ui, repo, wctx, kwt, *pats, **opts)
   344         modified, added, removed, deleted, unknown, ignored, clean = status
   344         modified, added, removed, deleted, unknown, ignored, clean = status
   345         if modified or added or removed or deleted:
   345         if modified or added or removed or deleted:
   346             raise util.Abort(_('outstanding uncommitted changes'))
   346             raise util.Abort(_('outstanding uncommitted changes'))
   347         kwt.overwrite(wctx, clean, True, expand)
   347         kwt.overwrite(wctx, clean, True, expand)
   348     finally:
   348     finally:
   473       k = keyword expansion candidate (not tracked)
   473       k = keyword expansion candidate (not tracked)
   474       I = ignored
   474       I = ignored
   475       i = ignored (not tracked)
   475       i = ignored (not tracked)
   476     '''
   476     '''
   477     kwt = kwtools['templater']
   477     kwt = kwtools['templater']
   478     status = _status(ui, repo, kwt, *pats, **opts)
   478     wctx = repo[None]
       
   479     status = _status(ui, repo, wctx, kwt, *pats, **opts)
   479     cwd = pats and repo.getcwd() or ''
   480     cwd = pats and repo.getcwd() or ''
   480     modified, added, removed, deleted, unknown, ignored, clean = status
   481     modified, added, removed, deleted, unknown, ignored, clean = status
   481     files = []
   482     files = []
   482     if not opts.get('unknown') or opts.get('all'):
   483     if not opts.get('unknown') or opts.get('all'):
   483         files = sorted(modified + added + clean)
   484         files = sorted(modified + added + clean)
   484     wctx = repo[None]
       
   485     kwfiles = kwt.iskwfile(files, wctx)
   485     kwfiles = kwt.iskwfile(files, wctx)
   486     kwdeleted = kwt.iskwfile(deleted, wctx)
   486     kwdeleted = kwt.iskwfile(deleted, wctx)
   487     kwunknown = kwt.iskwfile(unknown, wctx)
   487     kwunknown = kwt.iskwfile(unknown, wctx)
   488     if not opts.get('ignore') or opts.get('all'):
   488     if not opts.get('ignore') or opts.get('all'):
   489         showfiles = kwfiles, kwdeleted, kwunknown
   489         showfiles = kwfiles, kwdeleted, kwunknown