hgext/keyword.py
changeset 33070 735218be6122
parent 33069 ed92a4960874
child 33071 279c072a5c49
equal deleted inserted replaced
33069:ed92a4960874 33070:735218be6122
   163     11:00:13Z".
   163     11:00:13Z".
   164     '''
   164     '''
   165     return util.datestr((util.parsedate(text)[0], 0), '%Y-%m-%d %H:%M:%SZ')
   165     return util.datestr((util.parsedate(text)[0], 0), '%Y-%m-%d %H:%M:%SZ')
   166 
   166 
   167 # make keyword tools accessible
   167 # make keyword tools accessible
   168 kwtools = {'templater': None, 'hgcmd': ''}
   168 kwtools = {'hgcmd': ''}
   169 
   169 
   170 def _defaultkwmaps(ui):
   170 def _defaultkwmaps(ui):
   171     '''Returns default keywordmaps according to keywordset configuration.'''
   171     '''Returns default keywordmaps according to keywordset configuration.'''
   172     templates = {
   172     templates = {
   173         'Revision': '{node|short}',
   173         'Revision': '{node|short}',
   383 def _kwfwrite(ui, repo, expand, *pats, **opts):
   383 def _kwfwrite(ui, repo, expand, *pats, **opts):
   384     '''Selects files and passes them to kwtemplater.overwrite.'''
   384     '''Selects files and passes them to kwtemplater.overwrite.'''
   385     wctx = repo[None]
   385     wctx = repo[None]
   386     if len(wctx.parents()) > 1:
   386     if len(wctx.parents()) > 1:
   387         raise error.Abort(_('outstanding uncommitted merge'))
   387         raise error.Abort(_('outstanding uncommitted merge'))
   388     kwt = kwtools['templater']
   388     kwt = getattr(repo, '_keywordkwt', None)
   389     with repo.wlock():
   389     with repo.wlock():
   390         status = _status(ui, repo, wctx, kwt, *pats, **opts)
   390         status = _status(ui, repo, wctx, kwt, *pats, **opts)
   391         if status.modified or status.added or status.removed or status.deleted:
   391         if status.modified or status.added or status.removed or status.deleted:
   392             raise error.Abort(_('outstanding uncommitted changes'))
   392             raise error.Abort(_('outstanding uncommitted changes'))
   393         kwt.overwrite(wctx, status.clean, True, expand)
   393         kwt.overwrite(wctx, status.clean, True, expand)
   527       K = keyword expansion candidate
   527       K = keyword expansion candidate
   528       k = keyword expansion candidate (not tracked)
   528       k = keyword expansion candidate (not tracked)
   529       I = ignored
   529       I = ignored
   530       i = ignored (not tracked)
   530       i = ignored (not tracked)
   531     '''
   531     '''
   532     kwt = kwtools['templater']
   532     kwt = getattr(repo, '_keywordkwt', None)
   533     wctx = repo[None]
   533     wctx = repo[None]
   534     status = _status(ui, repo, wctx, kwt, *pats, **opts)
   534     status = _status(ui, repo, wctx, kwt, *pats, **opts)
   535     if pats:
   535     if pats:
   536         cwd = repo.getcwd()
   536         cwd = repo.getcwd()
   537     else:
   537     else:
   612         else:
   612         else:
   613             exc.append(pat)
   613             exc.append(pat)
   614     if not inc:
   614     if not inc:
   615         return
   615         return
   616 
   616 
   617     kwtools['templater'] = kwt = kwtemplater(ui, repo, inc, exc)
   617     kwt = kwtemplater(ui, repo, inc, exc)
   618 
   618 
   619     class kwrepo(repo.__class__):
   619     class kwrepo(repo.__class__):
   620         def file(self, f):
   620         def file(self, f):
   621             if f[0] == '/':
   621             if f[0] == '/':
   622                 f = f[1:]
   622                 f = f[1:]