hgkw/hgkwencode.py
author Christian Ebert <blacktrash@gmx.net>
Tue, 12 Dec 2006 22:26:05 +0100
changeset 1 1d997ec7be86
child 2 0bda12ebde94
permissions -rw-r--r--
Add simple [encode] filter in python The aim is to go for $Hg$ without basename. Perhaps this is feasable with update hooks &Co. No way to detect a filename while stream writing. Even though hg /knows/ the filenames, but does not provide an API or hook, unfortunately.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
1d997ec7be86 Add simple [encode] filter in python
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
     1
# $Hg: hgkwencode.py,v$
1d997ec7be86 Add simple [encode] filter in python
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
     2
1d997ec7be86 Add simple [encode] filter in python
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
     3
import re, sys
1d997ec7be86 Add simple [encode] filter in python
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
     4
1d997ec7be86 Add simple [encode] filter in python
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
     5
#re_kwencode = re.compile(r'[$]Hg.*?[$]')
1d997ec7be86 Add simple [encode] filter in python
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
     6
re_kwencode = re.compile(r'([$]Hg: .+?,v) [a-z0-9]{12} [^$]+? [$]')
1d997ec7be86 Add simple [encode] filter in python
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
     7
1d997ec7be86 Add simple [encode] filter in python
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
     8
def hgkwencode():
1d997ec7be86 Add simple [encode] filter in python
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
     9
    sys.stdout.write(
1d997ec7be86 Add simple [encode] filter in python
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
    10
            re_kwencode.sub(r'\1$', sys.stdin.read())
1d997ec7be86 Add simple [encode] filter in python
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
    11
            )