snapshot: FilterLatestRefs returns nothing as it deals with a pointer.

This commit is contained in:
Ryan Uber
2014-04-22 23:33:30 -07:00
parent 708fd800df
commit 6c3b2f686e
3 changed files with 9 additions and 9 deletions
+1 -1
View File
@@ -38,7 +38,7 @@ func aptlySnapshotMerge(cmd *commander.Command, args []string) error {
}
if latest {
result = deb.FilterLatestRefs(result)
deb.FilterLatestRefs(result)
}
sourceDescription := make([]string, len(sources))
+5 -5
View File
@@ -286,10 +286,10 @@ func (l *PackageRefList) Merge(r *PackageRefList, overrideMatching bool) (result
}
// FilterLatestRefs takes in a reflist with potentially multiples of the same
// packages and returns a reflist containing only the latest of each package.
// This implements a "latest wins" approach which can be used while merging two
// or more snapshots together.
func FilterLatestRefs(r *PackageRefList) *PackageRefList {
// packages and reduces it to only the latest of each package. The operations
// are done in-place. This implements a "latest wins" approach which can be used
// while merging two or more snapshots together.
func FilterLatestRefs(r *PackageRefList) {
// A running tab of latest seen package refs.
latestRefs := make(map[string]int)
@@ -322,5 +322,5 @@ func FilterLatestRefs(r *PackageRefList) *PackageRefList {
i -= 1
}
return r
return
}
+3 -3
View File
@@ -304,9 +304,9 @@ func (s *PackageRefListSuite) TestFilterLatestRefs(c *C) {
rl.Add(packages[7])
rl.Add(packages[7])
prl := NewPackageRefListFromPackageList(rl)
merged := FilterLatestRefs(prl)
result := NewPackageRefListFromPackageList(rl)
FilterLatestRefs(result)
c.Check(toStrSlice(merged), DeepEquals,
c.Check(toStrSlice(result), DeepEquals,
[]string{"Pi386 dpkg 1.6", "Pi386 lib 1.2"})
}