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
290d417c
Commit
290d417c
authored
Oct 06, 2021
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
79558000
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
94 additions
and
4 deletions
+94
-4
wcfs/internal/xbtree/δbtail.go
wcfs/internal/xbtree/δbtail.go
+4
-4
wcfs/internal/xbtree/δbtail_test.go
wcfs/internal/xbtree/δbtail_test.go
+90
-0
No files found.
wcfs/internal/xbtree/δbtail.go
View file @
290d417c
...
...
@@ -681,8 +681,6 @@ func vδTBuild1(atPrev zodb.Tid, δZ zodb.ΔRevEntry, trackNew blib.PPTreeSubSet
//
// δrevSet indicates set of new revisions created in vδT.
// vδT is modified inplace.
//
// XXX test
func
vδTMergeInplace
(
pvδT
*
[]
ΔTree
,
vδTnew
[]
ΔTree
)
(
δrevSet
setTid
)
{
// TODO optimize to go through vδT and vδTnew sequentially if needed
δrevSet
=
setTid
{}
...
...
@@ -699,9 +697,11 @@ func vδTMergeInplace(pvδT *[]ΔTree, vδTnew []ΔTree) (δrevSet setTid) {
//
// newRevEntry indicates whether δT.Rev was not there before in vδT.
// vδT is modified inplace.
//
// XXX test
func
vδTMerge1Inplace
(
pvδT
*
[]
ΔTree
,
δT
ΔTree
)
(
newRevEntry
bool
)
{
if
len
(
δT
.
KV
)
==
0
{
return
false
// δT has no change
}
vδT
:=
*
pvδT
l
:=
len
(
vδT
)
...
...
wcfs/internal/xbtree/δbtail_test.go
View file @
290d417c
...
...
@@ -1357,6 +1357,96 @@ func TestΔBtailClone(t_ *testing.T) {
assertΔTtail
(
t
.
T
,
"klon @at1 after orig @at->@at2"
,
δbklon
,
t1
,
t
.
Root
(),
δkv1_1
)
}
// -------- vδTMerge --------
func
TestVδTMerge
(
t
*
testing
.
T
)
{
vδTMerge1
:=
func
(
vδT
[]
ΔTree
,
δT
ΔTree
)
(
_
[]
ΔTree
,
newRevEntry
bool
)
{
vδT
=
vδTClone
(
vδT
)
newRevEntry
=
vδTMerge1Inplace
(
&
vδT
,
δT
)
return
vδT
,
newRevEntry
}
vδTMerge
:=
func
(
vδT
,
vδTnew
[]
ΔTree
)
(
_
[]
ΔTree
,
δrevSet
setTid
)
{
vδT
=
vδTClone
(
vδT
)
δrevSet
=
vδTMergeInplace
(
&
vδT
,
vδTnew
)
return
vδT
,
δrevSet
}
assertMerge1
:=
func
(
vδT
[]
ΔTree
,
δT
ΔTree
,
newRevEntryOK
bool
,
mergeOK
[]
ΔTree
)
{
t
.
Helper
()
merge
,
newRevEntry
:=
vδTMerge1
(
vδT
,
δT
)
if
!
(
reflect
.
DeepEqual
(
merge
,
mergeOK
)
&&
newRevEntry
==
newRevEntryOK
)
{
t
.
Errorf
(
"merge1 %v + %v:
\n
have: %v %t
\n
want: %v %t"
,
vδT
,
δT
,
merge
,
newRevEntry
,
mergeOK
,
newRevEntryOK
)
}
}
assertMerge
:=
func
(
vδT
,
vδTnew
[]
ΔTree
,
δrevSetOK
setTid
,
mergeOK
[]
ΔTree
)
{
t
.
Helper
()
merge
,
δrevSet
:=
vδTMerge
(
vδT
,
vδTnew
)
if
!
(
reflect
.
DeepEqual
(
merge
,
mergeOK
)
&&
δrevSet
.
Equal
(
δrevSetOK
))
{
t
.
Errorf
(
"merge %v + %v:
\n
have: %v %v
\n
want: %v %v"
,
vδT
,
vδTnew
,
merge
,
δrevSet
,
mergeOK
,
δrevSetOK
)
}
}
// syntax sugar
type
Δ
=
ΔTree
type
δ
=
map
[
Key
]
ΔValue
v
:=
func
(
vδT
...
Δ
)
[]
Δ
{
return
vδT
}
r
:=
func
(
tidv
...
zodb
.
Tid
)
setTid
{
s
:=
setTid
{}
for
_
,
tid
:=
range
tidv
{
s
.
Add
(
tid
)
}
return
s
}
δ1
:=
δ
{
1
:
{
1
,
2
}}
δ2
:=
δ
{
2
:
{
2
,
3
}};
δ22
:=
δ
{
22
:
{
0
,
1
}};
δ2_22
:=
δ
{
2
:
{
2
,
3
},
22
:
{
0
,
1
}}
δ3
:=
δ
{
3
:
{
3
,
4
}}
δ4
:=
δ
{
4
:
{
4
,
5
}};
δ44
:=
δ
{
44
:
{
0
,
1
}};
δ4_44
:=
δ
{
4
:
{
4
,
5
},
44
:
{
0
,
1
}}
δ5
:=
δ
{
5
:
{
5
,
6
}}
δ12
:=
δ
{
1
:
{
1
,
2
},
2
:
{
2
,
3
}}
Δ101
:=
Δ
{
0x101
,
δ1
}
Δ102
:=
Δ
{
0x102
,
δ2
}
Δ103
:=
Δ
{
0x103
,
δ3
}
Δ104
:=
Δ
{
0x104
,
δ4
}
Δ105
:=
Δ
{
0x105
,
δ5
}
// merge1
assertMerge1
(
nil
,
Δ
{
0x100
,
nil
},
false
,
nil
)
assertMerge1
(
v
(
Δ
{
0x100
,
δ1
}),
Δ
{
0x100
,
δ2
},
false
,
v
(
Δ
{
0x100
,
δ12
}))
assertMerge1
(
v
(
Δ101
,
Δ103
),
Δ102
,
true
,
v
(
Δ101
,
Δ102
,
Δ103
))
assertMerge1
(
v
(
Δ101
,
Δ102
),
Δ103
,
true
,
v
(
Δ101
,
Δ102
,
Δ103
))
assertMerge1
(
v
(
Δ102
,
Δ103
),
Δ101
,
true
,
v
(
Δ101
,
Δ102
,
Δ103
))
// merge
assertMerge
(
nil
,
nil
,
r
(),
nil
)
assertMerge
(
nil
,
v
(
Δ101
,
Δ103
),
r
(
0x101
,
0x103
),
v
(
Δ101
,
Δ103
))
assertMerge
(
v
(
Δ101
,
Δ103
),
nil
,
r
(),
v
(
Δ101
,
Δ103
))
assertMerge
(
v
(
Δ102
,
Δ104
),
v
(
Δ101
,
Δ
{
0x102
,
δ22
},
Δ103
,
Δ
{
0x104
,
δ44
},
Δ105
),
r
(
0x101
,
0x103
,
0x105
),
v
(
Δ101
,
Δ
{
0x102
,
δ2_22
},
Δ103
,
Δ
{
0x104
,
δ4_44
},
Δ105
))
}
// -------- KAdj --------
...
...
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