@@ -53,8 +53,8 @@ use core::io::WriterUtil;
53
53
use core::result::{Ok, Err};
54
54
use core::hashmap::linear::LinearMap;
55
55
use std::getopts::{optflag, optopt, opt_present};
56
- use std::map ::HashMap;
57
- use std::{map , json, tempfile, term, sort, getopts};
56
+ use std::oldmap ::HashMap;
57
+ use std::{oldmap , json, tempfile, term, sort, getopts};
58
58
use syntax::codemap::span;
59
59
use syntax::diagnostic::span_handler;
60
60
use syntax::diagnostic;
@@ -110,9 +110,9 @@ pub struct Cargo {
110
110
libdir: Path,
111
111
workdir: Path,
112
112
sourcedir: Path,
113
- sources: map ::HashMap<~str, @Source>,
113
+ sources: oldmap ::HashMap<~str, @Source>,
114
114
mut current_install: ~str,
115
- dep_cache: map ::HashMap<~str, bool>,
115
+ dep_cache: oldmap ::HashMap<~str, bool>,
116
116
opts: Options
117
117
}
118
118
@@ -490,7 +490,7 @@ pub fn parse_source(name: ~str, j: &json::Json) -> @Source {
490
490
}
491
491
492
492
pub fn try_parse_sources(filename: &Path,
493
- sources: map ::HashMap<~str, @Source>) {
493
+ sources: oldmap ::HashMap<~str, @Source>) {
494
494
if !os::path_exists(filename) { return; }
495
495
let c = io::read_whole_file_str(filename);
496
496
match json::from_str(c.get()) {
@@ -730,7 +730,7 @@ pub fn configure(opts: Options) -> Cargo {
730
730
need_dir(&c.libdir);
731
731
need_dir(&c.bindir);
732
732
733
- for sources.each_key | k| {
733
+ for sources.each_key_ref |& k| {
734
734
let mut s = sources.get(k);
735
735
load_source_packages(&c, s);
736
736
sources.insert(k, s);
@@ -748,7 +748,7 @@ pub fn configure(opts: Options) -> Cargo {
748
748
}
749
749
750
750
pub fn for_each_package(c: &Cargo, b: fn(s: @Source, p: &Package)) {
751
- for c.sources.each_value | v| {
751
+ for c.sources.each_value_ref |& v| {
752
752
for v.packages.each |p| {
753
753
b(v, p);
754
754
}
@@ -833,7 +833,7 @@ pub fn rustc_sysroot() -> ~str {
833
833
}
834
834
}
835
835
836
- pub fn install_source(c: &Cargo, path: &Path) {
836
+ pub fn install_source(c: &mut Cargo, path: &Path) {
837
837
debug!("source: %s", path.to_str());
838
838
os::change_dir(path);
839
839
@@ -872,7 +872,8 @@ pub fn install_source(c: &Cargo, path: &Path) {
872
872
}
873
873
}
874
874
875
- pub fn install_git(c: &Cargo, wd: &Path, url: ~str, reference: Option<~str>) {
875
+ pub fn install_git(c: &mut Cargo, wd: &Path, url: ~str,
876
+ reference: Option<~str>) {
876
877
run::program_output(~"git", ~[~"clone", url, wd.to_str()]);
877
878
if reference.is_some() {
878
879
let r = reference.get();
@@ -883,7 +884,7 @@ pub fn install_git(c: &Cargo, wd: &Path, url: ~str, reference: Option<~str>) {
883
884
install_source(c, wd);
884
885
}
885
886
886
- pub fn install_curl(c: &Cargo, wd: &Path, url: ~str) {
887
+ pub fn install_curl(c: &mut Cargo, wd: &Path, url: ~str) {
887
888
let tarpath = wd.push("pkg.tar");
888
889
let p = run::program_output(~"curl", ~[~"-f", ~"-s", ~"-o",
889
890
tarpath.to_str(), url]);
@@ -896,14 +897,14 @@ pub fn install_curl(c: &Cargo, wd: &Path, url: ~str) {
896
897
install_source(c, wd);
897
898
}
898
899
899
- pub fn install_file(c: &Cargo, wd: &Path, path: &Path) {
900
+ pub fn install_file(c: &mut Cargo, wd: &Path, path: &Path) {
900
901
run::program_output(~"tar", ~[~"-x", ~"--strip-components=1",
901
902
~"-C", wd.to_str(),
902
903
~"-f", path.to_str()]);
903
904
install_source(c, wd);
904
905
}
905
906
906
- pub fn install_package(c: &Cargo, src: ~str, wd: &Path, pkg: Package) {
907
+ pub fn install_package(c: &mut Cargo, src: ~str, wd: &Path, pkg: Package) {
907
908
let url = copy pkg.url;
908
909
let method = match pkg.method {
909
910
~"git" => ~"git",
@@ -922,15 +923,15 @@ pub fn install_package(c: &Cargo, src: ~str, wd: &Path, pkg: Package) {
922
923
}
923
924
924
925
pub fn cargo_suggestion(c: &Cargo, fallback: fn()) {
925
- if c.sources.size() == 0u {
926
+ if c.sources.is_empty() {
926
927
error(~"no sources defined - you may wish to run " +
927
928
~"`cargo init`");
928
929
return;
929
930
}
930
931
fallback();
931
932
}
932
933
933
- pub fn install_uuid(c: &Cargo, wd: &Path, uuid: ~str) {
934
+ pub fn install_uuid(c: &mut Cargo, wd: &Path, uuid: ~str) {
934
935
let mut ps = ~[];
935
936
for_each_package(c, |s, p| {
936
937
if p.uuid == uuid {
@@ -954,7 +955,7 @@ pub fn install_uuid(c: &Cargo, wd: &Path, uuid: ~str) {
954
955
}
955
956
}
956
957
957
- pub fn install_named(c: &Cargo, wd: &Path, name: ~str) {
958
+ pub fn install_named(c: &mut Cargo, wd: &Path, name: ~str) {
958
959
let mut ps = ~[];
959
960
for_each_package(c, |s, p| {
960
961
if p.name == name {
@@ -978,7 +979,8 @@ pub fn install_named(c: &Cargo, wd: &Path, name: ~str) {
978
979
}
979
980
}
980
981
981
- pub fn install_uuid_specific(c: &Cargo, wd: &Path, src: ~str, uuid: ~str) {
982
+ pub fn install_uuid_specific(c: &mut Cargo, wd: &Path, src: ~str,
983
+ uuid: ~str) {
982
984
match c.sources.find(src) {
983
985
Some(s) => {
984
986
for s.packages.each |p| {
@@ -993,7 +995,8 @@ pub fn install_uuid_specific(c: &Cargo, wd: &Path, src: ~str, uuid: ~str) {
993
995
error(~"can't find package: " + src + ~"/" + uuid);
994
996
}
995
997
996
- pub fn install_named_specific(c: &Cargo, wd: &Path, src: ~str, name: ~str) {
998
+ pub fn install_named_specific(c: &mut Cargo, wd: &Path, src: ~str,
999
+ name: ~str) {
997
1000
match c.sources.find(src) {
998
1001
Some(s) => {
999
1002
for s.packages.each |p| {
@@ -1060,7 +1063,7 @@ pub fn cmd_uninstall(c: &Cargo) {
1060
1063
}
1061
1064
}
1062
1065
1063
- pub fn install_query(c: &Cargo, wd: &Path, target: ~str) {
1066
+ pub fn install_query(c: &mut Cargo, wd: &Path, target: ~str) {
1064
1067
match c.dep_cache.find(target) {
1065
1068
Some(inst) => {
1066
1069
if inst {
@@ -1112,10 +1115,7 @@ pub fn install_query(c: &Cargo, wd: &Path, target: ~str) {
1112
1115
// a bit of a hack. It should be cleaned up in the future.
1113
1116
1114
1117
if target == c.current_install {
1115
- for c.dep_cache.each |k, _v| {
1116
- c.dep_cache.remove(k);
1117
- }
1118
-
1118
+ c.dep_cache.clear();
1119
1119
c.current_install = ~"";
1120
1120
}
1121
1121
}
@@ -1128,7 +1128,7 @@ pub fn get_temp_workdir(c: &Cargo) -> Path {
1128
1128
}
1129
1129
}
1130
1130
1131
- pub fn cmd_install(c: &Cargo) {
1131
+ pub fn cmd_install(c: &mut Cargo) {
1132
1132
unsafe {
1133
1133
let wd = get_temp_workdir(c);
1134
1134
@@ -1155,7 +1155,7 @@ pub fn cmd_install(c: &Cargo) {
1155
1155
}
1156
1156
1157
1157
pub fn sync(c: &Cargo) {
1158
- for c.sources.each_key | k| {
1158
+ for c.sources.each_key_ref |& k| {
1159
1159
let mut s = c.sources.get(k);
1160
1160
sync_one(c, s);
1161
1161
c.sources.insert(k, s);
@@ -1569,7 +1569,7 @@ pub fn cmd_list(c: &Cargo) {
1569
1569
}
1570
1570
}
1571
1571
} else {
1572
- for c.sources.each_value | v| {
1572
+ for c.sources.each_value_ref |& v| {
1573
1573
print_source(v);
1574
1574
}
1575
1575
}
@@ -1620,7 +1620,7 @@ pub fn dump_cache(c: &Cargo) {
1620
1620
}
1621
1621
1622
1622
pub fn dump_sources(c: &Cargo) {
1623
- if c.sources.size() < 1u {
1623
+ if c.sources.is_empty() {
1624
1624
return;
1625
1625
}
1626
1626
@@ -1636,7 +1636,7 @@ pub fn dump_sources(c: &Cargo) {
1636
1636
result::Ok(writer) => {
1637
1637
let mut hash = ~LinearMap::new();
1638
1638
1639
- for c.sources.each | k, v| {
1639
+ for c.sources.each_ref |& k, & v| {
1640
1640
let mut chash = ~LinearMap::new();
1641
1641
1642
1642
chash.insert(~"url", json::String(v.url));
@@ -1675,7 +1675,7 @@ pub fn copy_warn(srcfile: &Path, destfile: &Path) {
1675
1675
1676
1676
pub fn cmd_sources(c: &Cargo) {
1677
1677
if vec::len(c.opts.free) < 3u {
1678
- for c.sources.each_value | v| {
1678
+ for c.sources.each_value_ref |& v| {
1679
1679
info(fmt!("%s (%s) via %s",
1680
1680
v.name, v.url, v.method));
1681
1681
}
@@ -1686,8 +1686,8 @@ pub fn cmd_sources(c: &Cargo) {
1686
1686
1687
1687
match action {
1688
1688
~"clear" => {
1689
- for c.sources.each_key | k| {
1690
- c.sources.remove(k);
1689
+ for c.sources.each_key_ref |& k| {
1690
+ c.sources.remove(& k);
1691
1691
}
1692
1692
1693
1693
info(~"cleared sources");
@@ -1706,7 +1706,7 @@ pub fn cmd_sources(c: &Cargo) {
1706
1706
return;
1707
1707
}
1708
1708
1709
- if c.sources.contains_key( name) {
1709
+ if c.sources.contains_key_ref(& name) {
1710
1710
error(fmt!("source already exists: %s", name));
1711
1711
} else {
1712
1712
c.sources.insert(name, @Source {
@@ -1733,8 +1733,8 @@ pub fn cmd_sources(c: &Cargo) {
1733
1733
return;
1734
1734
}
1735
1735
1736
- if c.sources.contains_key( name) {
1737
- c.sources.remove(name);
1736
+ if c.sources.contains_key_ref(& name) {
1737
+ c.sources.remove(& name);
1738
1738
info(fmt!("removed source: %s", name));
1739
1739
} else {
1740
1740
error(fmt!("no such source: %s", name));
@@ -1825,7 +1825,7 @@ pub fn cmd_sources(c: &Cargo) {
1825
1825
1826
1826
match c.sources.find(name) {
1827
1827
Some(source) => {
1828
- c.sources.remove(name);
1828
+ c.sources.remove(& name);
1829
1829
c.sources.insert(newn, source);
1830
1830
info(fmt!("renamed source: %s to %s", name, newn));
1831
1831
}
@@ -1967,7 +1967,7 @@ pub fn main() {
1967
1967
1968
1968
match o.free[1] {
1969
1969
~"init" => cmd_init(&c),
1970
- ~"install" => cmd_install(&c),
1970
+ ~"install" => cmd_install(&mut c),
1971
1971
~"uninstall" => cmd_uninstall(&c),
1972
1972
~"list" => cmd_list(&c),
1973
1973
~"search" => cmd_search(&c),
0 commit comments