From: Chris Swindle Date: Mon, 6 Nov 2017 21:08:22 +0000 (+0000) Subject: Sort out bug with updating registry on a clean build. X-Git-Tag: archive/raspbian/0.35.0-2+rpi1~3^2^2^2^2^2^2^2~22^2~5^2~1^2~1 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=4a302acce1a3033944914b6bb3b355c1c446cea1;p=cargo.git Sort out bug with updating registry on a clean build. --- diff --git a/src/cargo/core/source/source_id.rs b/src/cargo/core/source/source_id.rs index 4d0ef32c9..350437055 100644 --- a/src/cargo/core/source/source_id.rs +++ b/src/cargo/core/source/source_id.rs @@ -32,6 +32,8 @@ struct SourceIdInner { kind: Kind, // e.g. the exact git revision of the specified branch for a Git Source precise: Option, + /// Name of the registry source for alternative registries + name: Option, } /// The possible kinds of code source. Along with a URL, this fully defines the @@ -44,8 +46,6 @@ enum Kind { Path, /// represents a remote registry Registry, - /// represents a remote alternative registry - AltRegistry, /// represents a local filesystem-based registry LocalRegistry, /// represents a directory-based registry @@ -74,6 +74,7 @@ impl SourceId { canonical_url: git::canonicalize_url(&url)?, url: url, precise: None, + name: None, }), }; Ok(source_id) @@ -188,10 +189,11 @@ impl SourceId { let url = config.get_registry_index(key)?; Ok(SourceId { inner: Arc::new(SourceIdInner { - kind: Kind::AltRegistry, + kind: Kind::Registry, canonical_url: git::canonicalize_url(&url)?, url: url, precise: None, + name: Some(key.to_string()), }), }) } @@ -213,14 +215,14 @@ impl SourceId { /// Is this source from a registry (either local or not) pub fn is_registry(&self) -> bool { match self.inner.kind { - Kind::Registry | Kind::AltRegistry | Kind::LocalRegistry => true, - _ => false, + Kind::Registry | Kind::LocalRegistry => true, + _ => false, } } /// Is this source from an alternative registry pub fn is_alt_registry(&self) -> bool { - self.inner.kind == Kind::AltRegistry + self.is_registry() && self.inner.name.is_some() } /// Is this source from a git repository @@ -243,7 +245,7 @@ impl SourceId { }; Ok(Box::new(PathSource::new(&path, self, config))) } - Kind::Registry | Kind::AltRegistry => Ok(Box::new(RegistrySource::remote(self, config))), + Kind::Registry => Ok(Box::new(RegistrySource::remote(self, config))), Kind::LocalRegistry => { let path = match self.inner.url.to_file_path() { Ok(p) => p, @@ -368,7 +370,6 @@ impl fmt::Display for SourceId { Ok(()) } SourceIdInner { kind: Kind::Registry, ref url, .. } | - SourceIdInner { kind: Kind::AltRegistry, ref url, .. } | SourceIdInner { kind: Kind::LocalRegistry, ref url, .. } => { write!(f, "registry `{}`", url) } @@ -466,8 +467,7 @@ impl<'a> fmt::Display for SourceIdToUrl<'a> { } Ok(()) } - SourceIdInner { kind: Kind::Registry, ref url, .. } | - SourceIdInner { kind: Kind::AltRegistry, ref url, .. } => { + SourceIdInner { kind: Kind::Registry, ref url, .. } => { write!(f, "registry+{}", url) } SourceIdInner { kind: Kind::LocalRegistry, ref url, .. } => { diff --git a/tests/alt-registry.rs b/tests/alt-registry.rs index 52e1842c4..fa8c15b8d 100644 --- a/tests/alt-registry.rs +++ b/tests/alt-registry.rs @@ -65,13 +65,11 @@ fn depend_on_alt_registry() { // Don't download a second time assert_that(p.cargo("build").masquerade_as_nightly_cargo(), execs().with_status(0).with_stderr(&format!("\ -[UPDATING] registry `{reg}` [COMPILING] bar v0.0.1 (registry `file://[..]`) [COMPILING] foo v0.0.1 ({dir}) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] secs ", - dir = p.url(), - reg = registry::alt_registry()))); + dir = p.url()))); } #[test]