Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(622)

Side by Side Diff: vpython/spec/spec.go

Issue 2963503003: [errors] Greatly simplify common/errors package. (Closed)
Patch Set: fix nits Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « vpython/spec/load.go ('k') | vpython/venv/config.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2017 The LUCI Authors. All rights reserved. 1 // Copyright 2017 The LUCI Authors. All rights reserved.
2 // Use of this source code is governed under the Apache License, Version 2.0 2 // Use of this source code is governed under the Apache License, Version 2.0
3 // that can be found in the LICENSE file. 3 // that can be found in the LICENSE file.
4 4
5 package spec 5 package spec
6 6
7 import ( 7 import (
8 "crypto/sha256" 8 "crypto/sha256"
9 "encoding/hex" 9 "encoding/hex"
10 "fmt" 10 "fmt"
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 pos++ 63 pos++
64 } 64 }
65 spec.Wheel = spec.Wheel[:pos] 65 spec.Wheel = spec.Wheel[:pos]
66 66
67 sort.Sort(specPackageSlice(spec.Wheel)) 67 sort.Sort(specPackageSlice(spec.Wheel))
68 68
69 // No duplicate packages. Since we're sorted, we can just check for no 69 // No duplicate packages. Since we're sorted, we can just check for no
70 // immediate repetitions. 70 // immediate repetitions.
71 for i, pkg := range spec.Wheel { 71 for i, pkg := range spec.Wheel {
72 if i > 0 && pkg.Name == spec.Wheel[i-1].Name { 72 if i > 0 && pkg.Name == spec.Wheel[i-1].Name {
73 » » » return errors.Reason("duplicate spec entries for package %(path)q"). 73 » » » return errors.Reason("duplicate spec entries for package %q", pkg.Name).Err()
74 » » » » D("name", pkg.Name).
75 » » » » Err()
76 } 74 }
77 } 75 }
78 76
79 return nil 77 return nil
80 } 78 }
81 79
82 // Hash hashes the contents of the supplied "spec" and "rt" and returns the 80 // Hash hashes the contents of the supplied "spec" and "rt" and returns the
83 // result as a hex-encoded string. 81 // result as a hex-encoded string.
84 // 82 //
85 // If not empty, the contents of extra are prefixed to hash string. This can 83 // If not empty, the contents of extra are prefixed to hash string. This can
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 func (s pep425TagSlice) Len() int { return len(s) } 127 func (s pep425TagSlice) Len() int { return len(s) }
130 func (s pep425TagSlice) Swap(i, j int) { s[i], s[j] = s[j], s[i] } 128 func (s pep425TagSlice) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
131 129
132 func (s pep425TagSlice) Less(i, j int) bool { 130 func (s pep425TagSlice) Less(i, j int) bool {
133 return sortby.Chain{ 131 return sortby.Chain{
134 func(i, j int) bool { return s[i].Python < s[j].Python }, 132 func(i, j int) bool { return s[i].Python < s[j].Python },
135 func(i, j int) bool { return s[i].Abi < s[j].Abi }, 133 func(i, j int) bool { return s[i].Abi < s[j].Abi },
136 func(i, j int) bool { return s[i].Platform < s[j].Platform }, 134 func(i, j int) bool { return s[i].Platform < s[j].Platform },
137 }.Use(i, j) 135 }.Use(i, j)
138 } 136 }
OLDNEW
« no previous file with comments | « vpython/spec/load.go ('k') | vpython/venv/config.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698