Commit 5e172c1c authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 02db2a48
......@@ -156,6 +156,8 @@ def Trees(zstor, r):
trees = zctx.root['treegen/trees'] = PersistentMapping()
commit('treegen/trees: init')
print("start @%s tree=%s" % (ashex(XXX), ashex(XXX))
while 1:
treetxt = r.readline()
if treetxt == '':
......
......@@ -25,6 +25,7 @@ import (
"io"
"os"
"os/exec"
"regexp"
"strings"
"testing"
......@@ -43,6 +44,7 @@ type TreeGen struct {
pyoutRaw *io.PipeReader // output from pysrv
pyout *bufio.Reader // buffered ^^^
treeRoot zodb.Oid // oid of the tree treegen works on
head zodb.Tid // last made commit
}
// StartTreeGen spawns `treegen trees` server.
......@@ -61,7 +63,33 @@ func StartTreeGen(zurl string) (_ *TreeGen, err error) {
return nil, err
}
// XXX wait for init message and set .treeRoot
// wait for init message and set .treeRoot
defer func() {
if err != nil {
tg.Close() // ignore error
}
}()
defer xerr.Context(&err, "handshake")
start, err := tg.pyout.ReadString('\n')
if err != nil {
return nil, err
}
// start @<at> tree=<root>
startRe := regexp.MustCompile(`^start @([^ ]+) root=([^ ]+)$`)
m := startRe.FindStringSubmatch(start)
if m == nil {
return nil, fmt.Errorf("invalid start %q", start)
}
tg.head, err = zodb.ParseTid(m[1]) // <at>
if err != nil {
return nil, fmt.Errorf("invalid start %q: tid: %s", start, err)
}
tg.treeRoot, err = zodb.ParseOid(m[2]) // <root>
if err != nil {
return nil, fmt.Errorf("invalid start %q: root: %s", start, err)
}
return tg, nil
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment