Skip to content

Commit 03fd040

Browse files
committed
---
yaml --- r: 64302 b: refs/heads/snap-stage3 c: b937af1 h: refs/heads/master v: v3
1 parent 6ac99f3 commit 03fd040

File tree

26 files changed

+320
-149
lines changed

26 files changed

+320
-149
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 2d28d645422c1617be58c8ca7ad9a457264ca850
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 0e882f2bbda58e8271ff25c1467a35fc3ff26dd4
4+
refs/heads/snap-stage3: b937af17c9ec309fa29d98c42a5735dd8b934369
55
refs/heads/try: 7b78b52e602bb3ea8174f9b2006bff3315f03ef9
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/mk/dist.mk

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ PKG_FILES := \
1919
$(S)LICENSE-APACHE \
2020
$(S)LICENSE-MIT \
2121
$(S)AUTHORS.txt \
22+
$(S)CONTRIBUTING.md \
2223
$(S)README.md \
24+
$(S)RELEASES.txt \
2325
$(S)configure $(S)Makefile.in \
2426
$(S)man \
2527
$(S)doc \

branches/snap-stage3/src/libextra/bitv.rs

Lines changed: 32 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -718,6 +718,38 @@ impl Set<uint> for BitvSet {
718718
*value < self.bitv.storage.len() * uint::bits && self.bitv.get(*value)
719719
}
720720

721+
fn insert(&mut self, value: uint) -> bool {
722+
if self.contains(&value) {
723+
return false;
724+
}
725+
let nbits = self.capacity();
726+
if value >= nbits {
727+
let newsize = num::max(value, nbits * 2) / uint::bits + 1;
728+
assert!(newsize > self.bitv.storage.len());
729+
self.bitv.storage.grow(newsize, &0);
730+
}
731+
self.size += 1;
732+
self.bitv.set(value, true);
733+
return true;
734+
}
735+
736+
fn remove(&mut self, value: &uint) -> bool {
737+
if !self.contains(value) {
738+
return false;
739+
}
740+
self.size -= 1;
741+
self.bitv.set(*value, false);
742+
743+
// Attempt to truncate our storage
744+
let mut i = self.bitv.storage.len();
745+
while i > 1 && self.bitv.storage[i - 1] == 0 {
746+
i -= 1;
747+
}
748+
self.bitv.storage.truncate(i);
749+
750+
return true;
751+
}
752+
721753
fn is_disjoint(&self, other: &BitvSet) -> bool {
722754
for self.intersection(other) |_| {
723755
return false;
@@ -784,40 +816,6 @@ impl Set<uint> for BitvSet {
784816
}
785817
}
786818

787-
impl MutableSet<uint> for BitvSet {
788-
fn insert(&mut self, value: uint) -> bool {
789-
if self.contains(&value) {
790-
return false;
791-
}
792-
let nbits = self.capacity();
793-
if value >= nbits {
794-
let newsize = num::max(value, nbits * 2) / uint::bits + 1;
795-
assert!(newsize > self.bitv.storage.len());
796-
self.bitv.storage.grow(newsize, &0);
797-
}
798-
self.size += 1;
799-
self.bitv.set(value, true);
800-
return true;
801-
}
802-
803-
fn remove(&mut self, value: &uint) -> bool {
804-
if !self.contains(value) {
805-
return false;
806-
}
807-
self.size -= 1;
808-
self.bitv.set(*value, false);
809-
810-
// Attempt to truncate our storage
811-
let mut i = self.bitv.storage.len();
812-
while i > 1 && self.bitv.storage[i - 1] == 0 {
813-
i -= 1;
814-
}
815-
self.bitv.storage.truncate(i);
816-
817-
return true;
818-
}
819-
}
820-
821819
impl BitvSet {
822820
/// Visits each of the words that the two bit vectors (self and other)
823821
/// both have in common. The three yielded arguments are (bit location,

branches/snap-stage3/src/libextra/smallintmap.rs

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717

1818

1919
use std::cmp;
20-
use std::iterator::{Iterator,IteratorUtil,ZipIterator,Counter,EnumerateIterator,FilterMapIterator};
20+
use std::container::{Container, Mutable, Map, Set};
21+
use std::iterator::*;
2122
use std::uint;
2223
use std::util::replace;
2324
use std::vec::{VecIterator,VecMutIterator,VecRevIterator,VecMutRevIterator};
@@ -67,9 +68,7 @@ impl<V> Map<uint, V> for SmallIntMap<V> {
6768
None
6869
}
6970
}
70-
}
7171

