mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-05-30 04:20:53 +00:00
Fix diff algorithm for reflists with duplicate entries. #57
This commit is contained in:
+17
-14
@@ -194,25 +194,28 @@ func (l *PackageRefList) Diff(r *PackageRefList, packageCollection *PackageColle
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// is pl & pr the same package, but different version?
|
// otherwise pl or pr is missing on one of the sides
|
||||||
if pl.Name == pr.Name && pl.Architecture == pr.Architecture {
|
if rel < 0 {
|
||||||
result = append(result, PackageDiff{Left: pl, Right: pr})
|
// compaction: +(,A) -(B,) --> !(A,B)
|
||||||
il++
|
if len(result) > 0 && result[len(result)-1].Left == nil && result[len(result)-1].Right.Name == pl.Name &&
|
||||||
ir++
|
result[len(result)-1].Right.Architecture == pl.Architecture {
|
||||||
pl, pr = nil, nil
|
result[len(result)-1] = PackageDiff{Left: pl, Right: result[len(result)-1].Right}
|
||||||
} else {
|
} else {
|
||||||
// otherwise pl or pr is missing on one of the sides
|
|
||||||
if rel < 0 {
|
|
||||||
result = append(result, PackageDiff{Left: pl, Right: nil})
|
result = append(result, PackageDiff{Left: pl, Right: nil})
|
||||||
il++
|
}
|
||||||
pl = nil
|
il++
|
||||||
|
pl = nil
|
||||||
|
} else {
|
||||||
|
// compaction: -(A,) +(,B) --> !(A,B)
|
||||||
|
if len(result) > 0 && result[len(result)-1].Right == nil && result[len(result)-1].Left.Name == pr.Name &&
|
||||||
|
result[len(result)-1].Left.Architecture == pr.Architecture {
|
||||||
|
result[len(result)-1] = PackageDiff{Left: result[len(result)-1].Left, Right: pr}
|
||||||
} else {
|
} else {
|
||||||
result = append(result, PackageDiff{Left: nil, Right: pr})
|
result = append(result, PackageDiff{Left: nil, Right: pr})
|
||||||
ir++
|
|
||||||
pr = nil
|
|
||||||
}
|
}
|
||||||
|
ir++
|
||||||
|
pr = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user