hgkw/keyword.py
branchsolo-extension
changeset 64 4cd7b993c5f8
parent 63 5455c45db625
child 65 188849659487
equal deleted inserted replaced
63:5455c45db625 64:4cd7b993c5f8
    46     [hooks]
    46     [hooks]
    47     pretxncommit =
    47     pretxncommit =
    48     pretxncommit.keyword = python:hgext.keyword.pretxnkw
    48     pretxncommit.keyword = python:hgext.keyword.pretxnkw
    49 '''
    49 '''
    50 
    50 
    51 from mercurial.i18n import _
    51 from mercurial import context, util
    52 from mercurial import cmdutil, commands, context, filelog, revlog, util
    52 import os.path, re
    53 import os.path, re, sys
       
    54 
    53 
    55 
    54 
    56 re_kw = re.compile(
    55 re_kw = re.compile(
    57         r'\$(Id|Header|Author|Date|Revision|RCSFile|Source)[^$]*?\$')
    56         r'\$(Id|Header|Author|Date|Revision|RCSFile|Source)[^$]*?\$')
    58 
    57 
    79 
    78 
    80     return '$%s: %s $' % (matchobj.group(1), eval(matchobj.group(1)))
    79     return '$%s: %s $' % (matchobj.group(1), eval(matchobj.group(1)))
    81 
    80 
    82 
    81 
    83 def reposetup(ui, repo):
    82 def reposetup(ui, repo):
       
    83     from mercurial import filelog, revlog
       
    84 
    84     if not repo.local():
    85     if not repo.local():
    85         return
    86         return
    86 
    87 
    87     class kwrepo(repo.__class__):
    88     class kwrepo(repo.__class__):
    88         def file(self, f):
    89         def file(self, f):
   134 
   135 
   135 
   136 
   136 def pretxnkw(ui, repo, hooktype, **args):
   137 def pretxnkw(ui, repo, hooktype, **args):
   137     '''pretxncommit hook that collects candidates for keyword expansion
   138     '''pretxncommit hook that collects candidates for keyword expansion
   138     on commit and expands keywords in working dir.'''
   139     on commit and expands keywords in working dir.'''
       
   140     from mercurial.i18n import _
       
   141     from mercurial import cmdutil, commands
       
   142     import sys
   139 
   143 
   140     if hooktype != 'pretxncommit':
   144     if hooktype != 'pretxncommit':
   141         return True
   145         return True
   142 
   146 
   143     cmd, sysargs, globalopts, cmdopts = commands.parse(ui, sys.argv[1:])[1:]
   147     cmd, sysargs, globalopts, cmdopts = commands.parse(ui, sys.argv[1:])[1:]