Commit 6b76ad1f authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent bdbe0182
......@@ -206,11 +206,11 @@ def AllStructs(zstor, kv1txt, kv2txt, n, seed=None):
# emit patches ztree with delta, adjusts tree structure and emits corresponding commit.
def emit(delta, verify, treeTopo):
ttxt_prev = treetxt(ztree, zctx.vencode)
ttxt_prev = zctx.ztreetxt(ztree)
patch(ztree, delta, verify)
if treeTopo is not None:
xbtree.Restructure(ztree, treeTopo)
ttxt = treetxt(ztree, zctx.vencode)
ttxt = zctx.ztreetxt(ztree)
tid = commit('%s -> %s' % (ttxt_prev, ttxt))
print('txn %s # %s -> %s' % (ashex(tid), ttxt_prev, ttxt))
for (k,v) in delta:
......@@ -348,9 +348,20 @@ def commit(description): # -> tid
return obj._p_serial
# treetxt returns text representation of a tree.
def treetxt(ztree, vencode): # -> txt
return xbtree.TopoEncode(xbtree.StructureOf(ztree), vencode)
# ztreetxt returns text representation of a ZODB tree.
@func(ZCtx)
def ztreetxt(zctx, ztree): # -> txt
assert ztree._p_jar is zctx.zconn
return zctx.TopoEncode(xbtree.StructureOf(ztree))
# TopoEncode and TopoDecode perform trees encode/decode with values registry
# taken from zctx.valdict.
@func(ZCtx)
def TopoEncode(zctx, tree):
return xbtree.TopoEncode(tree, zctx.vencode)
@func(ZCtx)
def TopoDecode(zctx, text):
return xbtree.TopoDecode(text, zctx.vdecode)
@func
......
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