From 882ff473d5f45dff2d537daf9cdf05ea96db96ed Mon Sep 17 00:00:00 2001 From: gibix Date: Mon, 19 Mar 2018 18:43:02 +0100 Subject: [PATCH] fix #2773 with new precise encode --- src/cargo/ops/cargo_generate_lockfile.rs | 2 +- src/cargo/sources/registry/index.rs | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/cargo/ops/cargo_generate_lockfile.rs b/src/cargo/ops/cargo_generate_lockfile.rs index c9a61266a..741974e3b 100644 --- a/src/cargo/ops/cargo_generate_lockfile.rs +++ b/src/cargo/ops/cargo_generate_lockfile.rs @@ -69,7 +69,7 @@ pub fn update_lockfile(ws: &Workspace, opts: &UpdateOptions) -> CargoResult<()> // seems like a pretty hokey reason to single out // the registry as well. let precise = if dep.source_id().is_registry() { - format!("{}={}", dep.name(), precise) + format!("{}={}->{}", dep.name(), dep.version(), precise) } else { precise.to_string() }; diff --git a/src/cargo/sources/registry/index.rs b/src/cargo/sources/registry/index.rs index eb07c24e8..b47ac26ce 100644 --- a/src/cargo/sources/registry/index.rs +++ b/src/cargo/sources/registry/index.rs @@ -179,13 +179,18 @@ impl<'cfg> RegistryIndex<'cfg> { .map(|s| s.0.clone()); // Handle `cargo update --precise` here. If specified, our own source - // will have a precise version listed of the form `=` where - // `` is the name of a crate on this source and `` is the + // will have a precise version listed of the form + // `=o->` where `` is the name of a crate on + // this source, `` is the version installed and ` is the // version requested (argument to `--precise`). let summaries = summaries.filter(|s| match source_id.precise() { Some(p) if p.starts_with(&*dep.name()) && p[dep.name().len()..].starts_with('=') => { - let vers = &p[dep.name().len() + 1..]; - s.version().to_string() == vers + let vers: Vec<&str> = p[dep.name().len() + 1..].split("->").collect(); + if dep.version_req().matches(&Version::parse(vers[0]).unwrap()) { + return vers[1] == s.version().to_string() + } + + true } _ => true, }); -- 2.30.2