hgkw/keyword.py
author Christian Ebert <blacktrash@gmx.net>
Thu, 21 Dec 2006 16:58:28 +0100
branchsolo-extension
changeset 47 0617e7d497f6
parent 44 dc6e7d0e607f
child 48 59fedb6b41da
permissions -rw-r--r--
Branch standalone extension, including pretxncommit hook function Slower, but easier to integrate.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
47
0617e7d497f6 Branch standalone extension, including pretxncommit hook function
Christian Ebert <blacktrash@gmx.net>
parents: 44
diff changeset
     1
from mercurial.i18n import _
0617e7d497f6 Branch standalone extension, including pretxncommit hook function
Christian Ebert <blacktrash@gmx.net>
parents: 44
diff changeset
     2
from mercurial import commands, cmdutil, context, filelog, revlog, util
0617e7d497f6 Branch standalone extension, including pretxncommit hook function
Christian Ebert <blacktrash@gmx.net>
parents: 44
diff changeset
     3
import os.path, re, sys
0617e7d497f6 Branch standalone extension, including pretxncommit hook function
Christian Ebert <blacktrash@gmx.net>
parents: 44
diff changeset
     4
0617e7d497f6 Branch standalone extension, including pretxncommit hook function
Christian Ebert <blacktrash@gmx.net>
parents: 44
diff changeset
     5
# supported keywords for use in regexes
0617e7d497f6 Branch standalone extension, including pretxncommit hook function
Christian Ebert <blacktrash@gmx.net>
parents: 44
diff changeset
     6
hgkeywords = 'Id|Header|Author|Date|Revision|RCSFile|Source'
0617e7d497f6 Branch standalone extension, including pretxncommit hook function
Christian Ebert <blacktrash@gmx.net>
parents: 44
diff changeset
     7
0617e7d497f6 Branch standalone extension, including pretxncommit hook function
Christian Ebert <blacktrash@gmx.net>
parents: 44
diff changeset
     8
def kwexpand(matchobj, repo, Revision, f, date, Author):
0617e7d497f6 Branch standalone extension, including pretxncommit hook function
Christian Ebert <blacktrash@gmx.net>
parents: 44
diff changeset
     9
    '''Called by kwfilelog.read and pretxnkw.
0617e7d497f6 Branch standalone extension, including pretxncommit hook function
Christian Ebert <blacktrash@gmx.net>
parents: 44
diff changeset
    10
    Sets supported keywords as local variables and evaluates them to
0617e7d497f6 Branch standalone extension, including pretxncommit hook function
Christian Ebert <blacktrash@gmx.net>
parents: 44
diff changeset
    11
    their expansion if matchobj is equal to string representation.'''
33
ebb39c6a1476 Add original keyword extension by Thomas Arendsen Hain
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
    12
47
0617e7d497f6 Branch standalone extension, including pretxncommit hook function
Christian Ebert <blacktrash@gmx.net>
parents: 44
diff changeset
    13
    RCSFile = os.path.basename(f)+',v'
0617e7d497f6 Branch standalone extension, including pretxncommit hook function
Christian Ebert <blacktrash@gmx.net>
parents: 44
diff changeset
    14
    Source = os.path.join(repo.root, f)+',v'
0617e7d497f6 Branch standalone extension, including pretxncommit hook function
Christian Ebert <blacktrash@gmx.net>
parents: 44
diff changeset
    15
    Date = util.datestr(date=date)
0617e7d497f6 Branch standalone extension, including pretxncommit hook function
Christian Ebert <blacktrash@gmx.net>
parents: 44
diff changeset
    16
    revdateauth = '%s %s %s' % (Revision,       # %Y-%m-%d %H:%M:%S
0617e7d497f6 Branch standalone extension, including pretxncommit hook function
Christian Ebert <blacktrash@gmx.net>
parents: 44
diff changeset
    17
            util.datestr(date=date, format=util.defaultdateformats[0]),
0617e7d497f6 Branch standalone extension, including pretxncommit hook function
Christian Ebert <blacktrash@gmx.net>
parents: 44
diff changeset
    18
            util.shortuser(Author))
