Don't lock overrides if we're updating them

There was already a function for this, `keep`, it was just forgotten to be
called.

Closes #2766
This commit is contained in:
Alex Crichton 2016-06-05 00:19:55 -07:00
parent 7d79da0823
commit feccad0fee
3 changed files with 44 additions and 5 deletions

View file

@ -37,10 +37,8 @@ pub fn update_lockfile(manifest_path: &Path,
let package = try!(Package::for_path(manifest_path, opts.config));
let previous_resolve = match try!(ops::load_pkg_lockfile(&package, opts.config)) {
Some(resolve) => resolve,
None => {
return generate_lockfile(manifest_path, opts.config);
}
Some(resolve) => resolve,
None => return generate_lockfile(manifest_path, opts.config),
};
let mut registry = PackageRegistry::new(opts.config);
let mut to_avoid = HashSet::new();

View file

@ -105,7 +105,9 @@ pub fn resolve_with_previous<'a>(registry: &mut PackageRegistry,
let replace = package.manifest().replace();
let replace = replace.iter().map(|&(ref spec, ref dep)| {
for (key, val) in r.replacements().iter() {
if spec.matches(key) && dep.matches_id(val) {
if spec.matches(key) &&
dep.matches_id(val) &&
keep(&val, to_avoid, &to_avoid_sources) {
return (spec.clone(), dep.clone().lock_to(val))
}
}

View file

@ -578,3 +578,42 @@ Please re-run this command with [..]
[..]#foo:0.1.0
"));
}
#[test]
fn update() {
Package::new("foo", "0.1.0").publish();
let foo = git::repo(&paths::root().join("override"))
.file("Cargo.toml", r#"
[package]
name = "foo"
version = "0.1.0"
authors = []
"#)
.file("src/lib.rs", "pub fn foo() {}");
foo.build();
let p = project("local")
.file("Cargo.toml", &format!(r#"
[package]
name = "local"
version = "0.0.1"
authors = []
[dependencies]
foo = "0.1.0"
[replace]
"foo:0.1.0" = {{ git = '{0}' }}
"#, foo.url()))
.file("src/lib.rs", "");
assert_that(p.cargo_process("generate-lockfile"),
execs().with_status(0));
assert_that(p.cargo("update"),
execs().with_status(0)
.with_stderr("\
[UPDATING] registry `[..]`
[UPDATING] git repository `[..]`
"));
}