@@ -113,11 +113,23 @@ pub struct PackageRegistry<'gctx> {
113113 yanked_whitelist : HashSet < PackageId > ,
114114 source_config : SourceConfigMap < ' gctx > ,
115115
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.
116120 patches : HashMap < CanonicalUrl , Vec < Summary > > ,
117121 /// Whether patches are locked. That is, they are available to resolution.
118122 ///
119123 /// See [`PackageRegistry::lock_patches`] and [`PackageRegistry::patch`] for more.
120124 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.
121133 patches_available : HashMap < CanonicalUrl , Vec < PackageId > > ,
122134}
123135
@@ -453,25 +465,18 @@ impl<'gctx> PackageRegistry<'gctx> {
453465 }
454466 }
455467
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.
472469 let mut ids = Vec :: new ( ) ;
473470 for ( summary, ( _, lock) ) in unlocked_summaries. iter ( ) . zip ( patch_deps) {
474471 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.
475480 if let Some ( lock) = lock {
476481 ids. extend ( lock. alt_package_id ) ;
477482 }
0 commit comments