Commit b1aba2bf authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent db6c8a01
...@@ -114,14 +114,19 @@ class ZCtx(object): ...@@ -114,14 +114,19 @@ class ZCtx(object):
zctx.root = zctx.zconn.root() zctx.root = zctx.zconn.root()
# init root['treegen/values'] = {} v -> ZBlk(v) # init root['treegen/values'] = {} v -> ZBlk(v)
# TODO don't generate if already there valdict = zctx.root.get('treegen/values', None)
zctx.valdict = zctx.root['treegen/values'] = PersistentMapping() if valdict is None:
valdict = zctx.root['treegen/values'] = PersistentMapping()
valv = b'abcdefghi' valv = b'abcdefghi'
for v in valv: for v in valv:
zblk = valdict.get(v, None)
if zblk is not None and zblk.loadblkdata() == v:
continue
zblk = ZBlk() zblk = ZBlk()
zblk.setblkdata(v) zblk.setblkdata(v)
zctx.valdict[v] = zblk valdict[v] = zblk
commit('treegen/values: init %r' % valv) zctx.valdict = valdict
commit('treegen/values: init %r' % valv, skipIfEmpty=True)
# close release resources associated with zctx. # close release resources associated with zctx.
def close(zctx): def close(zctx):
...@@ -343,11 +348,13 @@ def patch(d, diff, verify): ...@@ -343,11 +348,13 @@ def patch(d, diff, verify):
# commit commits current transaction with description. # commit commits current transaction with description.
def commit(description): # -> tid def commit(description, skipIfEmpty=False): # -> tid | None
txn = transaction.get() txn = transaction.get()
if skipIfEmpty and len(txn._resources) == 0:
return None
txn.description = description txn.description = description
# XXX hack to retrieve committed transaction ID via ._p_serial of object changed in this transaction # XXX hack to retrieve committed transaction ID via ._p_serial of object changed in this transaction
assert len(txn._resources) == 1 assert len(txn._resources) == 1, txn._resources
zconn = txn._resources[0] zconn = txn._resources[0]
assert isinstance(zconn, Connection) assert isinstance(zconn, Connection)
assert len(zconn._registered_objects) > 0 assert len(zconn._registered_objects) > 0
......
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