tests/heredoctest.py
author Mathias De Maré <mathias.demare@gmail.com>
Fri, 28 Nov 2014 20:16:15 +0100
changeset 23411 2d86f4e38c08
parent 22565 8d45a42b0c0f
child 25032 1db2127d2373
permissions -rw-r--r--
subrepo: add status support for ignored files in git subrepos Retrieving the status of a git subrepo did not show ignored files. Using 'git ls-files', we can retrieve these files and display the correct status.

import sys

globalvars = {}
lines = sys.stdin.readlines()
while lines:
    l = lines.pop(0)
    if l.startswith('SALT'):
        print l[:-1]
    elif l.startswith('>>> '):
        snippet = l[4:]
        while lines and lines[0].startswith('... '):
            l = lines.pop(0)
            snippet += l[4:]
        c = compile(snippet, '<heredoc>', 'single')
        try:
            exec c in globalvars
        except Exception, inst:
            print repr(inst)