fix #2773 with new precise encode
authorgibix <gibix@riseup.net>
Mon, 19 Mar 2018 17:43:02 +0000 (18:43 +0100)
committergibix <gibix@riseup.net>
Sat, 24 Mar 2018 18:16:52 +0000 (19:16 +0100)
src/cargo/ops/cargo_generate_lockfile.rs
src/cargo/sources/registry/index.rs

index c9a61266a098ecb0bbc8c9b22a940f2d7812c03b..741974e3b3521bcee82a21c0c1d234b3e28f6aa5 100644 (file)
@@ -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()
                         };
index eb07c24e873959dee35083c254b6932324084818..b47ac26ce17c5d706585ee2225ee35b26bfdbc76 100644 (file)
@@ -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 `<pkg>=<req>` where
-        // `<pkg>` is the name of a crate on this source and `<req>` is the
+        // will have a precise version listed of the form
+        // `<pkg>=<p_req>o-><f_req>` where `<pkg>` is the name of a crate on
+        // this source, `<p_req>` is the version installed and `<f_req> 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,
         });