Commit 124a8543 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 4b24bab6
...@@ -332,10 +332,10 @@ func (tidx trackIndex) verify() { ...@@ -332,10 +332,10 @@ func (tidx trackIndex) verify() {
// //
// In other words it removes B nodes from A while still maintaining A as P-connected. // In other words it removes B nodes from A while still maintaining A as P-connected.
func (A trackIndex) DifferenceInplace(B trackIndex) { func (A trackIndex) DifferenceInplace(B trackIndex) {
//fmt.Printf("\n\nDifferenceInplace:\n") fmt.Printf("\n\nDifferenceInplace:\n")
//fmt.Printf(" A: %s\n", A) fmt.Printf(" A: %s\n", A)
//fmt.Printf(" B: %s\n", B) fmt.Printf(" B: %s\n", B)
//defer fmt.Printf("->D: %s\n", A) defer fmt.Printf("->D: %s\n", A)
A.verify() A.verify()
B.verify() B.verify()
...@@ -402,10 +402,10 @@ func (A trackIndex) DifferenceInplace(B trackIndex) { ...@@ -402,10 +402,10 @@ func (A trackIndex) DifferenceInplace(B trackIndex) {
// //
// In other words it adds B nodes to A. // In other words it adds B nodes to A.
func (A trackIndex) UnionInplace(B trackIndex) { func (A trackIndex) UnionInplace(B trackIndex) {
//fmt.Printf("\n\nUnionInplace:\n") fmt.Printf("\n\nUnionInplace:\n")
//fmt.Printf(" A: %s\n", A) fmt.Printf(" A: %s\n", A)
//fmt.Printf(" B: %s\n", B) fmt.Printf(" B: %s\n", B)
//defer fmt.Printf("->U: %s\n", A) defer fmt.Printf("->U: %s\n", A)
A.verify() A.verify()
B.verify() B.verify()
...@@ -439,11 +439,11 @@ func (A trackIndex) UnionInplace(B trackIndex) { ...@@ -439,11 +439,11 @@ func (A trackIndex) UnionInplace(B trackIndex) {
// ApplyΔ applies δ to trackIdx. XXX // ApplyΔ applies δ to trackIdx. XXX
func (tidx trackIndex) ApplyΔ(δ *δtrackIndex) { func (tidx trackIndex) ApplyΔ(δ *δtrackIndex) {
//fmt.Printf("\n\nApplyΔ\n") fmt.Printf("\n\nApplyΔ\n")
//fmt.Printf(" A: %s\n", tidx) fmt.Printf(" A: %s\n", tidx)
//fmt.Printf(" -: %s\n", δ.Del) fmt.Printf(" -: %s\n", δ.Del)
//fmt.Printf(" +: %s\n", δ.Add) fmt.Printf(" +: %s\n", δ.Add)
//defer fmt.Printf("\n->B: %s\n", tidx) defer fmt.Printf("\n->B: %s\n", tidx)
tidx.verify() tidx.verify()
δ.Del.verify() δ.Del.verify()
...@@ -1414,9 +1414,11 @@ func diffT(ctx context.Context, A, B *Tree, δZTC SetOid, trackIdx trackIndex, h ...@@ -1414,9 +1414,11 @@ func diffT(ctx context.Context, A, B *Tree, δZTC SetOid, trackIdx trackIndex, h
// adjust trackIdx since path to the node could have changed // adjust trackIdx since path to the node could have changed
apath := trackIdx.Path(acOid) apath := trackIdx.Path(acOid)
bpath := BtrackIdx.Path(acOid) bpath := BtrackIdx.Path(acOid)
if !reflect.DeepEqual(apath, bpath) { if !pathEqual(apath, bpath) {
δtrack.Del.AddPath(apath)
δtrack.Add.AddPath(bpath) δtrack.Add.AddPath(bpath)
δtrack.Del.AddPath(apath)
// remove all nodes from under a XXX no
// XXX (a was not changed and nothing under a was changed) -> we just have to correct path till a.
} }
/* XXX kill /* XXX kill
...@@ -1878,6 +1880,19 @@ func pop(nodeStk *[]*nodeInRange) *nodeInRange { ...@@ -1878,6 +1880,19 @@ func pop(nodeStk *[]*nodeInRange) *nodeInRange {
return top return top
} }
// pathEqual returns whether two paths are the same.
func pathEqual(patha, pathb []zodb.Oid) bool {
if len(patha) != len(pathb) {
return false
}
for i, a := range patha {
if pathb[i] != a {
return false
}
}
return true
}
const debug = false const debug = false
func tracef(format string, argv ...interface{}) { func tracef(format string, argv ...interface{}) {
......
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