@@ -34,11 +34,16 @@ if nothing is required, lockstep won't print anything.
34
34
opte support is missing
35
35
*/
36
36
37
+ use std:: cmp:: Ordering ;
37
38
use std:: collections:: BTreeMap ;
38
39
use std:: collections:: HashSet ;
40
+ use std:: hash;
41
+ use std:: hash:: Hash ;
39
42
use std:: path:: Path ;
43
+ use url:: Url ;
40
44
41
45
use anyhow:: { anyhow, bail, Result } ;
46
+ use cargo_lock:: package:: SourceKind ;
42
47
use cargo_toml:: Manifest ;
43
48
use glob:: glob;
44
49
use reqwest:: blocking:: Client ;
@@ -175,6 +180,46 @@ fn get_explicit_dependencies(
175
180
Ok ( ( ) )
176
181
}
177
182
183
+ // Implement SourceID like rust-lang/Cargo, not like in rustsec/rustsec (read:
184
+ // with manual impls)
185
+ #[ derive( Clone , Debug , Eq ) ]
186
+ struct MySourceId {
187
+ pub url : Url ,
188
+ pub kind : SourceKind ,
189
+ pub precise : Option < String > ,
190
+ }
191
+
192
+ impl PartialEq for MySourceId {
193
+ fn eq ( & self , other : & MySourceId ) -> bool {
194
+ self . cmp ( other) == Ordering :: Equal
195
+ }
196
+ }
197
+
198
+ impl PartialOrd for MySourceId {
199
+ fn partial_cmp ( & self , other : & MySourceId ) -> Option < Ordering > {
200
+ Some ( self . cmp ( other) )
201
+ }
202
+ }
203
+
204
+ impl Ord for MySourceId {
205
+ fn cmp ( & self , other : & MySourceId ) -> Ordering {
206
+ // Ignore precise and name
207
+ match self . kind . cmp ( & other. kind ) {
208
+ Ordering :: Equal => { }
209
+ other => return other,
210
+ } ;
211
+
212
+ self . url . cmp ( & other. url )
213
+ }
214
+ }
215
+
216
+ impl Hash for MySourceId {
217
+ fn hash < S : hash:: Hasher > ( & self , into : & mut S ) {
218
+ self . url . hash ( into) ;
219
+ self . kind . hash ( into) ;
220
+ }
221
+ }
222
+
178
223
fn check_cargo_lock_revisions (
179
224
sub_directory : & str ,
180
225
latest_revs : & BTreeMap < String , String > ,
@@ -189,6 +234,9 @@ fn check_cargo_lock_revisions(
189
234
dependencies
190
235
} ;
191
236
237
+ // Check for conflicting SourceId
238
+ let mut sources: HashSet < MySourceId > = HashSet :: new ( ) ;
239
+
192
240
for package in & cargo_lockfile. packages {
193
241
if let Some ( source) = & package. source {
194
242
let path = source. url ( ) . path ( ) ;
@@ -204,8 +252,8 @@ fn check_cargo_lock_revisions(
204
252
// for packages in a Cargo.toml
205
253
if dependencies. contains ( & package. name . to_string ( ) ) {
206
254
println ! (
207
- "{}/Cargo.lock has old rev for {} {}!" ,
208
- sub_directory, repo, package. name,
255
+ "{}/Cargo.lock has old rev for {} {}! update {} to {} " ,
256
+ sub_directory, repo, package. name, precise , latest_rev ,
209
257
) ;
210
258
}
211
259
}
@@ -216,9 +264,32 @@ fn check_cargo_lock_revisions(
216
264
}
217
265
}
218
266
}
267
+
268
+ let my_source_id = MySourceId {
269
+ url : source. url ( ) . clone ( ) ,
270
+ kind : source. kind ( ) . clone ( ) ,
271
+ precise : source. precise ( ) . map ( |x| x. to_string ( ) ) . clone ( ) ,
272
+ } ;
273
+
274
+ if let Some ( existing_source) = sources. get ( & my_source_id) {
275
+ if existing_source. precise == my_source_id. precise {
276
+ sources. insert ( my_source_id) ;
277
+ } else {
278
+ panic ! (
279
+ "{}/Cargo.lock has a mismatch for {:?} != {:?}!" ,
280
+ sub_directory, existing_source, my_source_id,
281
+ ) ;
282
+ }
283
+ } else {
284
+ sources. insert ( my_source_id) ;
285
+ }
219
286
}
220
287
}
221
288
289
+ for source in sources {
290
+ println ! ( "{}/Cargo.lock has source {:?}" , sub_directory, source) ;
291
+ }
292
+
222
293
Ok ( ( ) )
223
294
}
224
295
@@ -284,6 +355,8 @@ fn main() -> Result<()> {
284
355
// - update crucible cargo revs
285
356
// - update propolis cargo revs
286
357
358
+ check_cargo_lock_revisions ( "omicron" , & latest_revs) ?;
359
+
287
360
update_required |= compare_cargo_toml_revisions (
288
361
"omicron" ,
289
362
& Manifest :: from_path ( "./omicron/Cargo.toml" ) ?,
0 commit comments