0617e7d497f6 Branch standalone extension, including pretxncommit hook function
Christian Ebert <blacktrash@gmx.net>
parents: 44
diff changeset
    19
    Header = '%s %s' % (Source, revdateauth)
0617e7d497f6 Branch standalone extension, including pretxncommit hook function
Christian Ebert <blacktrash@gmx.net>
parents: 44
diff changeset
    20
    Id = '%s %s' % (RCSFile, revdateauth)
0617e7d497f6 Branch standalone extension, including pretxncommit hook function
Christian Ebert <blacktrash@gmx.net>
parents: 44
diff changeset
    21
0617e7d497f6 Branch standalone extension, including pretxncommit hook function
Christian Ebert <blacktrash@gmx.net>
parents: 44
diff changeset
    22
    return '$%s: %s $' % (matchobj.group(1), eval(matchobj.group(1)))
0617e7d497f6 Branch standalone extension, including pretxncommit hook function
Christian Ebert <blacktrash@gmx.net>
parents: 44
diff changeset
    23
42
ba000e29ecf3 Implement near CVS compability with more than one keyword
Christian Ebert <blacktrash@gmx.net>
parents: 41
diff changeset
    24
33
ebb39c6a1476 Add original keyword extension by Thomas Arendsen Hain
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
    25
def reposetup(ui, repo):
ebb39c6a1476 Add original keyword extension by Thomas Arendsen Hain
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
    26
    if not repo.local():
ebb39c6a1476 Add original keyword extension by Thomas Arendsen Hain
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
    27
        return
ebb39c6a1476 Add original keyword extension by Thomas Arendsen Hain
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
    28
ebb39c6a1476 Add original keyword extension by Thomas Arendsen Hain
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
    29
    class kwrepo(repo.__class__):
ebb39c6a1476 Add original keyword extension by Thomas Arendsen Hain
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
    30
        def file(self, f):
ebb39c6a1476 Add original keyword extension by Thomas Arendsen Hain
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
    31
            if f[0] == '/':
ebb39c6a1476 Add original keyword extension by Thomas Arendsen Hain
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
    32
                f = f[1:]
ebb39c6a1476 Add original keyword extension by Thomas Arendsen Hain
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
    33
            return filelog.filelog(self.sopener, f, self, self.revlogversion)
ebb39c6a1476 Add original keyword extension by Thomas Arendsen Hain
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
    34
ebb39c6a1476 Add original keyword extension by Thomas Arendsen Hain
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
    35
    class kwfilelog(filelog.filelog):
ebb39c6a1476 Add original keyword extension by Thomas Arendsen Hain
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
    36
        def __init__(self, opener, path, repo,
ebb39c6a1476 Add original keyword extension by Thomas Arendsen Hain
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
    37
                     defversion=revlog.REVLOG_DEFAULT_VERSION):
ebb39c6a1476 Add original keyword extension by Thomas Arendsen Hain
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
    38
            super(kwfilelog, self).__init__(opener, path, defversion)
ebb39c6a1476 Add original keyword extension by Thomas Arendsen Hain
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
    39
            self._repo = repo
ebb39c6a1476 Add original keyword extension by Thomas Arendsen Hain
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
    40
            self._path = path
36
b3ace8cc5a33 Change config opt "expand" to accept filename patterns
Christian Ebert <blacktrash@gmx.net>
parents: 34
diff changeset
    41
33
ebb39c6a1476 Add original keyword extension by Thomas Arendsen Hain
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
    42
        def read(self, node):
42
ba000e29ecf3 Implement near CVS compability with more than one keyword
Christian Ebert <blacktrash@gmx.net>
parents: 41
diff changeset
    43
            data = super(kwfilelog, self).read(node)
44
dc6e7d0e607f Exclude tag cmd from pretxcommit hook; exclude .hg files
Christian Ebert <blacktrash@gmx.net>
parents: 42
diff changeset
    44
            if util.binary(data):
dc6e7d0e607f Exclude tag cmd from pretxcommit hook; exclude .hg files
Christian Ebert <blacktrash@gmx.net>
parents: 42
diff changeset
    45
                return data
dc6e7d0e607f Exclude tag cmd from pretxcommit hook; exclude .hg files
Christian Ebert <blacktrash@gmx.net>
parents: 42
diff changeset
    46
