view tests/heredoctest.py @ 35679:5a2d505a9174

bookmark: deprecate direct update of a bookmark value This changeset was part of an older series preventing direct update of the bookmarks store without the change being tracked by a transaction. For some unclear reason, this was not sent to the list. So we are sending it now. Initial series: 3325c7dcabaa+08bf0ebc6c8e+712a85b3677f. We want to channel all bookmarks update through 'applychanges' so let's remove more way to work around this function.
author Boris Feld <boris.feld@octobus.net>
date Fri, 14 Jul 2017 19:59:10 +0200
parents 6a98f9408a50
children 55fd0fefbec4
line wrap: on
line source

from __future__ import absolute_import, print_function

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, globalvars)
        except Exception as inst:
            print(repr(inst))