Commit 627c1ab6 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 8fd0a998
......@@ -229,10 +229,13 @@ class tDB:
# change schedules zf to be changed according changeDelta at commit.
#
# changeDelta is {} blk -> data.
# data can be both bytes and unicode.
def change(t, zf, changeDelta):
assert isinstance(zf, ZBigFile)
zfDelta = t._changed.setdefault(zf, {})
for blk, data in changeDelta.iteritems():
if not isinstance(data, bytes):
data = data.encode('utf-8')
assert len(data) <= zf.blksize
zfDelta[blk] = data
......@@ -853,29 +856,29 @@ def test_wcfs():
f.assertData ([], mtime=at0)
# >>> (@at1) commit data -> we can see it on wcfs
t.change(zf, {2: b'1γ'})
t.change(zf, {2: '1γ'})
at1 = t.commit()
f.assertCache([0,0,0]) # initially not cached
f.assertData ([b'',b'',b'1γ'], mtime=t.head)
f.assertData (['','','1γ'], mtime=t.head)
# >>> (@at2) commit again -> we can see both latest and snapshotted states
t.change(zf, {2: b'2γ', 3: b'2δ'})
t.change(zf, {2: '2γ', 3: '2δ'})
at2 = t.commit()
# f @head
f.assertCache([1,1,0,0])
f.assertData ([b'',b'', b'2γ', b'2δ'], mtime=t.head)
f.assertData (['','', '2γ', '2δ'], mtime=t.head)
# f @at1
f1 = t.open(zf, at=at1)
f1.assertCache([0,0,1])
f1.assertData ([b'',b'',b'1γ']) # XXX + mtime=at1?
f1.assertData (['','','1γ']) # XXX + mtime=at1?
# >>> (@at3) commit again without changing zf size
f2 = t.open(zf, at=at2)
t.change(zf, {2: b'3γ'})
t.change(zf, {2: '3γ'})
at3 = t.commit()
f.assertCache([1,1,0,1])
......@@ -888,15 +891,15 @@ def test_wcfs():
# f @head
f.assertCache([1,1,0,1])
f.assertData ([b'',b'',b'3γ',b'2δ'], mtime=t.head)
f.assertData (['','','3γ','2δ'], mtime=t.head)
# f @at2
f2.assertCache([0,0,1,0])
f2.assertData ([b'',b'',b'2γ',b'2δ']) # XXX mtime=at2
f2.assertData (['','','2γ','2δ']) # XXX mtime=at2
# f @at1
f1.assertCache([1,1,1])
f1.assertData ([b'',b'',b'1γ']) # XXX + mtime=at1?
f1.assertData (['','','1γ']) # XXX + mtime=at1?
# >>> f close / open again -> cache must not be lost
......@@ -955,7 +958,7 @@ def test_wcfs():
wl = t.openwatch()
wl.watch(zf, t.head)
f.assertCache([1,1,1,1])
t.change(zf, {1: b'rio', 2: b'tty', 5: b'big'})
t.change(zf, {1: 'rio', 2: 'tty', 5: 'big'})
at4 = t.commit()
f.assertCache([1,0,0,1,0,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