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.

# $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()))