"bufstream 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"crates-io 0.2.0",
"crossbeam 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
- "curl 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)",
+ "curl 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)",
"docopt 0.6.78 (registry+https://github.com/rust-lang/crates.io-index)",
"env_logger 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
"filetime 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
"flate2 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)",
"fs2 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
- "git2 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "git2-curl 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "git2 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
+ "git2-curl 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
"glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
"hamcrest 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"kernel32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
- "libgit2-sys 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libgit2-sys 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
"num_cpus 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
"regex 0.1.58 (registry+https://github.com/rust-lang/crates.io-index)",
"term 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)",
"time 0.1.34 (registry+https://github.com/rust-lang/crates.io-index)",
"toml 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)",
- "url 0.2.38 (registry+https://github.com/rust-lang/crates.io-index)",
+ "url 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
]
name = "crates-io"
version = "0.2.0"
dependencies = [
- "curl 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)",
+ "curl 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-serialize 0.3.18 (registry+https://github.com/rust-lang/crates.io-index)",
- "url 0.2.38 (registry+https://github.com/rust-lang/crates.io-index)",
+ "url 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
[[package]]
name = "curl"
-version = "0.2.18"
+version = "0.2.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"curl-sys 0.1.34 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
"openssl-sys 0.7.8 (registry+https://github.com/rust-lang/crates.io-index)",
- "url 0.5.7 (registry+https://github.com/rust-lang/crates.io-index)",
+ "url 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
[[package]]
name = "git2"
-version = "0.4.2"
+version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"bitflags 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
- "libgit2-sys 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "url 0.5.7 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libgit2-sys 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
+ "url 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "git2-curl"
-version = "0.4.0"
+version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
- "curl 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)",
- "git2 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "curl 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)",
+ "git2 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
- "url 0.5.7 (registry+https://github.com/rust-lang/crates.io-index)",
+ "url 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
"num 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)",
]
+[[package]]
+name = "idna"
+version = "0.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "matches 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "unicode-bidi 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
+ "unicode-normalization 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
[[package]]
name = "kernel32-sys"
version = "0.2.1"
[[package]]
name = "libgit2-sys"
-version = "0.4.2"
+version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cmake 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)",
[[package]]
name = "url"
-version = "0.2.38"
+version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
+ "idna 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"matches 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "rustc-serialize 0.3.18 (registry+https://github.com/rust-lang/crates.io-index)",
- "uuid 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)",
-]
-
-[[package]]
-name = "url"
-version = "0.5.7"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-dependencies = [
- "matches 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "rustc-serialize 0.3.18 (registry+https://github.com/rust-lang/crates.io-index)",
- "unicode-bidi 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
- "unicode-normalization 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "uuid 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-[[package]]
-name = "uuid"
-version = "0.1.18"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-dependencies = [
- "rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
- "rustc-serialize 0.3.18 (registry+https://github.com/rust-lang/crates.io-index)",
-]
-
[[package]]
name = "winapi"
version = "0.2.6"
term = "0.4.4"
time = "0.1"
toml = "0.1"
-url = "0.2"
+url = "1.1"
winapi = "0.2"
[dev-dependencies]
use std::fmt;
use semver::Version;
-use url::{self, Url, UrlParser};
+use url::Url;
use core::PackageId;
use util::{CargoResult, ToUrl, human, ToSemver, ChainError};
Err(..) => {}
}
if !spec.contains("://") {
- match url(&format!("cargo://{}", spec)) {
+ match Url::parse(&format!("cargo://{}", spec)) {
Ok(url) => return PackageIdSpec::from_url(url),
Err(..) => {}
}
}
fn from_url(mut url: Url) -> CargoResult<PackageIdSpec> {
- if url.query.is_some() {
+ if url.query().is_some() {
bail!("cannot have a query string in a pkgid: {}", url)
}
- let frag = url.fragment.take();
+ let frag = url.fragment().map(|s| s.to_owned());
+ url.set_fragment(None);
let (name, version) = {
- let path = try!(url.path().chain_error(|| {
+ let mut path = try!(url.path_segments().chain_error(|| {
human(format!("pkgid urls must have a path: {}", url))
}));
- let path_name = try!(path.last().chain_error(|| {
+ let path_name = try!(path.next_back().chain_error(|| {
human(format!("pkgid urls must have at least one path \
component: {}", url))
}));
}
}
-fn url(s: &str) -> url::ParseResult<Url> {
- return UrlParser::new().scheme_type_mapper(mapper).parse(s);
-
- fn mapper(scheme: &str) -> url::SchemeType {
- if scheme == "cargo" {
- url::SchemeType::Relative(1)
- } else {
- url::whatwg_scheme_type_mapper(scheme)
- }
- }
-
-}
-
impl fmt::Display for PackageIdSpec {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let mut printed_name = false;
match self.url {
Some(ref url) => {
- if url.scheme == "cargo" {
- try!(write!(f, "{}/{}", url.host().unwrap(),
- url.path().unwrap().join("/")));
+ if url.scheme() == "cargo" {
+ try!(write!(f, "{}{}", url.host().unwrap(), url.path()));
} else {
try!(write!(f, "{}", url));
}
- if url.path().unwrap().last().unwrap() != &self.name {
+ if url.path_segments().unwrap().next_back().unwrap() != &self.name {
printed_name = true;
try!(write!(f, "#{}", self.name));
}
#[cfg(test)]
mod tests {
use core::{PackageId, SourceId};
- use super::{PackageIdSpec, url};
+ use super::PackageIdSpec;
use url::Url;
use semver::Version;
ok("http://crates.io/foo#1.2.3", PackageIdSpec {
name: "foo".to_string(),
version: Some(Version::parse("1.2.3").unwrap()),
- url: Some(url("http://crates.io/foo").unwrap()),
+ url: Some(Url::parse("http://crates.io/foo").unwrap()),
});
ok("http://crates.io/foo#bar:1.2.3", PackageIdSpec {
name: "bar".to_string(),
version: Some(Version::parse("1.2.3").unwrap()),
- url: Some(url("http://crates.io/foo").unwrap()),
+ url: Some(Url::parse("http://crates.io/foo").unwrap()),
});
ok("crates.io/foo", PackageIdSpec {
name: "foo".to_string(),
version: None,
- url: Some(url("cargo://crates.io/foo").unwrap()),
+ url: Some(Url::parse("cargo://crates.io/foo").unwrap()),
});
ok("crates.io/foo#1.2.3", PackageIdSpec {
name: "foo".to_string(),
version: Some(Version::parse("1.2.3").unwrap()),
- url: Some(url("cargo://crates.io/foo").unwrap()),
+ url: Some(Url::parse("cargo://crates.io/foo").unwrap()),
});
ok("crates.io/foo#bar", PackageIdSpec {
name: "bar".to_string(),
version: None,
- url: Some(url("cargo://crates.io/foo").unwrap()),
+ url: Some(Url::parse("cargo://crates.io/foo").unwrap()),
});
ok("crates.io/foo#bar:1.2.3", PackageIdSpec {
name: "bar".to_string(),
version: Some(Version::parse("1.2.3").unwrap()),
- url: Some(url("cargo://crates.io/foo").unwrap()),
+ url: Some(Url::parse("cargo://crates.io/foo").unwrap()),
});
ok("foo", PackageIdSpec {
name: "foo".to_string(),
use std::collections::hash_map::{HashMap, Values, IterMut};
use std::fmt::{self, Formatter};
use std::hash;
-use std::mem;
use std::path::Path;
use std::sync::Arc;
use rustc_serialize::{Decodable, Decoder, Encodable, Encoder};
"git" => {
let mut url = url.to_url().unwrap();
let mut reference = GitReference::Branch("master".to_string());
- let pairs = url.query_pairs().unwrap_or(Vec::new());
- for &(ref k, ref v) in pairs.iter() {
+ for (k, v) in url.query_pairs() {
match &k[..] {
// map older 'ref' to branch
"branch" |
- "ref" => reference = GitReference::Branch(v.clone()),
+ "ref" => reference = GitReference::Branch(v.into_owned()),
- "rev" => reference = GitReference::Rev(v.clone()),
- "tag" => reference = GitReference::Tag(v.clone()),
+ "rev" => reference = GitReference::Rev(v.into_owned()),
+ "tag" => reference = GitReference::Tag(v.into_owned()),
_ => {}
}
}
- url.query = None;
- let precise = mem::replace(&mut url.fragment, None);
+ let precise = url.fragment().map(|s| s.to_owned());
+ url.set_fragment(None);
+ url.set_query(None);
SourceId::for_git(&url, reference).with_precise(precise)
}
"registry" => {
use std::fmt::{self, Debug, Formatter};
use std::hash::{Hash, Hasher, SipHasher};
-use std::mem;
-use url::{self, Url};
+use url::Url;
use core::source::{Source, SourceId};
use core::GitReference;
fn ident(url: &Url) -> String {
let mut hasher = SipHasher::new_with_keys(0,0);
- // FIXME: this really should be able to not use to_str() everywhere, but the
- // compiler seems to currently ask for static lifetimes spuriously.
- // Perhaps related to rust-lang/rust#15144
let url = canonicalize_url(url);
- let ident = url.path().unwrap_or(&[])
- .last().map(|a| a.clone()).unwrap_or(String::new());
+ let ident = url.path_segments().and_then(|mut s| s.next_back()).unwrap_or("");
let ident = if ident == "" {
- "_empty".to_string()
+ "_empty"
} else {
ident
};
let mut url = url.clone();
// Strip a trailing slash
- if let url::SchemeData::Relative(ref mut rel) = url.scheme_data {
- if rel.path.last().map(|s| s.is_empty()).unwrap_or(false) {
- rel.path.pop();
- }
- }
+ url.path_segments_mut().unwrap().pop_if_empty();
// HACKHACK: For github URL's specifically just lowercase
// everything. GitHub treats both the same, but they hash
// differently, and we're gonna be hashing them. This wants a more
// general solution, and also we're almost certainly not using the
// same case conversion rules that GitHub does. (#84)
- if url.domain() == Some("github.com") {
- url.scheme = "https".to_string();
- if let url::SchemeData::Relative(ref mut rel) = url.scheme_data {
- rel.port = Some(443);
- rel.default_port = Some(443);
- let path = mem::replace(&mut rel.path, Vec::new());
- rel.path = path.into_iter().map(|s| {
- s.chars().flat_map(|c| c.to_lowercase()).collect()
- }).collect();
- }
+ if url.host_str() == Some("github.com") {
+ url.set_scheme("https").unwrap();
+ let path = url.path().to_lowercase();
+ url.set_path(&path);
}
// Repos generally can be accessed with or w/o '.git'
- if let url::SchemeData::Relative(ref mut rel) = url.scheme_data {
- let needs_chopping = {
- let last = rel.path.last().map(|s| &s[..]).unwrap_or("");
- last.ends_with(".git")
+ let needs_chopping = url.path().ends_with(".git");
+ if needs_chopping {
+ let last = {
+ let last = url.path_segments().unwrap().next_back().unwrap();
+ last[..last.len() - 4].to_owned()
};
- if needs_chopping {
- let last = rel.path.pop().unwrap();
- rel.path.push(last[..last.len() - 4].to_string())
- }
+ url.path_segments_mut().unwrap().pop().push(&last);
}
url
pub fn new(source_id: &SourceId,
config: &'cfg Config) -> RegistrySource<'cfg> {
let hash = hex::short_hash(source_id);
- let ident = source_id.url().host().unwrap().to_string();
+ let ident = source_id.url().host_str().unwrap_or("").to_string();
let part = format!("{}-{}", ident, hash);
RegistrySource {
checkout_path: config.registry_index_path().join(&part),
let config = try!(self.config());
let url = try!(config.dl.to_url().map_err(internal));
let mut url = url.clone();
- url.path_mut().unwrap().push(package.name().to_string());
- url.path_mut().unwrap().push(package.version().to_string());
- url.path_mut().unwrap().push("download".to_string());
+ url.path_segments_mut().unwrap()
+ .push(package.name())
+ .push(&package.version().to_string())
+ .push("download");
let krate = try!(self.download_package(package, &url).chain_error(|| {
internal(format!("failed to download package `{}` from {}",
package, url))
-use url::{self, Url, UrlParser};
+use url::Url;
use std::path::Path;
pub trait ToUrl {
impl<'a> ToUrl for &'a str {
fn to_url(self) -> Result<Url, String> {
- UrlParser::new().scheme_type_mapper(mapper).parse(self).map_err(|s| {
+ Url::parse(self).map_err(|s| {
format!("invalid url `{}`: {}", self, s)
})
}
})
}
}
-
-fn mapper(s: &str) -> url::SchemeType {
- match s {
- "git" => url::SchemeType::Relative(9418),
- "ssh" => url::SchemeType::Relative(22),
- s => url::whatwg_scheme_type_mapper(s),
- }
-}
[dependencies]
curl = "0.2"
-url = "0.2"
+url = "1.0"
rustc-serialize = "0.3"