dc6e7d0e607f Exclude tag cmd from pretxcommit hook; exclude .hg files
Christian Ebert <blacktrash@gmx.net>
parents: 42
diff changeset
    47
            c = context.filectx(self._repo, self._path, fileid=node,
dc6e7d0e607f Exclude tag cmd from pretxcommit hook; exclude .hg files
Christian Ebert <blacktrash@gmx.net>
parents: 42
diff changeset
    48
                                 filelog=self)
dc6e7d0e607f Exclude tag cmd from pretxcommit hook; exclude .hg files
Christian Ebert <blacktrash@gmx.net>
parents: 42
diff changeset
    49
            f = c.path()
dc6e7d0e607f Exclude tag cmd from pretxcommit hook; exclude .hg files
Christian Ebert <blacktrash@gmx.net>
parents: 42
diff changeset
    50
            if f.startswith('.hg'):
dc6e7d0e607f Exclude tag cmd from pretxcommit hook; exclude .hg files
Christian Ebert <blacktrash@gmx.net>
parents: 42
diff changeset
    51
                return data
dc6e7d0e607f Exclude tag cmd from pretxcommit hook; exclude .hg files
Christian Ebert <blacktrash@gmx.net>
parents: 42
diff changeset
    52
dc6e7d0e607f Exclude tag cmd from pretxcommit hook; exclude .hg files
Christian Ebert <blacktrash@gmx.net>
parents: 42
diff changeset
    53
            for pat, opt in self._repo.ui.configitems('keyword'):
dc6e7d0e607f Exclude tag cmd from pretxcommit hook; exclude .hg files
Christian Ebert <blacktrash@gmx.net>
parents: 42
diff changeset
    54
                if opt == 'expand':
dc6e7d0e607f Exclude tag cmd from pretxcommit hook; exclude .hg files
Christian Ebert <blacktrash@gmx.net>
parents: 42
diff changeset
    55
                    mf = util.matcher(self._repo.root,
dc6e7d0e607f Exclude tag cmd from pretxcommit hook; exclude .hg files
Christian Ebert <blacktrash@gmx.net>
parents: 42
diff changeset
    56
                            '', [pat], [], [])[1]
dc6e7d0e607f Exclude tag cmd from pretxcommit hook; exclude .hg files
Christian Ebert <blacktrash@gmx.net>
parents: 42
diff changeset
    57
                    if mf(f):
42
ba000e29ecf3 Implement near CVS compability with more than one keyword
Christian Ebert <blacktrash@gmx.net>
parents: 41
diff changeset
    58
47
0617e7d497f6 Branch standalone extension, including pretxncommit hook function
Christian Ebert <blacktrash@gmx.net>
parents: 44
diff changeset
    59
                        def kwexpander(matchobj):
0617e7d497f6 Branch standalone extension, including pretxncommit hook function
Christian Ebert <blacktrash@gmx.net>
parents: 44
diff changeset
    60
                            return kwexpand(matchobj,
0617e7d497f6 Branch standalone extension, including pretxncommit hook function
Christian Ebert <blacktrash@gmx.net>
parents: 44
diff changeset
    61
                                    self._repo, c.changectx(), f,
0617e7d497f6 Branch standalone extension, including pretxncommit hook function
Christian Ebert <blacktrash@gmx.net>
parents: 44
diff changeset
    62
                                    c.date(), c.user())
42
ba000e29ecf3 Implement near CVS compability with more than one keyword
Christian Ebert <blacktrash@gmx.net>
parents: 41
diff changeset
    63
47
0617e7d497f6 Branch standalone extension, including pretxncommit hook function
Christian Ebert <blacktrash@gmx.net>
parents: 44
diff changeset
    64
                        re_kw = re.compile(r'\$(%s)\$' % hgkeywords)
0617e7d497f6 Branch standalone extension, including pretxncommit hook function
Christian Ebert <blacktrash@gmx.net>
parents: 44
diff changeset
    65
                        return re_kw.sub(kwexpander, data)
33
ebb39c6a1476 Add original keyword extension by Thomas Arendsen Hain
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
    66
            return data
36
b3ace8cc5a33 Change config opt "expand" to accept filename patterns
Christian Ebert <blacktrash@gmx.net>
parents: 34
diff changeset
    67
33
ebb39c6a1476 Add original keyword extension by Thomas Arendsen Hain
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
    68
        def add(self, text, meta, tr, link, p1=None, p2=None):
ebb39c6a1476 Add original keyword extension by Thomas Arendsen Hain
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
    69
            if (not util.binary(text) and
36
b3ace8cc5a33 Change config opt "expand" to accept filename patterns
Christian Ebert <blacktrash@gmx.net>
parents: 34
diff changeset
    70
                   self._repo.ui.config('keyword', 'remove', True)):
42
ba000e29ecf3 Implement near CVS compability with more than one keyword
Christian Ebert <blacktrash@gmx.net>
parents: 41
diff changeset
    71
                re_kw = re.compile(r'\$(%s): [^$]+? \$' % hgkeywords)
ba000e29ecf3 Implement near CVS compability with more than one keyword
Christian Ebert <blacktrash@gmx.net>
parents: 41
diff changeset
    72
                text = re_kw.sub(r'$\1$', text)
33
ebb39c6a1476 Add original keyword extension by Thomas Arendsen Hain
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
    73
            return super(kwfilelog, self).add(text, meta, tr, link, p1, p2)
ebb39c6a1476 Add original keyword extension by Thomas Arendsen Hain
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
    74
ebb39c6a1476 Add original keyword extension by Thomas Arendsen Hain
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
    75
    filelog.filelog = kwfilelog
ebb39c6a1476 Add original keyword extension by Thomas Arendsen Hain
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
    76
    repo.__class__ = kwrepo
47
0617e7d497f6 Branch standalone extension, including pretxncommit hook function
Christian Ebert <blacktrash@gmx.net>
parents: 44
diff changeset
    77
0617e7d497f6 Branch standalone extension, including pretxncommit hook function
Christian Ebert <blacktrash@gmx.net>
parents: 44
diff changeset
    78
0617e7d497f6 Branch standalone extension, including pretxncommit hook function
Christian Ebert <blacktrash@gmx.net>
parents: 44
diff changeset
    79
def pretxnkw(ui, repo, hooktype, **args):
0617e7d497f6 Branch standalone extension, including pretxncommit hook function
Christian Ebert <blacktrash@gmx.net>
parents: 44
diff changeset
    80
    '''pretxncommit hook that collects candidates for keyword expansion
0617e7d497f6 Branch standalone extension, including pretxncommit hook function
Christian Ebert <blacktrash@gmx.net>
parents: 44
diff changeset
    81
    on commit and expands keywords in working dir.'''
0617e7d497f6 Branch standalone extension, including pretxncommit hook function
Christian Ebert <blacktrash@gmx.net>
parents: 44
diff changeset
    82
0617e7d497f6 Branch standalone extension, including pretxncommit hook function
Christian Ebert <blacktrash@gmx.net>
parents: 44
diff changeset
    83
    if hooktype != 'pretxncommit': # bail out with error
0617e7d497f6 Branch standalone extension, including pretxncommit hook function
Christian Ebert <blacktrash@gmx.net>
parents: 44
diff changeset
    84
        return True
0617e7d497f6 Branch standalone extension, including pretxncommit hook function
Christian Ebert <blacktrash@gmx.net>
parents: 44
diff changeset
    85
0617e7d497f6 Branch standalone extension, including pretxncommit hook function
Christian Ebert <blacktrash@gmx.net>
parents: 44
diff changeset
    86
    # reparse args, opts again as pretxncommit hook is silent about them
0617e7d497f6 Branch standalone extension, including pretxncommit hook function
Christian Ebert <blacktrash@gmx.net>
parents: 44
diff changeset
    87
    cmd, sysargs, globalopts, cmdopts = commands.parse(ui, sys.argv[1:])[1:]
0617e7d497f6 Branch standalone extension, including pretxncommit hook function
Christian Ebert <blacktrash@gmx.net>
parents: 44
diff changeset
    88
    # exclude tag and import
