hgkw/keyword.py
branchkwmap-templates
changeset 156 0382bccf861e
parent 155 b62dacbd2166
child 158 900a9e4d7f82
equal deleted inserted replaced
155:b62dacbd2166 156:0382bccf861e
    87 
    87 
    88 try:
    88 try:
    89     from mercurial.demandload import * # stable
    89     from mercurial.demandload import * # stable
    90     from mercurial.i18n import gettext as _
    90     from mercurial.i18n import gettext as _
    91     demandload(globals(), 'mercurial:commands,fancyopts,templater,util')
    91     demandload(globals(), 'mercurial:commands,fancyopts,templater,util')
    92     demandload(globals(), 'mercurial:cmdutil,context,filelog,revlog')
    92     demandload(globals(), 'mercurial:cmdutil,context,filelog')
    93     demandload(globals(), 'os re sys time')
    93     demandload(globals(), 'os re sys time')
    94 except ImportError:                    # demandimport
    94 except ImportError:                    # demandimport
    95     from mercurial.i18n import _
    95     from mercurial.i18n import _
    96     from mercurial import commands, fancyopts, templater, util
    96     from mercurial import commands, fancyopts, templater, util
    97     from mercurial import cmdutil, context, filelog, revlog
    97     from mercurial import cmdutil, context, filelog
    98     import os, re, sys, time
    98     import os, re, sys, time
    99 
    99 
   100 deftemplates = {
   100 deftemplates = {
   101         'Revision': '{node|short}',
   101         'Revision': '{node|short}',
   102         'Author': '{author|user}',
   102         'Author': '{author|user}',
   190 class kwfilelog(filelog.filelog):
   190 class kwfilelog(filelog.filelog):
   191     '''
   191     '''
   192     Superclass over filelog to customize its read, add, cmp methods.
   192     Superclass over filelog to customize its read, add, cmp methods.
   193     Keywords are "stored" unexpanded, and expanded on reading.
   193     Keywords are "stored" unexpanded, and expanded on reading.
   194     '''
   194     '''
   195     def __init__(self, opener, path, kwtemplater,
   195     def __init__(self, opener, path, kwtemplater):
   196                  defversion=revlog.REVLOG_DEFAULT_VERSION):
   196         super(kwfilelog, self).__init__(opener, path)
   197         super(kwfilelog, self).__init__(opener, path, defversion)
       
   198         self.path = path
   197         self.path = path
   199         self.kwtemplater = kwtemplater
   198         self.kwtemplater = kwtemplater
   200 
   199 
   201     def read(self, node):
   200     def read(self, node):
   202         '''Substitutes keywords when reading filelog.'''
   201         '''Substitutes keywords when reading filelog.'''
   251             if f[0] == '/':
   250             if f[0] == '/':
   252                 f = f[1:]
   251                 f = f[1:]
   253             # only use kwfilelog when needed
   252             # only use kwfilelog when needed
   254             if self.kwfmatcher(f):
   253             if self.kwfmatcher(f):
   255                 kwt = kwtemplater(self.ui, self)
   254                 kwt = kwtemplater(self.ui, self)
   256                 return kwfilelog(self.sopener, f, kwt, self.revlogversion)
   255                 return kwfilelog(self.sopener, f, kwt)
   257             else:
   256             else:
   258                 return filelog.filelog(self.sopener, f, self.revlogversion)
   257                 return filelog.filelog(self.sopener, f)
   259 
   258 
   260         def commit(self, files=None, text="", user=None, date=None,
   259         def commit(self, files=None, text="", user=None, date=None,
   261                 match=util.always, force=False, lock=None, wlock=None,
   260                 match=util.always, force=False, lock=None, wlock=None,
   262                 force_editor=False, p1=None, p2=None, extra={}):
   261                 force_editor=False, p1=None, p2=None, extra={}):
   263             '''Wraps commit, expanding keywords of committed and
   262             '''Wraps commit, expanding keywords of committed and