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
6270a51d
Commit
6270a51d
authored
Jun 19, 2020
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
9fa6ad5e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
56 additions
and
25 deletions
+56
-25
wcfs/δbtail.go
wcfs/δbtail.go
+52
-21
wcfs/δbtail_test.go
wcfs/δbtail_test.go
+4
-4
No files found.
wcfs/δbtail.go
View file @
6270a51d
...
...
@@ -344,33 +344,24 @@ func (δBtail *ΔBtail) treediff(ctx context.Context, root zodb.Oid, δZT SetOid
return
nil
,
err
}
ta
:=
zodb
.
ClassOf
(
xa
)
tb
:=
zodb
.
ClassOf
(
xb
)
if
ta
!=
tb
{
return
nil
,
fmt
.
Errorf
(
"object %s: type mutated: %s -> %s"
,
top
,
ta
,
tb
)
a
,
ok
:=
xa
.
(
Node
)
if
!
ok
{
return
nil
,
fmt
.
Errorf
(
"object %s@%s: type unexpected: %s"
,
top
,
zconnOld
.
At
(),
zodb
.
ClassOf
(
xa
)
)
}
// XXX activate/deactivate
var
δtop
map
[
Key
]
Value
switch
a
:=
xa
.
(
type
)
{
default
:
return
nil
,
fmt
.
Errorf
(
"object %s: type unexpected: %s"
,
top
,
ta
)
case
*
Tree
:
fmt
.
Printf
(
" T%s
\n
"
,
a
.
POid
())
b
:=
xb
.
(
*
Tree
)
// must not fail
δtop
,
err
=
diffT
(
ctx
,
a
,
b
,
δZTC
)
case
*
Bucket
:
fmt
.
Printf
(
" B%s
\n
"
,
a
.
POid
())
b
:=
xb
.
(
*
Bucket
)
// must not fail
δtop
,
err
=
diffB
(
ctx
,
a
,
b
)
b
,
ok
:=
xb
.
(
Node
)
if
!
ok
{
return
nil
,
fmt
.
Errorf
(
"object %s@%s: type unexpected: %s"
,
top
,
zconnNew
.
At
(),
zodb
.
ClassOf
(
xb
))
}
δtop
,
err
:=
diffX
(
ctx
,
a
,
b
,
δZTC
)
if
err
!=
nil
{
return
nil
,
err
}
// FIXME -> merge (VDEL vs add)
for
k
,
v
:=
range
δtop
{
δT
[
k
]
=
v
}
...
...
@@ -392,6 +383,44 @@ func diffX(ctx context.Context, a, b Node, δZTC SetOid) (δ map[Key]Value, err
panic
(
"BUG: both a & b == nil"
)
}
/*
type Kind int
const (
KEmpty Kind = iota
KBucket
KTree
)
akind, bkind := KEmpty, KEmpty
*/
var
aT
,
bT
*
Tree
var
aB
,
bB
*
Bucket
if
a
!=
nil
{
aT
,
_
=
a
.
(
*
Tree
)
aB
,
_
=
a
.
(
*
Bucket
)
if
(
aT
==
nil
&&
aB
==
nil
)
{
panicf
(
"a: bad type %T"
,
a
)
}
}
if
b
!=
nil
{
bT
,
_
=
b
.
(
*
Tree
)
bB
,
_
=
b
.
(
*
Bucket
)
if
(
bT
==
nil
&&
bB
==
nil
)
{
panicf
(
"b: bad type %T"
,
b
)
}
}
if
a
!=
nil
&&
b
!=
nil
{
if
a
.
POid
()
!=
b
.
POid
()
{
panicf
(
"BUG: a.oid != b.oid ; a: %s b: %s"
,
a
.
POid
(),
b
.
POid
())
}
if
!
((
aT
!=
nil
&&
bT
!=
nil
)
||
(
aB
!=
nil
&&
bB
!=
nil
))
{
return
nil
,
fmt
.
Errorf
(
"object %s: type mutated %s -> %s"
,
a
.
POid
(),
zodb
.
ClassOf
(
a
),
zodb
.
ClassOf
(
b
))
}
}
panic
(
"TODO"
)
}
...
...
@@ -400,6 +429,7 @@ func diffX(ctx context.Context, a, b Node, δZTC SetOid) (δ map[Key]Value, err
// a, b point to top of the subtree @old and @new revisions.
// δZTC is connected set of objects covering δZT (objects changed in this tree in old..new).
func
diffT
(
ctx
context
.
Context
,
a
,
b
*
Tree
,
δZTC
SetOid
)
(
δ
map
[
Key
]
Value
,
err
error
)
{
fmt
.
Printf
(
" T%s
\n
"
,
a
.
POid
())
defer
xerr
.
Contextf
(
&
err
,
"diffT %s"
,
a
.
POid
())
if
a
.
POid
()
!=
b
.
POid
()
{
panic
(
"different trees"
)
...
...
@@ -475,6 +505,7 @@ func diffT(ctx context.Context, a, b *Tree, δZTC SetOid) (δ map[Key]Value, err
// diffB computes difference in between two revisions of a bucket.
// see diffX for details.
func
diffB
(
ctx
context
.
Context
,
a
,
b
*
Bucket
)
(
δ
map
[
Key
]
Value
,
err
error
)
{
fmt
.
Printf
(
" B%s
\n
"
,
a
.
POid
())
defer
xerr
.
Contextf
(
&
err
,
"diffB %s"
,
a
.
POid
())
// XXX oid can be InvalidOid for T/B... (i.e. B is part of T and is not yet committed separately)
if
a
.
POid
()
!=
b
.
POid
()
{
...
...
wcfs/δbtail_test.go
View file @
6270a51d
...
...
@@ -286,12 +286,12 @@ func (rbs RBucketSet) Get(k Key) *RBucket {
return
rbs
[
i
]
.
hi
>
k
})
if
i
==
len
(
rbs
)
{
panic
(
fmt
.
Sprintf
(
"BUG: key %v not covered; coverage: %s"
,
k
,
rbs
.
coverage
()
))
panic
f
(
"BUG: key %v not covered; coverage: %s"
,
k
,
rbs
.
coverage
(
))
}
rb
:=
rbs
[
i
]
if
!
(
rb
.
lo
<=
k
&&
k
<
rb
.
hi
)
{
panic
(
fmt
.
Sprintf
(
"BUG: get(%v) -> [%v, %v); coverage: %s"
,
k
,
rb
.
lo
,
rb
.
hi
,
rbs
.
coverage
()
))
panic
f
(
"BUG: get(%v) -> [%v, %v); coverage: %s"
,
k
,
rb
.
lo
,
rb
.
hi
,
rbs
.
coverage
(
))
}
return
rb
...
...
@@ -650,7 +650,7 @@ func ΔBTest(xtest interface{}) ΔBTestEntry {
case
ΔBTestEntry
:
test
=
xtest
default
:
panic
(
fmt
.
Sprintf
(
"BUG: ΔBTest: bad type %T"
,
xtest
)
)
panic
f
(
"BUG: ΔBTest: bad type %T"
,
xtest
)
}
return
test
}
...
...
@@ -1047,7 +1047,7 @@ func kvtxt(kv map[Key]string) string {
for
_
,
k
:=
range
keyv
{
v
:=
kv
[
k
]
if
strings
.
ContainsAny
(
v
,
"
\n\t
,:"
)
{
panic
(
fmt
.
Sprintf
(
"[%v]=%q: invalid value"
,
k
,
v
)
)
panic
f
(
"[%v]=%q: invalid value"
,
k
,
v
)
}
sv
=
append
(
sv
,
fmt
.
Sprintf
(
"%v:%s"
,
k
,
v
))
}
...
...
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