0617e7d497f6 Branch standalone extension, including pretxncommit hook function
Christian Ebert <blacktrash@gmx.net>
parents: 44
diff changeset
    89
    if repr(cmd).split()[1] in ('tag', 'import_'):
0617e7d497f6 Branch standalone extension, including pretxncommit hook function
Christian Ebert <blacktrash@gmx.net>
parents: 44
diff changeset
    90
        return False
0617e7d497f6 Branch standalone extension, including pretxncommit hook function
Christian Ebert <blacktrash@gmx.net>
parents: 44
diff changeset
    91
0617e7d497f6 Branch standalone extension, including pretxncommit hook function
Christian Ebert <blacktrash@gmx.net>
parents: 44
diff changeset
    92
    files, match, anypats = cmdutil.matchpats(repo, sysargs, cmdopts)
0617e7d497f6 Branch standalone extension, including pretxncommit hook function
Christian Ebert <blacktrash@gmx.net>
parents: 44
diff changeset
    93
    # validity checks should have been done already
0617e7d497f6 Branch standalone extension, including pretxncommit hook function
Christian Ebert <blacktrash@gmx.net>
parents: 44
diff changeset
    94
    modified, added = repo.status(files=files, match=match)[:2]
0617e7d497f6 Branch standalone extension, including pretxncommit hook function
Christian Ebert <blacktrash@gmx.net>
parents: 44
diff changeset
    95
    candidates = [f for f in modified + added if not f.startswith('.hg')]
0617e7d497f6 Branch standalone extension, including pretxncommit hook function
Christian Ebert <blacktrash@gmx.net>
parents: 44
diff changeset
    96
0617e7d497f6 Branch standalone extension, including pretxncommit hook function
Christian Ebert <blacktrash@gmx.net>
parents: 44
diff changeset
    97
    if not candidates:
0617e7d497f6 Branch standalone extension, including pretxncommit hook function
Christian Ebert <blacktrash@gmx.net>
parents: 44
diff changeset
    98
        return False
0617e7d497f6 Branch standalone extension, including pretxncommit hook function
Christian Ebert <blacktrash@gmx.net>
parents: 44
diff changeset
    99
0617e7d497f6 Branch standalone extension, including pretxncommit hook function
Christian Ebert <blacktrash@gmx.net>
parents: 44
diff changeset
   100
    # only check files that are configured in keyword section
0617e7d497f6 Branch standalone extension, including pretxncommit hook function
Christian Ebert <blacktrash@gmx.net>
parents: 44
diff changeset
   101
    files = []
0617e7d497f6 Branch standalone extension, including pretxncommit hook function
Christian Ebert <blacktrash@gmx.net>
parents: 44
diff changeset
   102
    # python2.4: files = set()
0617e7d497f6 Branch standalone extension, including pretxncommit hook function
Christian Ebert <blacktrash@gmx.net>
parents: 44
diff changeset
   103
    for pat, opt in repo.ui.configitems('keyword'):
0617e7d497f6 Branch standalone extension, including pretxncommit hook function
Christian Ebert <blacktrash@gmx.net>
parents: 44
diff changeset
   104
        if opt == 'expand':
0617e7d497f6 Branch standalone extension, including pretxncommit hook function
Christian Ebert <blacktrash@gmx.net>
parents: 44
diff changeset
   105
            mf = util.matcher(repo.root, '', [pat], [], [])[1]
0617e7d497f6 Branch standalone extension, including pretxncommit hook function
Christian Ebert <blacktrash@gmx.net>
parents: 44
diff changeset
   106
            for candidate in candidates:
0617e7d497f6 Branch standalone extension, including pretxncommit hook function
Christian Ebert <blacktrash@gmx.net>
parents: 44
diff changeset
   107
                if mf(candidate) and candidate not in files:
0617e7d497f6 Branch standalone extension, including pretxncommit hook function
Christian Ebert <blacktrash@gmx.net>
parents: 44
diff changeset
   108
                    files.append(candidate)
0617e7d497f6 Branch standalone extension, including pretxncommit hook function
Christian Ebert <blacktrash@gmx.net>
parents: 44
diff changeset
   109
                # python2.4:
0617e7d497f6 Branch standalone extension, including pretxncommit hook function
Christian Ebert <blacktrash@gmx.net>
parents: 44
diff changeset
   110
                # if mf(candidate): files.add(candidate)
