@@ -572,7 +572,7 @@ fn load_one_source_package(src: source, p: map::HashMap<~str, json::Json>) {
572
572
log(debug, ~" loaded package: " + src.name + ~" /" + name);
573
573
}
574
574
575
- fn load_source_info(c: cargo, src: source) {
575
+ fn load_source_info(c: & cargo, src: source) {
576
576
let dir = c.sourcedir.push(src.name);
577
577
let srcfile = dir.push(" source. json ") ;
578
578
if !os:: path_exists ( & srcfile) { return ; }
@@ -593,7 +593,7 @@ fn load_source_info(c: cargo, src: source) {
593
593
}
594
594
} ;
595
595
}
596
- fn load_source_packages( c: cargo, src: source) {
596
+ fn load_source_packages( c: & cargo, src: source) {
597
597
log( debug, ~"loading source: " + src.name);
598
598
let dir = c.sourcedir.push(src.name);
599
599
let pkgfile = dir.push(" packages. json") ;
@@ -697,7 +697,7 @@ fn configure(opts: options) -> cargo {
697
697
698
698
for sources. each_key |k| {
699
699
let mut s = sources. get ( k) ;
700
- load_source_packages ( c, s) ;
700
+ load_source_packages ( & c, s) ;
701
701
sources. insert ( k, s) ;
702
702
}
703
703
@@ -712,7 +712,7 @@ fn configure(opts: options) -> cargo {
712
712
c
713
713
}
714
714
715
- fn for_each_package ( c : cargo , b : fn ( source , package ) ) {
715
+ fn for_each_package ( c : & cargo , b : fn ( source , package ) ) {
716
716
for c. sources. each_value |v| {
717
717
for v. packages. each |p| {
718
718
b( v, p) ;
@@ -746,7 +746,7 @@ fn run_in_buildpath(what: &str, path: &Path, subdir: &Path, cf: &Path,
746
746
Some ( buildpath)
747
747
}
748
748
749
- fn test_one_crate ( _c : cargo , path : & Path , cf : & Path ) {
749
+ fn test_one_crate ( _c : & cargo , path : & Path , cf : & Path ) {
750
750
let buildpath = match run_in_buildpath ( ~"testing", path,
751
751
& Path ( "test" ) ,
752
752
cf,
@@ -757,7 +757,7 @@ fn test_one_crate(_c: cargo, path: &Path, cf: &Path) {
757
757
run_programs ( & buildpath) ;
758
758
}
759
759
760
- fn install_one_crate ( c : cargo , path : & Path , cf : & Path ) {
760
+ fn install_one_crate ( c : & cargo , path : & Path , cf : & Path ) {
761
761
let buildpath = match run_in_buildpath ( ~"installing", path,
762
762
& Path ( "build" ) ,
763
763
cf, ~[ ] ) {
@@ -798,7 +798,7 @@ fn rustc_sysroot() -> ~str {
798
798
}
799
799
}
800
800
801
- fn install_source( c: cargo, path: & Path ) {
801
+ fn install_source( c: & cargo, path: & Path ) {
802
802
debug ! ( "source: %s" , path. to_str( ) ) ;
803
803
os:: change_dir( path) ;
804
804
@@ -837,7 +837,7 @@ fn install_source(c: cargo, path: &Path) {
837
837
}
838
838
}
839
839
840
- fn install_git( c: cargo, wd: & Path , url: ~str , reference: Option <~str >) {
840
+ fn install_git( c: & cargo, wd: & Path , url: ~str , reference: Option <~str >) {
841
841
run:: program_output( ~"git", ~[ ~"clone", url, wd. to_str( ) ] ) ;
842
842
if option:: is_some( reference) {
843
843
let r = option:: get( reference) ;
@@ -848,7 +848,7 @@ fn install_git(c: cargo, wd: &Path, url: ~str, reference: Option<~str>) {
848
848
install_source( c, wd) ;
849
849
}
850
850
851
- fn install_curl( c: cargo, wd: & Path , url: ~str ) {
851
+ fn install_curl( c: & cargo, wd: & Path , url: ~str ) {
852
852
let tarpath = wd. push( "pkg. tar") ;
853
853
let p = run:: program_output( ~"curl", ~[ ~"-f", ~"-s", ~"-o",
854
854
tarpath. to_str( ) , url] ) ;
@@ -861,14 +861,14 @@ fn install_curl(c: cargo, wd: &Path, url: ~str) {
861
861
install_source( c, wd) ;
862
862
}
863
863
864
- fn install_file( c: cargo, wd: & Path , path: & Path ) {
864
+ fn install_file( c: & cargo, wd: & Path , path: & Path ) {
865
865
run:: program_output( ~"tar", ~[ ~"-x", ~"--strip-components=1 ",
866
866
~"-C ", wd. to_str( ) ,
867
867
~"-f", path. to_str( ) ] ) ;
868
868
install_source( c, wd) ;
869
869
}
870
870
871
- fn install_package( c: cargo, src: ~str , wd: & Path , pkg: package) {
871
+ fn install_package( c: & cargo, src: ~str , wd: & Path , pkg: package) {
872
872
let url = copy pkg. url;
873
873
let method = match pkg. method {
874
874
~"git" => ~"git",
@@ -886,7 +886,7 @@ fn install_package(c: cargo, src: ~str, wd: &Path, pkg: package) {
886
886
}
887
887
}
888
888
889
- fn cargo_suggestion( c: cargo, fallback: fn ( ) )
889
+ fn cargo_suggestion( c: & cargo, fallback: fn ( ) )
890
890
{
891
891
if c. sources. size( ) == 0 u {
892
892
error( ~"no sources defined - you may wish to run " +
@@ -896,7 +896,7 @@ fn cargo_suggestion(c: cargo, fallback: fn())
896
896
fallback( ) ;
897
897
}
898
898
899
- fn install_uuid( c: cargo, wd: & Path , uuid: ~str ) {
899
+ fn install_uuid( c: & cargo, wd: & Path , uuid: ~str ) {
900
900
let mut ps = ~[ ] ;
901
901
for_each_package( c, |s, p| {
902
902
if p. uuid == uuid {
@@ -920,7 +920,7 @@ fn install_uuid(c: cargo, wd: &Path, uuid: ~str) {
920
920
}
921
921
}
922
922
923
- fn install_named( c: cargo, wd: & Path , name: ~str ) {
923
+ fn install_named( c: & cargo, wd: & Path , name: ~str ) {
924
924
let mut ps = ~[ ] ;
925
925
for_each_package( c, |s, p| {
926
926
if p. name == name {
@@ -944,7 +944,7 @@ fn install_named(c: cargo, wd: &Path, name: ~str) {
944
944
}
945
945
}
946
946
947
- fn install_uuid_specific( c: cargo, wd: & Path , src: ~str , uuid: ~str ) {
947
+ fn install_uuid_specific( c: & cargo, wd: & Path , src: ~str , uuid: ~str ) {
948
948
match c. sources. find( src) {
949
949
Some ( s) => {
950
950
for s. packages. each |p| {
@@ -959,7 +959,7 @@ fn install_uuid_specific(c: cargo, wd: &Path, src: ~str, uuid: ~str) {
959
959
error( ~"can' t find package: " + src + ~" /" + uuid) ;
960
960
}
961
961
962
- fn install_named_specific( c: cargo, wd: & Path , src: ~str , name: ~str ) {
962
+ fn install_named_specific( c: & cargo, wd: & Path , src: ~str , name: ~str ) {
963
963
match c. sources. find( src) {
964
964
Some ( s) => {
965
965
for s. packages. each |p| {
@@ -974,7 +974,7 @@ fn install_named_specific(c: cargo, wd: &Path, src: ~str, name: ~str) {
974
974
error( ~"can' t find package: " + src + ~" /" + name) ;
975
975
}
976
976
977
- fn cmd_uninstall( c: cargo) {
977
+ fn cmd_uninstall( c: & cargo) {
978
978
if vec:: len( c. opts. free) < 3 u {
979
979
cmd_usage( ) ;
980
980
return ;
@@ -1026,7 +1026,7 @@ fn cmd_uninstall(c: cargo) {
1026
1026
}
1027
1027
}
1028
1028
1029
- fn install_query(c: cargo, wd: &Path, target: ~str) {
1029
+ fn install_query(c: & cargo, wd: &Path, target: ~str) {
1030
1030
match c.dep_cache.find(target) {
1031
1031
Some(inst) => {
1032
1032
if inst {
@@ -1086,15 +1086,15 @@ fn install_query(c: cargo, wd: &Path, target: ~str) {
1086
1086
}
1087
1087
}
1088
1088
1089
- fn get_temp_workdir( c: cargo) -> Path {
1089
+ fn get_temp_workdir( c: & cargo) -> Path {
1090
1090
match tempfile:: mkdtemp( & c. workdir, "cargo") {
1091
1091
Some ( wd) => wd,
1092
1092
None => fail fmt!( "needed temp dir: %s",
1093
1093
c. workdir. to_str( ) )
1094
1094
}
1095
1095
}
1096
1096
1097
- fn cmd_install( c: cargo) unsafe {
1097
+ fn cmd_install( c: & cargo) unsafe {
1098
1098
let wd = get_temp_workdir( c) ;
1099
1099
1100
1100
if vec:: len( c. opts. free) == 2 u {
@@ -1118,15 +1118,15 @@ fn cmd_install(c: cargo) unsafe {
1118
1118
install_query( c, & wd, query) ;
1119
1119
}
1120
1120
1121
- fn sync( c: cargo) {
1121
+ fn sync( c: & cargo) {
1122
1122
for c. sources. each_key |k| {
1123
1123
let mut s = c. sources. get( k) ;
1124
1124
sync_one( c, s) ;
1125
1125
c. sources. insert( k, s) ;
1126
1126
}
1127
1127
}
1128
1128
1129
- fn sync_one_file( c: cargo, dir: & Path , src: source) -> bool {
1129
+ fn sync_one_file( c: & cargo, dir: & Path , src: source) -> bool {
1130
1130
let name = src. name;
1131
1131
let srcfile = dir. push( "source. json. new") ;
1132
1132
let destsrcfile = dir. push( "source. json") ;
@@ -1204,7 +1204,7 @@ fn sync_one_file(c: cargo, dir: &Path, src: source) -> bool {
1204
1204
return true;
1205
1205
}
1206
1206
1207
- fn sync_one_git( c: cargo, dir: & Path , src: source) -> bool {
1207
+ fn sync_one_git( c: & cargo, dir: & Path , src: source) -> bool {
1208
1208
let name = src. name;
1209
1209
let srcfile = dir. push( "source. json") ;
1210
1210
let pkgfile = dir. push( "packages. json") ;
@@ -1307,7 +1307,7 @@ fn sync_one_git(c: cargo, dir: &Path, src: source) -> bool {
1307
1307
return true ;
1308
1308
}
1309
1309
1310
- fn sync_one_curl( c : cargo , dir : & Path , src : source ) -> bool {
1310
+ fn sync_one_curl( c : & cargo , dir : & Path , src : source ) -> bool {
1311
1311
let name = src. name ;
1312
1312
let srcfile = dir. push ( "source.json.new" ) ;
1313
1313
let destsrcfile = dir. push ( "source.json" ) ;
@@ -1423,7 +1423,7 @@ fn sync_one_curl(c: cargo, dir: &Path, src: source) -> bool {
1423
1423
return true;
1424
1424
}
1425
1425
1426
- fn sync_one ( c : cargo , src : source ) {
1426
+ fn sync_one ( c : & cargo , src : source ) {
1427
1427
let name = src. name ;
1428
1428
let dir = c. sourcedir . push ( name) ;
1429
1429
@@ -1443,7 +1443,7 @@ fn sync_one(c: cargo, src: source) {
1443
1443
}
1444
1444
}
1445
1445
1446
- fn cmd_init ( c : cargo ) {
1446
+ fn cmd_init ( c : & cargo ) {
1447
1447
let srcurl = ~"http: //www.rust-lang.org/cargo/sources.json";
1448
1448
let sigurl = ~"http: //www.rust-lang.org/cargo/sources.json.sig";
1449
1449
@@ -1514,7 +1514,7 @@ fn print_source(s: source) {
1514
1514
}));
1515
1515
}
1516
1516
1517
- fn cmd_list(c: cargo) {
1517
+ fn cmd_list(c: & cargo) {
1518
1518
sync(c);
1519
1519
1520
1520
if vec::len(c.opts.free) >= 3u {
@@ -1539,7 +1539,7 @@ fn cmd_list(c: cargo) {
1539
1539
}
1540
1540
}
1541
1541
1542
- fn cmd_search( c: cargo) {
1542
+ fn cmd_search( c: & cargo) {
1543
1543
if vec:: len( c. opts . free ) < 3 u {
1544
1544
cmd_usage( ) ;
1545
1545
return ;
@@ -1572,7 +1572,7 @@ fn install_to_dir(srcfile: &Path, destdir: &Path) {
1572
1572
}
1573
1573
}
1574
1574
1575
- fn dump_cache( c: cargo) {
1575
+ fn dump_cache( c: & cargo) {
1576
1576
need_dir ( & c. root ) ;
1577
1577
1578
1578
let out = c. root . push ( "cache.json" ) ;
@@ -1582,7 +1582,7 @@ fn dump_cache(c: cargo) {
1582
1582
copy_warn ( & out, & c. root . push ( "cache.json.old" ) ) ;
1583
1583
}
1584
1584
}
1585
- fn dump_sources ( c : cargo ) {
1585
+ fn dump_sources ( c : & cargo ) {
1586
1586
if c. sources . size ( ) < 1 u {
1587
1587
return ;
1588
1588
}
@@ -1638,7 +1638,7 @@ fn copy_warn(srcfile: &Path, destfile: &Path) {
1638
1638
}
1639
1639
}
1640
1640
1641
- fn cmd_sources ( c : cargo ) {
1641
+ fn cmd_sources ( c : & cargo ) {
1642
1642
if vec:: len ( c. opts . free ) < 3 u {
1643
1643
for c. sources. each_value |v| {
1644
1644
info( fmt ! ( "%s (%s) via %s" ,
@@ -1923,12 +1923,14 @@ fn main(argv: ~[~str]) {
1923
1923
let first_time = os:: path_exists ( & home. push ( "sources.json" ) ) ;
1924
1924
1925
1925
if !first_time && o. free [ 1 ] != ~"init" {
1926
- cmd_init ( c) ;
1926
+ cmd_init ( & c) ;
1927
1927
1928
1928
// FIXME (#2662): shouldn't need to reconfigure
1929
1929
c = configure ( o) ;
1930
1930
}
1931
1931
1932
+ let c = & move c;
1933
+
1932
1934
match o. free [ 1 ] {
1933
1935
~"init" => cmd_init ( c) ,
1934
1936
~"install" => cmd_install ( c) ,
0 commit comments