72-
impl<V> MutableMap<uint, V> for SmallIntMap<V> {
7372
/// Return a mutable reference to the value corresponding to the key
7473
fn find_mut<'a>(&'a mut self, key: &uint) -> Option<&'a mut V> {
7574
if *key < self.v.len() {
@@ -350,6 +349,14 @@ impl Set<uint> for SmallIntSet {
350349
/// Return true if the set contains a value
351350
fn contains(&self, value: &uint) -> bool { self.map.contains_key(value) }
352351

352+
/// Add a value to the set. Return true if the value was not already
353+
/// present in the set.
354+
fn insert(&mut self, value: uint) -> bool { self.map.insert(value, ()) }
355+
356+
/// Remove a value from the set. Return true if the value was
357+
/// present in the set.
358+
fn remove(&mut self, value: &uint) -> bool { self.map.remove(value) }
359+
353360
/// Return true if the set has no elements in common with `other`.
354361
/// This is equivalent to checking for an empty uintersection.
355362
fn is_disjoint(&self, other: &SmallIntSet) -> bool {
@@ -405,16 +412,6 @@ impl Set<uint> for SmallIntSet {
405412
}
406413
}
407414

408-
impl MutableSet<uint> for SmallIntSet {
409-
/// Add a value to the set. Return true if the value was not already
410-
/// present in the set.
411-
fn insert(&mut self, value: uint) -> bool { self.map.insert(value, ()) }
412-
413-
/// Remove a value from the set. Return true if the value was
414-
/// present in the set.
415-
fn remove(&mut self, value: &uint) -> bool { self.map.remove(value) }
416-
}
417-
418415
impl SmallIntSet {
419416
/// Create an empty SmallIntSet
420417
pub fn new() -> SmallIntSet { SmallIntSet{map: SmallIntMap::new()} }

branches/snap-stage3/src/libextra/treemap.rs

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,7 @@ impl<K: TotalOrd, V> Map<K, V> for TreeMap<K, V> {
124124
}
125125
}
126126
}
127-
}
128127

129-
impl<K: TotalOrd, V> MutableMap<K, V> for TreeMap<K, V> {
130128
/// Return a mutable reference to the value corresponding to the key
131129
#[inline]
132130
fn find_mut<'a>(&'a mut self, key: &K) -> Option<&'a mut V> {
@@ -295,6 +293,16 @@ impl<T: TotalOrd> Set<T> for TreeSet<T> {
295293
self.map.contains_key(value)
296294
}
297295

296+
/// Add a value to the set. Return true if the value was not already
297+
/// present in the set.
298+
#[inline]
299+
fn insert(&mut self, value: T) -> bool { self.map.insert(value, ()) }
300+
301+
/// Remove a value from the set. Return true if the value was
302+
/// present in the set.
303+
#[inline]
304+
fn remove(&mut self, value: &T) -> bool { self.map.remove(value) }
305+
298306
/// Return true if the set has no elements in common with `other`.
299307
/// This is equivalent to checking for an empty intersection.
300308
fn is_disjoint(&self, other: &TreeSet<T>) -> bool {
@@ -467,18 +475,6 @@ impl<T: TotalOrd> Set<T> for TreeSet<T> {
467475
}
468476
}
469477

