@@ -113,11 +113,23 @@ pub struct PackageRegistry<'gctx> {
113
113
yanked_whitelist : HashSet < PackageId > ,
114
114
source_config : SourceConfigMap < ' gctx > ,
115
115
116
+ /// Patches registered during calls to [`PackageRegistry::patch`].
117
+ ///
118
+ /// These are available for `query` after calling [`PackageRegistry::lock_patches`],
119
+ /// which `lock`s them all to specific versions.
116
120
patches : HashMap < CanonicalUrl , Vec < Summary > > ,
117
121
/// Whether patches are locked. That is, they are available to resolution.
118
122
///
119
123
/// See [`PackageRegistry::lock_patches`] and [`PackageRegistry::patch`] for more.
120
124
patches_locked : bool ,
125
+ /// Patches available for each source.
126
+ ///
127
+ /// This is for determining whether a dependency entry from a lockfile
128
+ /// happened through `[patch]`, during calls to [`lock`] to rewrite
129
+ /// summaries to point directly at these patched entries.
130
+ ///
131
+ /// This is constructed during calls to [`PackageRegistry::patch`],
132
+ /// along with the `patches` field, thoough these entries never get locked.
121
133
patches_available : HashMap < CanonicalUrl , Vec < PackageId > > ,
122
134
}
123
135
@@ -453,25 +465,18 @@ impl<'gctx> PackageRegistry<'gctx> {
453
465
}
454
466
}
455
467
456
- // Calculate a list of all patches available for this source which is
457
- // then used later during calls to `lock` to rewrite summaries to point
458
- // directly at these patched entries.
459
- //
460
- // Note that this is somewhat subtle where the list of `ids` for a
461
- // canonical URL is extend with possibly two ids per summary. This is done
462
- // to handle the transition from the v2->v3 lock file format where in
463
- // v2 DefaultBranch was either DefaultBranch or Branch("master") for
464
- // git dependencies. In this case if `summary.package_id()` is
465
- // Branch("master") then alt_package_id will be DefaultBranch. This
466
- // signifies that there's a patch available for either of those
467
- // dependency directives if we see them in the dependency graph.
468
- //
469
- // This is a bit complicated and hopefully an edge case we can remove
470
- // in the future, but for now it hopefully doesn't cause too much
471
- // harm...
468
+ // Calculate a list of all patches available for this source.
472
469
let mut ids = Vec :: new ( ) ;
473
470
for ( summary, ( _, lock) ) in unlocked_summaries. iter ( ) . zip ( patch_deps) {
474
471
ids. push ( summary. package_id ( ) ) ;
472
+ // This is subtle where the list of `ids` for a canonical URL is
473
+ // extend with possibly two ids per summary. This is done to handle
474
+ // the transition from the v2->v3 lock file format where in v2
475
+ // DefaultBranch was either DefaultBranch or Branch("master") for
476
+ // git dependencies. In this case if `summary.package_id()` is
477
+ // Branch("master") then alt_package_id will be DefaultBranch. This
478
+ // signifies that there's a patch available for either of those
479
+ // dependency directives if we see them in the dependency graph.
475
480
if let Some ( lock) = lock {
476
481
ids. extend ( lock. alt_package_id ) ;
477
482
}
0 commit comments