Commit b10e08f4 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 52eacf3d
...@@ -878,6 +878,7 @@ def watch(twlink, zf, at, pinok=None): # -> tWatch ...@@ -878,6 +878,7 @@ def watch(twlink, zf, at, pinok=None): # -> tWatch
print('\nC: setup watch f<%s> %s%s' % (h(zf._p_oid), at_from, t.hat(at))) print('\nC: setup watch f<%s> %s%s' % (h(zf._p_oid), at_from, t.hat(at)))
headOfAccess = t._headOfAccess(zf) headOfAccess = t._headOfAccess(zf)
blkRevAt = lambda blk, at: t._blkRevAt(zf, blk, at)
pin_prev = {} pin_prev = {}
if at_prev is not None: if at_prev is not None:
...@@ -894,25 +895,33 @@ def watch(twlink, zf, at, pinok=None): # -> tWatch ...@@ -894,25 +895,33 @@ def watch(twlink, zf, at, pinok=None): # -> tWatch
# blk ∉ pin_prev, blk ∉ pin -> cannot happen # blk ∉ pin_prev, blk ∉ pin -> cannot happen
assert (blk in pin_prev) or (blk in pin) assert (blk in pin_prev) or (blk in pin)
# blk ∉ pin_prev, blk ∈ pin -> cannot happen # blk ∉ pin_prev, blk ∈ pin -> cannot happen, except on first start
if blk not in pin_prev and blk in pin: if blk not in pin_prev and blk in pin:
if at_prev is not None: if at_prev is not None:
assert False, '#%d pinned %s; not pinned %s' % (t.hat(at_prev), t.hat(at)) assert False, '#%d pinned %s; not pinned %s' % (t.hat(at_prev), t.hat(at))
# blk ∈ pin -> blk was already accessed with rev > at
assert blk in headOfAccess
assert at < blkRevAt(blk, headOfAccess[blk])
# blk ∈ pin_prev, blk ∉ pin -> unpin to head # blk ∈ pin_prev, blk ∉ pin -> unpin to head
elif blk in pin_prev and blk not in pin: elif blk in pin_prev and blk not in pin:
# blk ∈ pin_prev means blk was already accessed with rev > at_prev # blk ∈ pin_prev -> blk was already accessed with rev > at_prev
assert blk in headOfAccess assert blk in headOfAccess
assert t._blkRevAt(blk, headOfAccess[blk]) > at_prev assert at_prev < blkRevAt(blk, headOfAccess[blk])
# blk ∉ pin means XXX # blk ∉ pin -> blk revision as of last access is ≤ at
assert headOfAccess[blk] >= t._blkRevAt(blk, t.head) assert blkRevAt(blk, headOfAccess[blk]) <= at
pin[blk] = None # @head pin[blk] = None # @head
# blk ∈ pin_prev, blk ∈ pin -> if rev different: use pin # blk ∈ pin_prev, blk ∈ pin -> if rev different: use pin
elif blk in pin_prev and blk in pin: elif blk in pin_prev and blk in pin:
# XXX headOfAccess assert # blk ∈ pin_prev, pin -> blk was already accessed with rev > at_prev, at
assert blk in headOfAccess
assert at_prev < blkRevAt(blk, headOfAccess[blk])
assert at < blkRevAt(blk, headOfAccess[blk])
assert pin_prev[blk] <= pin[blk] assert pin_prev[blk] <= pin[blk]
if pin_prev[blk] == pin[blk]: if pin_prev[blk] == pin[blk]:
del pin[blk] # would need to pin to what it is already pinned del pin[blk] # would need to pin to what it is already pinned
......
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