author | Christian Ebert <blacktrash@gmx.net> |
Thu, 14 Dec 2006 16:28:38 +0100 | |
branch | decodefilter |
changeset 14 | b60345141aa5 |
parent 4 | 7e618d820490 |
child 16 | e29cf107baf2 |
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: |
7e618d820490
decodefilter branch: add decode filter with kwutil module
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
11 |
parent1 = repo.changelog.tip() |
7e618d820490
decodefilter branch: add decode filter with kwutil module
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
12 |
else: |
7e618d820490
decodefilter branch: add decode filter with kwutil module
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
13 |
parent1 = repo.dirstate.parents()[0] |
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: |
7e618d820490
decodefilter branch: add decode filter with kwutil module
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
16 |
node = repo.changectx(parent1) |
7e618d820490
decodefilter branch: add decode filter with kwutil module
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
17 |
|
7e618d820490
decodefilter branch: add decode filter with kwutil module
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
18 |
user, date = repo.changelog.read(parent1)[1:3] |
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).*?\$') |