hgkw/hgkwencode.py
author Christian Ebert <blacktrash@gmx.net>
Tue, 19 Dec 2006 15:41:45 +0100
branchextension
changeset 36 b3ace8cc5a33
parent 18 0a57d4566be9
permissions -rw-r--r--
Change config opt "expand" to accept filename patterns Not nice yet; but passes tests together with pretxnkw. TODO: Find out what filelog.add() does exactly.
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()))