Created
May 18, 2020 20:20
-
-
Save alexcrichton/76b358ad212520da70a99d6d13c412c5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/cargo/ops/resolve.rs b/src/cargo/ops/resolve.rs | |
index ec12f6786..611996013 100644 | |
--- a/src/cargo/ops/resolve.rs | |
+++ b/src/cargo/ops/resolve.rs | |
@@ -238,7 +238,7 @@ pub fn resolve_with_previous<'cfg>( | |
let mut try_to_use = HashSet::new(); | |
if let Some(r) = previous { | |
trace!("previous: {:?}", r); | |
- register_previous_locks(ws, registry, r, &keep); | |
+ register_previous_locks(ws, registry, r, register_patches, &keep)?; | |
// Everything in the previous lock file we want to keep is prioritized | |
// in dependency selection if it comes up, aka we want to have | |
@@ -246,35 +246,12 @@ pub fn resolve_with_previous<'cfg>( | |
try_to_use.extend(r.iter().filter(keep).inspect(|id| { | |
debug!("attempting to prefer {}", id); | |
})); | |
- } | |
- | |
- if register_patches { | |
+ } else if register_patches { | |
for (url, patches) in ws.root_patch() { | |
- let previous = match previous { | |
- Some(r) => r, | |
- None => { | |
- registry.patch(url, patches)?; | |
- continue; | |
- } | |
- }; | |
- let patches = patches | |
- .iter() | |
- .map(|dep| { | |
- let unused = previous.unused_patches().iter().cloned(); | |
- let candidates = previous.iter().chain(unused); | |
- match candidates.filter(keep).find(|&id| dep.matches_id(id)) { | |
- Some(id) => { | |
- let mut dep = dep.clone(); | |
- dep.lock_to(id); | |
- dep | |
- } | |
- None => dep.clone(), | |
- } | |
- }) | |
- .collect::<Vec<_>>(); | |
registry.patch(url, &patches)?; | |
} | |
- | |
+ } | |
+ if register_patches { | |
registry.lock_patches(); | |
} | |
@@ -413,8 +390,9 @@ fn register_previous_locks( | |
ws: &Workspace<'_>, | |
registry: &mut PackageRegistry<'_>, | |
resolve: &Resolve, | |
+ register_patches: bool, | |
keep: &dyn Fn(&PackageId) -> bool, | |
-) { | |
+) -> CargoResult<()> { | |
let path_pkg = |id: SourceId| { | |
if !id.is_path() { | |
return None; | |
@@ -568,6 +546,28 @@ fn register_previous_locks( | |
registry.register_lock(node, deps); | |
} | |
+ if register_patches { | |
+ for (url, patches) in ws.root_patch() { | |
+ let patches = patches | |
+ .iter() | |
+ .map(|dep| { | |
+ let unused = resolve.unused_patches().iter().cloned(); | |
+ let candidates = resolve.iter().chain(unused); | |
+ match candidates.filter(keep).find(|&id| dep.matches_id(id)) { | |
+ Some(id) => { | |
+ let mut dep = dep.clone(); | |
+ dep.lock_to(id); | |
+ dep | |
+ } | |
+ None => dep.clone(), | |
+ } | |
+ }) | |
+ .collect::<Vec<_>>(); | |
+ registry.patch(url, &patches)?; | |
+ } | |
+ } | |
+ return Ok(()); | |
+ | |
/// Recursively add `node` and all its transitive dependencies to `set`. | |
fn add_deps(resolve: &Resolve, node: PackageId, set: &mut HashSet<PackageId>) { | |
if !set.insert(node) { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment