hgkw/hgkwencode.py
author Christian Ebert <blacktrash@gmx.net>
Sat, 16 Dec 2006 15:28:42 +0100
branchupdatehook
changeset 18 0a57d4566be9
parent 3 b9f2c0853da3
permissions -rw-r--r--
Simplify filter pattern for $Hg$ scheme Adapt keyword trigger as well.

# $Hg$

import re, sys

def kwencode():
    '''Truncates hg keywords in IO stream
    from
    <Dollar>Hg: <filename> <cset id> <stuff> <Dollar>
    to
    <Dollar>Hg<Dollar>.'''
    kwrepl = r'%sHg$' % '$'
    re_kwtrunc = re.compile(r'[$]Hg: .+?,v [a-z0-9]{12} [^$]+? \$')
    sys.stdout.write(re_kwtrunc.sub(kwrepl, sys.stdin.read()))