470-
impl<T: TotalOrd> MutableSet<T> for TreeSet<T> {
471-
/// Add a value to the set. Return true if the value was not already
472-
/// present in the set.
473-
#[inline]
474-
fn insert(&mut self, value: T) -> bool { self.map.insert(value, ()) }
475-
476-
/// Remove a value from the set. Return true if the value was
477-
/// present in the set.
478-
#[inline]
479-
fn remove(&mut self, value: &T) -> bool { self.map.remove(value) }
480-
}
481-
482478
impl<T: TotalOrd> TreeSet<T> {
483479
/// Create an empty TreeSet
484480
#[inline]

branches/snap-stage3/src/librustpkg/conditions.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,7 @@ condition! {
3232
condition! {
3333
bad_pkg_id: (super::Path, ~str) -> super::PkgId;
3434
}
35+
36+
condition! {
37+
no_rust_path: (~str) -> super::Path;
38+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// Listing installed packages
12+
13+
use path_util::*;
14+
use std::os;
15+
16+
pub fn list_installed_packages(f: &fn(&PkgId) -> bool) -> bool {
17+
let workspaces = rust_path();
18+
for workspaces.iter().advance |p| {
19+
let binfiles = os::list_dir(&p.push("bin"));
20+
for binfiles.iter().advance() |exec| {
21+
f(&PkgId::new(*exec));
22+
}
23+
let libfiles = os::list_dir(&p.push("lib"));
24+
for libfiles.iter().advance() |lib| {
25+
f(&PkgId::new(*lib));
26+
}
27+
}
28+
true
29+
}
30+
31+
pub fn package_is_installed(p: &PkgId) -> bool {
32+
let mut is_installed = false;
33+
do list_installed_packages() |installed| {
34+
if installed == p {
35+
is_installed = true;
36+
}
37+
false
38+
};
39+
is_installed
40+
}

branches/snap-stage3/src/librustpkg/package_id.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,15 @@ pub struct PkgId {
3030
version: Version
3131
}
3232

33+
impl Eq for PkgId {
34+
fn eq(&self, p: &PkgId) -> bool {
35+
*p.local_path == *self.local_path && p.version == self.version
36+
}
37+
fn ne(&self, p: &PkgId) -> bool {
38+
!(self.eq(p))
39+
}
40+
}
41+
3342
impl PkgId {
3443
pub fn new(s: &str) -> PkgId {
3544
use conditions::bad_pkg_id::cond;

branches/snap-stage3/src/librustpkg/path_util.rs

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,18 @@ static PATH_ENTRY_SEPARATOR: &'static str = ";";
3333
#[cfg(not(windows))]
3434
static PATH_ENTRY_SEPARATOR: &'static str = ":";
3535

36+
/// Returns RUST_PATH as a string, without default paths added
37+
pub fn get_rust_path() -> Option<~str> {
38+
os::getenv("RUST_PATH")
39+
}
40+
3641
/// Returns the value of RUST_PATH, as a list
3742
/// of Paths. Includes default entries for, if they exist:
3843
/// $HOME/.rust
3944
/// DIR/.rust for any DIR that's the current working directory
4045
/// or an ancestor of it
4146
pub fn rust_path() -> ~[Path] {
42-
let mut env_rust_path: ~[Path] = match os::getenv("RUST_PATH") {
47+
let mut env_rust_path: ~[Path] = match get_rust_path() {
4348
Some(env_path) => {
4449
let env_path_components: ~[&str] =
4550
env_path.split_str_iter(PATH_ENTRY_SEPARATOR).collect();
@@ -378,3 +383,23 @@ pub fn mk_output_path(what: OutputType, where: Target,
378383
debug!("mk_output_path: returning %s", output_path.to_str());
379384
output_path
380385
}
386+
387+
/// Removes files for the package `pkgid`, assuming it's installed in workspace `workspace`
388+
pub fn uninstall_package_from(workspace: &Path, pkgid: &PkgId) {
389+
let mut did_something = false;
390+
let installed_bin = target_executable_in_workspace(pkgid, workspace);
391+
if os::path_exists(&installed_bin) {
392+
os::remove_file(&installed_bin);
393+
did_something = true;
394+
}
395+
let installed_lib = target_library_in_workspace(pkgid, workspace);
396+
if os::path_exists(&installed_lib) {
397+
os::remove_file(&installed_lib);
398+
did_something = true;
399+
}
400+
if !did_something {
401+
warn(fmt!("Warning: there don't seem to be any files for %s installed in %s",
402+
pkgid.to_str(), workspace.to_str()));
403+
}
404+
405+
}

branches/snap-stage3/src/librustpkg/rustpkg.rs

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ pub mod api;
5050
mod conditions;
5151
mod context;
5252
mod crate;
53+
mod installed_packages;
5354
mod messages;
5455
mod package_id;
5556
mod package_path;
@@ -248,6 +249,14 @@ impl CtxMethods for Ctx {
248249
}
249250
}
250251
}
252+
"list" => {
253+
io::println("Installed packages:");
254+
for installed_packages::list_installed_packages |pkg_id| {
255+
io::println(fmt!("%s-%s",
256+
pkg_id.local_path.to_str(),
257+
pkg_id.version.to_str()));
258+
}
259+
}
251260
"prefer" => {
252261
if args.len() < 1 {
253262
return usage::uninstall();
@@ -263,11 +272,24 @@ impl CtxMethods for Ctx {
263272
return usage::uninstall();
264273
}
265274

266-
self.uninstall(args[0], None);
275+
let pkgid = PkgId::new(args[0]);
276+
if !installed_packages::package_is_installed(&pkgid) {
277+
warn(fmt!("Package %s doesn't seem to be installed! Doing nothing.", args[0]));
278+
return;
279+
}
280+
else {
281+
let rp = rust_path();
282+
assert!(!rp.is_empty());
283+
for each_pkg_parent_workspace(&pkgid) |workspace| {
284+
path_util::uninstall_package_from(workspace, &pkgid);
285+
note(fmt!("Uninstalled package %s (was installed in %s)",
286+
pkgid.to_str(), workspace.to_str()));
287+
}
288+
}
267289
}
268290
"unprefer" => {
269291
if args.len() < 1 {
270-
return usage::uninstall();
292+
return usage::unprefer();
271293
}
272294

273295
self.unprefer(args[0], None);
@@ -447,6 +469,7 @@ pub fn main() {
447469
~"do" => usage::do_cmd(),
448470
~"info" => usage::info(),
449471
~"install" => usage::install(),
472+
~"list" => usage::list(),
450473
~"prefer" => usage::prefer(),
451474
~"test" => usage::test(),
452475
~"uninstall" => usage::uninstall(),

0 commit comments

Comments
 (0)