0617e7d497f6 Branch standalone extension, including pretxncommit hook function
Christian Ebert <blacktrash@gmx.net>
parents: 44
diff changeset
   111
0617e7d497f6 Branch standalone extension, including pretxncommit hook function
Christian Ebert <blacktrash@gmx.net>
parents: 44
diff changeset
   112
    if not files:
0617e7d497f6 Branch standalone extension, including pretxncommit hook function
Christian Ebert <blacktrash@gmx.net>
parents: 44
diff changeset
   113
        return False
0617e7d497f6 Branch standalone extension, including pretxncommit hook function
Christian Ebert <blacktrash@gmx.net>
parents: 44
diff changeset
   114
0617e7d497f6 Branch standalone extension, including pretxncommit hook function
Christian Ebert <blacktrash@gmx.net>
parents: 44
diff changeset
   115
    user, date = repo.changelog.read(repo.changelog.tip())[1:3]
0617e7d497f6 Branch standalone extension, including pretxncommit hook function
Christian Ebert <blacktrash@gmx.net>
parents: 44
diff changeset
   116
    # expand both expanded and unexpanded keywords
0617e7d497f6 Branch standalone extension, including pretxncommit hook function
Christian Ebert <blacktrash@gmx.net>
parents: 44
diff changeset
   117
    re_kw = re.compile(r'\$(%s)(: [^$]+? )?\$' % hgkeywords)
0617e7d497f6 Branch standalone extension, including pretxncommit hook function
Christian Ebert <blacktrash@gmx.net>
parents: 44
diff changeset
   118
0617e7d497f6 Branch standalone extension, including pretxncommit hook function
Christian Ebert <blacktrash@gmx.net>
parents: 44
diff changeset
   119
    for f in files:
0617e7d497f6 Branch standalone extension, including pretxncommit hook function
Christian Ebert <blacktrash@gmx.net>
parents: 44
diff changeset
   120
        data = repo.wfile(f).read()
0617e7d497f6 Branch standalone extension, including pretxncommit hook function
Christian Ebert <blacktrash@gmx.net>
parents: 44
diff changeset
   121
        if not util.binary(data):
0617e7d497f6 Branch standalone extension, including pretxncommit hook function
Christian Ebert <blacktrash@gmx.net>
parents: 44
diff changeset
   122
0617e7d497f6 Branch standalone extension, including pretxncommit hook function
Christian Ebert <blacktrash@gmx.net>
parents: 44
diff changeset
   123
            def kwexpander(matchobj):
0617e7d497f6 Branch standalone extension, including pretxncommit hook function
Christian Ebert <blacktrash@gmx.net>
parents: 44
diff changeset
   124
                return kwexpand(matchobj,
0617e7d497f6 Branch standalone extension, including pretxncommit hook function
Christian Ebert <blacktrash@gmx.net>
parents: 44
diff changeset
   125
                        repo, args['node'][:12], f, date, user)
0617e7d497f6 Branch standalone extension, including pretxncommit hook function
Christian Ebert <blacktrash@gmx.net>
parents: 44
diff changeset
   126
0617e7d497f6 Branch standalone extension, including pretxncommit hook function
Christian Ebert <blacktrash@gmx.net>
parents: 44
diff changeset
   127
            data, kwct = re_kw.subn(kwexpander, data)
0617e7d497f6 Branch standalone extension, including pretxncommit hook function
Christian Ebert <blacktrash@gmx.net>
parents: 44
diff changeset
   128
            if kwct:
0617e7d497f6 Branch standalone extension, including pretxncommit hook function
Christian Ebert <blacktrash@gmx.net>
parents: 44
diff changeset
   129
                ui.note(_('expanding keywords in %s\n' % f))
0617e7d497f6 Branch standalone extension, including pretxncommit hook function
Christian Ebert <blacktrash@gmx.net>
parents: 44
diff changeset
   130
                # backup file?
0617e7d497f6 Branch standalone extension, including pretxncommit hook function
Christian Ebert <blacktrash@gmx.net>
parents: 44
diff changeset
   131
                repo.wfile(f, 'w').write(data)