From: gibix Date: Mon, 19 Mar 2018 17:43:02 +0000 (+0100) Subject: fix #2773 with new precise encode X-Git-Tag: archive/raspbian/0.35.0-2+rpi1~3^2^2^2^2^2^2^2~22^2~2^2~6^2~4 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=882ff473d5f45dff2d537daf9cdf05ea96db96ed;p=cargo.git fix #2773 with new precise encode --- 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, });