hgkw/hgkwencode.py
author Christian Ebert <blacktrash@gmx.net>
Tue, 19 Dec 2006 10:00:28 +0100
branchextension
changeset 35 a730c9d4ec05
parent 18 0a57d4566be9
permissions -rw-r--r--
Interim test version in connection with keyword.py Simplify grep pattern. Outcomment filename lookup, will be changed to configitems('keywords'). Update stuff will be removed. And the whole thing will go into pretxncommit. kwupdate.py will be removed.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
18
0a57d4566be9 Simplify filter pattern for $Hg$ scheme
Christian Ebert <blacktrash@gmx.net>
parents: 3
diff changeset
     1
# $Hg$
1
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
3
b9f2c0853da3 Make pattern compilation local to function
Christian Ebert <blacktrash@gmx.net>
parents: 2
diff changeset
     5
def kwencode():
18
0a57d4566be9 Simplify filter pattern for $Hg$ scheme
Christian Ebert <blacktrash@gmx.net>
parents: 3
diff changeset
     6
    '''Truncates hg keywords in IO stream
0a57d4566be9 Simplify filter pattern for $Hg$ scheme
Christian Ebert <blacktrash@gmx.net>
parents: 3
diff changeset
     7
    from
0a57d4566be9 Simplify filter pattern for $Hg$ scheme
Christian Ebert <blacktrash@gmx.net>
parents: 3
diff changeset
     8
    <Dollar>Hg: <filename> <cset id> <stuff> <Dollar>
0a57d4566be9 Simplify filter pattern for $Hg$ scheme
Christian Ebert <blacktrash@gmx.net>
parents: 3
diff changeset
     9
    to
0a57d4566be9 Simplify filter pattern for $Hg$ scheme
Christian Ebert <blacktrash@gmx.net>
parents: 3
diff changeset
    10
    <Dollar>Hg<Dollar>.'''
0a57d4566be9 Simplify filter pattern for $Hg$ scheme
Christian Ebert <blacktrash@gmx.net>
parents: 3
diff changeset
    11
    kwrepl = r'%sHg$' % '$'
0a57d4566be9 Simplify filter pattern for $Hg$ scheme
Christian Ebert <blacktrash@gmx.net>
parents: 3
diff changeset
    12
    re_kwtrunc = re.compile(r'[$]Hg: .+?,v [a-z0-9]{12} [^$]+? \$')
0a57d4566be9 Simplify filter pattern for $Hg$ scheme
Christian Ebert <blacktrash@gmx.net>
parents: 3
diff changeset
    13
    sys.stdout.write(re_kwtrunc.sub(kwrepl, sys.stdin.read()))