hgkw/hgkwdecode.py
author Christian Ebert <blacktrash@gmx.net>
Thu, 14 Dec 2006 08:35:24 +0100
branchdecodefilter
changeset 4 7e618d820490
child 14 b60345141aa5
permissions -rw-r--r--
decodefilter branch: add decode filter with kwutil module
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4
7e618d820490 decodefilter branch: add decode filter with kwutil module
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
     1
# $Hg: hgkwdecode.py,v$
7e618d820490 decodefilter branch: add decode filter with kwutil module
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
     2
7e618d820490 decodefilter branch: add decode filter with kwutil module
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
     3
from mercurial.demandload import demandload
7e618d820490 decodefilter branch: add decode filter with kwutil module
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
     4
demandload(globals(), 'hgkw:kwutil mercurial:localrepo re sys')
7e618d820490 decodefilter branch: add decode filter with kwutil module
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
     5
7e618d820490 decodefilter branch: add decode filter with kwutil module
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
     6
def kwdecode():
7e618d820490 decodefilter branch: add decode filter with kwutil module
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
     7
    '''Expands keywords into IO stream.'''
7e618d820490 decodefilter branch: add decode filter with kwutil module
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
     8
7e618d820490 decodefilter branch: add decode filter with kwutil module
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
     9
    lr = localrepo.localrepository(None)
7e618d820490 decodefilter branch: add decode filter with kwutil module
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
    10
7e618d820490 decodefilter branch: add decode filter with kwutil module
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
    11
    kword = kwutil.mkkw(lr, tip=False, node='')
7e618d820490 decodefilter branch: add decode filter with kwutil module
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
    12
    re_kw = kwutil.rekw()
7e618d820490 decodefilter branch: add decode filter with kwutil module
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
    13
7e618d820490 decodefilter branch: add decode filter with kwutil module
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
    14
    sys.stdout.write(re_kw.sub(kword, sys.stdin.read()))