Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
W
wendelin.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Kirill Smelkov
wendelin.core
Commits
56aad370
Commit
56aad370
authored
Jun 26, 2019
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
2de41552
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
24 deletions
+35
-24
wcfs/wcfs_test.py
wcfs/wcfs_test.py
+35
-24
No files found.
wcfs/wcfs_test.py
View file @
56aad370
...
...
@@ -283,7 +283,7 @@ class tDB:
t
.
root
[
'_last'
]
=
last
=
Persistent
()
last
.
_p_changed
=
1
transaction
.
commit
()
head
=
last
.
_p_serial
head
=
tAt
(
t
,
last
.
_p_serial
)
dF
.
rev
=
head
for
dfile
in
dF
.
byfile
.
values
():
...
...
@@ -291,7 +291,7 @@ class tDB:
t
.
dFtail
.
append
(
dF
)
assert
t
.
head
==
head
# self-check
print
(
'
\
n
M: commit -> %s'
%
t
.
hat
(
head
)
)
print
(
'
\
n
M: commit -> %s'
%
head
)
for
zf
,
zfDelta
in
t
.
_changed
.
items
():
print
(
'M: f<%s>
\
t
%s'
%
(
h
(
zf
.
_p_oid
),
sorted
(
zfDelta
.
keys
())))
t
.
_changed
=
{}
...
...
@@ -306,10 +306,10 @@ class tDB:
l
=
t
.
_wc_zheadfh
.
readline
()
#print('> zhead read: %r' % l)
l
=
l
.
rstrip
(
'
\
n
'
)
wchead
=
fromhex
(
l
)
wchead
=
tAt
(
t
,
fromhex
(
l
)
)
i
=
len
(
t
.
_wc_zheadv
)
if
wchead
!=
t
.
dFtail
[
i
].
rev
:
raise
RuntimeError
(
"wcsync #%d: wczhead (%s) != zhead (%s)"
%
(
i
,
h
(
wchead
),
h
(
t
.
dFtail
[
i
].
rev
)
))
raise
RuntimeError
(
"wcsync #%d: wczhead (%s) != zhead (%s)"
%
(
i
,
wchead
,
t
.
dFtail
[
i
].
rev
))
t
.
_wc_zheadv
.
append
(
wchead
)
# head/at = last txn of whole db
...
...
@@ -864,7 +864,7 @@ class tSrvReq:
if
at
==
"head"
:
at
=
None
else
:
at
=
fromhex
(
at
)
at
=
tAt
(
req
.
twlink
.
tdb
,
fromhex
(
at
)
)
return
foid
,
blk
,
at
...
...
@@ -899,15 +899,15 @@ def watch(twlink, zf, at, pinok=None): # -> tWatch
at_from
=
''
if
at_prev
is
not
None
:
at_from
=
'(%s ->) '
%
t
.
hat
(
at_prev
)
print
(
'
\
n
C: setup watch f<%s> %s%s'
%
(
h
(
zf
.
_p_oid
),
at_from
,
t
.
hat
(
at
)
))
at_from
=
'(%s ->) '
%
at_prev
print
(
'
\
n
C: setup watch f<%s> %s%s'
%
(
h
(
zf
.
_p_oid
),
at_from
,
at
))
accessed
=
t
.
_blkaccessed
(
zf
)
lastRevOf
=
lambda
blk
:
t
.
_blkRevAt
(
zf
,
blk
,
t
.
head
)
pin_prev
=
{}
if
at_prev
is
not
None
:
assert
at_prev
<=
at
,
'TODO %s -> %s'
%
(
t
.
hat
(
at_prev
),
t
.
hat
(
at
)
)
assert
at_prev
<=
at
,
'TODO %s -> %s'
%
(
at_prev
,
at
)
pin_prev
=
t
.
_pinnedAt
(
zf
,
at_prev
)
assert
w
.
pinned
==
pin_prev
...
...
@@ -923,7 +923,7 @@ def watch(twlink, zf, at, pinok=None): # -> tWatch
# blk ∉ pin_prev, blk ∈ pin -> cannot happen, except on first start
if
blk
not
in
pin_prev
and
blk
in
pin
:
if
at_prev
is
not
None
:
fail
(
'#%d pinned %s; not pinned %s'
%
(
t
.
hat
(
at_prev
),
t
.
hat
(
at
)
))
fail
(
'#%d pinned %s; not pinned %s'
%
(
at_prev
,
at
))
# blk ∈ pin -> blk is tracked; has rev > at
# (see criteria in _pinnedAt)
...
...
@@ -1179,13 +1179,13 @@ def _pinnedAt(t, zf, at): # -> pin = {} blk -> rev
@
func
(
tDB
)
def
iter_revv
(
t
,
start
=
z64
,
level
=
0
):
dFtail
=
[
_
for
_
in
t
.
dFtail
if
_
.
rev
>
start
]
#print(' '*level, 'iter_revv',
t.hat(start), [t.hat(_.rev)
for _ in dFtail])
#print(' '*level, 'iter_revv',
start, [_.rev
for _ in dFtail])
if
len
(
dFtail
)
==
0
:
yield
[]
return
for
dF
in
dFtail
:
#print(' '*level, 'QQQ',
t.hat(dF.rev)
)
#print(' '*level, 'QQQ',
dF.rev
)
for
tail
in
t
.
iter_revv
(
start
=
dF
.
rev
,
level
=
level
+
1
):
#print(' '*level, 'zzz', tail)
yield
([
dF
.
rev
]
+
tail
)
...
...
@@ -1452,7 +1452,7 @@ def test_wcfs_watch_setup():
for
zf
in
t
.
zfiles
():
for
revv
in
t
.
iter_revv
():
print
(
'
\
n
--------'
)
print
(
' -> '
.
join
(
[
t
.
hat
(
_
)
for
_
in
revv
]
))
print
(
' -> '
.
join
(
revv
))
wl
=
t
.
openwatch
()
wl
.
watch
(
zf
,
revv
[
0
])
wl
.
watch
(
zf
,
revv
[
0
])
# verify at_i -> at_i
...
...
@@ -1724,16 +1724,27 @@ def test_tidtime_notrough():
assert
tidtime
(
at
)
>
tidtime
(
atprev
)
# hat returns string for at.
# it gives both symbolic version and raw hex for at, for example:
# tAt is bytes whose repr returns human readable string considering it as `at` under tDB.
#
# It gives both symbolic version and raw hex forms, for example:
# @at2 (03cf7850500b5f66)
@
func
(
tDB
)
def
hat
(
t
,
at
):
for
i
,
dF
in
enumerate
(
t
.
dFtail
):
if
dF
.
rev
==
at
:
return
"@at%d (%s)"
%
(
i
,
h
(
at
))
return
"@"
+
h
(
at
)
#
# tAt is used everywhere with the idea that e.g. if an assert comparing at, or
# e.g. dicts containing at, fails, everything is printed in human readable
# form instead of raw hex that is hard to visibly map to logical transaction.
class
tAt
(
bytes
):
def
__new__
(
cls
,
tdb
,
at
):
tat
=
bytes
.
__new__
(
cls
,
at
)
tat
.
tdb
=
tdb
return
tat
def
__repr__
(
at
):
t
=
at
.
tdb
for
i
,
dF
in
enumerate
(
t
.
dFtail
):
if
dF
.
rev
==
at
:
return
"@at%d (%s)"
%
(
i
,
h
(
at
))
return
"@"
+
h
(
at
)
__str__
=
__repr__
# hpin returns human-readable representation for {}blk->rev.
@
func
(
tDB
)
...
...
@@ -1743,7 +1754,7 @@ def hpin(t, pin):
if
pin
[
blk
]
is
None
:
s
=
'@head'
else
:
s
=
t
.
hat
(
pin
[
blk
])
s
=
'%s'
%
pin
[
blk
]
pinv
.
append
(
'%d: %s'
%
(
blk
,
s
))
return
'{%s}'
%
', '
.
join
(
pinv
)
...
...
@@ -1768,7 +1779,7 @@ def dump_history(t):
print
(
'>>> Change history by file:
\
n
'
)
for
zf
in
t
.
zfiles
():
print
(
'f<%s>:'
%
h
(
zf
.
_p_oid
))
indent
=
'
\
t
%s
\
t
'
%
(
' '
*
len
(
t
.
hat
(
t
.
head
)
),)
indent
=
'
\
t
%s
\
t
'
%
(
' '
*
len
(
'%s'
%
t
.
head
),)
print
(
'%s%s'
%
(
indent
,
' '
.
join
(
'01234567'
)))
print
(
'%s%s'
%
(
indent
,
' '
.
join
(
'abcdefgh'
)))
for
dF
in
t
.
dFtail
:
...
...
@@ -1782,7 +1793,7 @@ def dump_history(t):
else
:
emitv
.
append
(
' '
)
print
(
'
\
t
%s
\
t
%s'
%
(
t
.
hat
(
dF
.
rev
)
,
' '
.
join
(
emitv
)))
print
(
'
\
t
%s
\
t
%s'
%
(
dF
.
rev
,
' '
.
join
(
emitv
)))
print
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment