author | Christian Ebert <blacktrash@gmx.net> |
Thu, 21 Dec 2006 16:00:45 +0100 | |
branch | modular |
changeset 46 | 67e9fb23a32b |
permissions | -rw-r--r-- |
46
67e9fb23a32b
Make keyword.py depend on resurrected kwutil.py
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1 |
''' |
67e9fb23a32b
Make keyword.py depend on resurrected kwutil.py
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
2 |
kwutil provides required little helpers for the Mercurial |
67e9fb23a32b
Make keyword.py depend on resurrected kwutil.py
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
3 |
keyword extension and the Python pretxncommit hook pretxnkw. |
67e9fb23a32b
Make keyword.py depend on resurrected kwutil.py
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
4 |
''' |
67e9fb23a32b
Make keyword.py depend on resurrected kwutil.py
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
5 |
|
67e9fb23a32b
Make keyword.py depend on resurrected kwutil.py
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
6 |
from mercurial import util |
67e9fb23a32b
Make keyword.py depend on resurrected kwutil.py
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
7 |
import os.path |
67e9fb23a32b
Make keyword.py depend on resurrected kwutil.py
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
8 |
|
67e9fb23a32b
Make keyword.py depend on resurrected kwutil.py
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
9 |
# supported keywords for use in regexes |
67e9fb23a32b
Make keyword.py depend on resurrected kwutil.py
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
10 |
hgkeywords = 'Id|Header|Author|Date|Revision|RCSFile|Source' |
67e9fb23a32b
Make keyword.py depend on resurrected kwutil.py
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
11 |
|
67e9fb23a32b
Make keyword.py depend on resurrected kwutil.py
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
12 |
def kwexpand(matchobj, repo, Revision, f, date, Author): |
67e9fb23a32b
Make keyword.py depend on resurrected kwutil.py
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
13 |
'''Called by keyword extension and pretxnkw pretxncomit hook, |
67e9fb23a32b
Make keyword.py depend on resurrected kwutil.py
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
14 |
sets supported keywords as local variables and evaluates them |
67e9fb23a32b
Make keyword.py depend on resurrected kwutil.py
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
15 |
to their expansion if matchobj is equal to their string |
67e9fb23a32b
Make keyword.py depend on resurrected kwutil.py
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
16 |
representation.''' |
67e9fb23a32b
Make keyword.py depend on resurrected kwutil.py
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
17 |
RCSFile = os.path.basename(f)+',v' |
67e9fb23a32b
Make keyword.py depend on resurrected kwutil.py
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
18 |
Source = os.path.join(repo.root, f)+',v' |
67e9fb23a32b
Make keyword.py depend on resurrected kwutil.py
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
19 |
Date = util.datestr(date) |
67e9fb23a32b
Make keyword.py depend on resurrected kwutil.py
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
20 |
revdateauth = '%s %s %s' % (Revision, |
67e9fb23a32b
Make keyword.py depend on resurrected kwutil.py
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
21 |
util.datestr(date=date, format=util.defaultdateformats[0]), |
67e9fb23a32b
Make keyword.py depend on resurrected kwutil.py
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
22 |
# %Y-%m-%d %H:%M:%S |
67e9fb23a32b
Make keyword.py depend on resurrected kwutil.py
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
23 |
util.shortuser(Author)) |
67e9fb23a32b
Make keyword.py depend on resurrected kwutil.py
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
24 |
Header = '%s %s' % (Source, revdateauth) |
67e9fb23a32b
Make keyword.py depend on resurrected kwutil.py
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
25 |
Id = '%s %s' % (RCSFile, revdateauth) |
67e9fb23a32b
Make keyword.py depend on resurrected kwutil.py
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
26 |
return '$%s: %s $' % (matchobj.group(1), eval(matchobj.group(1))) |