author | Christian Ebert <blacktrash@gmx.net> |
Fri, 15 Dec 2006 01:21:56 +0100 | |
branch | decodefilter |
changeset 16 | e29cf107baf2 |
parent 14 | b60345141aa5 |
permissions | -rw-r--r-- |
14
b60345141aa5
Adapt to filename instead of basename style
Christian Ebert <blacktrash@gmx.net>
parents:
4
diff
changeset
|
1 |
# $Hg: hgkw/kwutil.py,v$ |
4
7e618d820490
decodefilter branch: add decode filter with kwutil module
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
2 |
|
7e618d820490
decodefilter branch: add decode filter with kwutil module
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
3 |
from mercurial.demandload import demandload |
7e618d820490
decodefilter branch: add decode filter with kwutil module
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
4 |
demandload(globals(), 'mercurial:util re') |
7e618d820490
decodefilter branch: add decode filter with kwutil module
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
5 |
|
7e618d820490
decodefilter branch: add decode filter with kwutil module
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
6 |
def mkkw(repo, tip=False, node=''): |
7e618d820490
decodefilter branch: add decode filter with kwutil module
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
7 |
'''Gathers info for Hg keyword and returns it as raw replacement string.''' |
7e618d820490
decodefilter branch: add decode filter with kwutil module
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
8 |
|
7e618d820490
decodefilter branch: add decode filter with kwutil module
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
9 |
# get hex |
7e618d820490
decodefilter branch: add decode filter with kwutil module
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
10 |
if tip: |
16 | 11 |
p = repo.changelog.tip() |
4
7e618d820490
decodefilter branch: add decode filter with kwutil module
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
12 |
else: |
16 | 13 |
p = repo.dirstate.parents()[0] |
4
7e618d820490
decodefilter branch: add decode filter with kwutil module
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
14 |
|
7e618d820490
decodefilter branch: add decode filter with kwutil module
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
15 |
if not node: |
16 | 16 |
node = repo.changectx(p) |
4
7e618d820490
decodefilter branch: add decode filter with kwutil module
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
17 |
|
16 | 18 |
user, date = repo.changelog.read(p)[1:3] |
4
7e618d820490
decodefilter branch: add decode filter with kwutil module
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
19 |
user = util.shortuser(user) |
7e618d820490
decodefilter branch: add decode filter with kwutil module
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
20 |
date = util.datestr(date=date, format=util.defaultdateformats[0]) |
7e618d820490
decodefilter branch: add decode filter with kwutil module
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
21 |
# %Y-%m-%d %H:%M:%S |
7e618d820490
decodefilter branch: add decode filter with kwutil module
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
22 |
|
7e618d820490
decodefilter branch: add decode filter with kwutil module
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
23 |
return r'\1 %s %s %s $' % (node, date, user) |
7e618d820490
decodefilter branch: add decode filter with kwutil module
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
24 |
|
7e618d820490
decodefilter branch: add decode filter with kwutil module
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
25 |
|
7e618d820490
decodefilter branch: add decode filter with kwutil module
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
26 |
def rekw(): |
7e618d820490
decodefilter branch: add decode filter with kwutil module
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
27 |
'''Returns compiled regex to detect hg keywords.''' |
7e618d820490
decodefilter branch: add decode filter with kwutil module
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
28 |
|
7e618d820490
decodefilter branch: add decode filter with kwutil module
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
29 |
return re.compile(r'([$]Hg: .+?,v).*?\$') |