Skip to content

Commit

Permalink
Update for nightly
Browse files Browse the repository at this point in the history
I'm a bit shaky on the profile.rs changes (`thread_local!` and `RefCell`
relplacing `local_data_key!`), do make sure I haven't royally screwed
something up there.

Note that I haven't sucessfully run the various test_cargo_cross_compile
tests as I don't have an i686-unknown-linux-gnu rustc sitting around.
  • Loading branch information
codyps committed Dec 3, 2014
1 parent 5a80c02 commit 6312107
Show file tree
Hide file tree
Showing 16 changed files with 96 additions and 91 deletions.
100 changes: 55 additions & 45 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/bin/cargo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ fn list_commands() -> TreeSet<String> {

fn is_executable(path: &Path) -> bool {
match fs::stat(path) {
Ok(io::FileStat{ kind: io::TypeFile, perm, ..}) =>
Ok(io::FileStat{ kind: io::FileType::RegularFile, perm, ..}) =>
perm.contains(io::OTHER_EXECUTE),
_ => false
}
Expand Down
12 changes: 6 additions & 6 deletions src/cargo/core/source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ pub struct SourceMap<'src> {
pub type Sources<'a, 'src> = Values<'a, SourceId, Box<Source+'src>>;
pub type SourcesMut<'a, 'src> = iter::Map<'static, (&'a SourceId,
&'a mut Box<Source+'src>),
&'a mut Source+'src,
&'a mut (Source+'src),
MutEntries<'a, SourceId, Box<Source+'src>>>;

impl<'src> SourceMap<'src> {
Expand All @@ -341,23 +341,23 @@ impl<'src> SourceMap<'src> {
self.map.contains_key(id)
}

pub fn get(&self, id: &SourceId) -> Option<&Source+'src> {
pub fn get(&self, id: &SourceId) -> Option<&(Source+'src)> {
let source = self.map.get(id);

source.map(|s| {
let s: &Source+'src = &**s;
let s: &(Source+'src) = &**s;
s
})
}

pub fn get_mut(&mut self, id: &SourceId) -> Option<&mut Source+'src> {
pub fn get_mut(&mut self, id: &SourceId) -> Option<&mut (Source+'src)> {
self.map.get_mut(id).map(|s| {
let s: &mut Source+'src = &mut **s;
let s: &mut (Source+'src) = &mut **s;
s
})
}

pub fn get_by_package_id(&self, pkg_id: &PackageId) -> Option<&Source+'src> {
pub fn get_by_package_id(&self, pkg_id: &PackageId) -> Option<&(Source+'src)> {
self.get(pkg_id.get_source_id())
}

Expand Down
4 changes: 2 additions & 2 deletions src/cargo/sources/git/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ impl<'a> GitCheckout<'a> {
self.revision.as_slice());
let oid = try!(git2::Oid::from_str(self.revision.as_slice()));
let object = try!(self.repo.find_object(oid, None));
try!(self.repo.reset(&object, git2::Hard, None, None));
try!(self.repo.reset(&object, git2::ResetType::Hard, None, None));
Ok(())
}

Expand Down Expand Up @@ -345,7 +345,7 @@ impl<'a> GitCheckout<'a> {
}));

let obj = try!(repo.find_object(head, None));
try!(repo.reset(&obj, git2::Hard, None, None));
try!(repo.reset(&obj, git2::ResetType::Hard, None, None));
try!(update_submodules(&repo));
}
Ok(())
Expand Down
2 changes: 1 addition & 1 deletion src/cargo/sources/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ impl<'a, 'b> RegistrySource<'a, 'b> {
let oid = try!(repo.refname_to_id(reference));
log!(5, "[{}] updating to rev {}", self.source_id, oid);
let object = try!(repo.find_object(oid, None));
try!(repo.reset(&object, git2::Hard, None, None));
try!(repo.reset(&object, git2::ResetType::Hard, None, None));
self.updated = true;
self.cache.clear();
Ok(())
Expand Down
4 changes: 2 additions & 2 deletions src/cargo/util/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,15 +253,15 @@ from_error!(CliError)
impl CargoError for docopt::Error {
fn description(&self) -> String {
match *self {
docopt::WithProgramUsage(ref other, _) => other.description(),
docopt::Error::WithProgramUsage(ref other, _) => other.description(),
ref e if e.fatal() => self.to_string(),
_ => "".to_string(),
}
}

fn detail(&self) -> Option<String> {
match *self {
docopt::WithProgramUsage(_, ref usage) => Some(usage.clone()),
docopt::Error::WithProgramUsage(_, ref usage) => Some(usage.clone()),
ref e if e.fatal() => None,
ref e => Some(e.to_string()),
}
Expand Down
2 changes: 1 addition & 1 deletion src/cargo/util/paths.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub fn realpath(original: &Path) -> io::IoResult<Path> {

match fs::lstat(&result) {
Err(..) => break,
Ok(ref stat) if stat.kind != io::TypeSymlink => break,
Ok(ref stat) if stat.kind != io::FileType::Symlink => break,
Ok(..) => {
followed += 1;
let path = try!(fs::readlink(&result));
Expand Down
33 changes: 16 additions & 17 deletions src/cargo/util/profile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ use std::os;
use std::mem;
use std::fmt::Show;
use time;
use std::cell::RefCell;

local_data_key!(PROFILE_STACK: Vec<u64>)
local_data_key!(MESSAGES: Vec<Message>)
thread_local!(static PROFILE_STACK: RefCell<Vec<u64>> = RefCell::new(Vec::new()))
thread_local!(static MESSAGES: RefCell<Vec<Message>> = RefCell::new(Vec::new()))

type Message = (uint, u64, String);

Expand All @@ -17,9 +18,7 @@ fn enabled() -> bool { os::getenv("CARGO_PROFILE").is_some() }
pub fn start<T: Show>(desc: T) -> Profiler {
if !enabled() { return Profiler { desc: String::new() } }

let mut stack = PROFILE_STACK.replace(None).unwrap_or(Vec::new());
stack.push(time::precise_time_ns());
PROFILE_STACK.replace(Some(stack));
PROFILE_STACK.with(|stack| stack.borrow_mut().push(time::precise_time_ns()));

Profiler {
desc: desc.to_string(),
Expand All @@ -30,14 +29,11 @@ impl Drop for Profiler {
fn drop(&mut self) {
if !enabled() { return }

let mut stack = PROFILE_STACK.replace(None).unwrap_or(Vec::new());
let mut msgs = MESSAGES.replace(None).unwrap_or(Vec::new());

let start = stack.pop().unwrap();
let start = PROFILE_STACK.with(|stack| stack.borrow_mut().pop().unwrap());
let end = time::precise_time_ns();

let msg = mem::replace(&mut self.desc, String::new());
if stack.len() == 0 {
let stack_len = PROFILE_STACK.with(|stack| stack.borrow().len());
if stack_len == 0 {
fn print(lvl: uint, msgs: &[Message]) {
let mut last = 0;
for (i, &(l, time, ref msg)) in msgs.iter().enumerate() {
Expand All @@ -50,13 +46,16 @@ impl Drop for Profiler {
}

}
msgs.push((0, end - start, msg));
print(0, msgs.as_slice());
MESSAGES.with(|msgs_rc| {
let mut msgs = msgs_rc.borrow_mut();
msgs.push((0, end - start, mem::replace(&mut self.desc, String::new())));
print(0, msgs.as_slice());
});
} else {
msgs.push((stack.len(), end - start, msg));
MESSAGES.replace(Some(msgs));
MESSAGES.with(|msgs| {
let msg = mem::replace(&mut self.desc, String::new());
msgs.borrow_mut().push((stack_len, end - start, msg));
});
}
PROFILE_STACK.replace(Some(stack));

}
}
5 changes: 3 additions & 2 deletions src/registry/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ use std::io::util::ChainedReader;
use std::result;

use curl::http;
use curl::http::handle::{Put, Get, Delete, Method, Request};
use curl::http::handle::Method::{Put, Get, Delete};
use curl::http::handle::{Method, Request};
use serialize::json;

pub struct Registry {
Expand Down Expand Up @@ -135,7 +136,7 @@ impl Registry {
w.write_le_u32(json.len() as u32).unwrap();
w.write_str(json.as_slice()).unwrap();
w.write_le_u32(stat.size as u32).unwrap();
MemReader::new(w.unwrap())
MemReader::new(w.into_inner())
};
let tarball = try!(File::open(tarball).map_err(Error::Io));
let size = stat.size as uint + header.get_ref().len();
Expand Down
2 changes: 1 addition & 1 deletion src/rustversion.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2014-11-24
2014-12-02
2 changes: 1 addition & 1 deletion tests/resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use std::collections::HashMap;
use hamcrest::{assert_that, equal_to, contains};

use cargo::core::source::SourceId;
use cargo::core::dependency::Development;
use cargo::core::dependency::Kind::Development;
use cargo::core::{Dependency, PackageId, Summary, Registry};
use cargo::util::{CargoResult, ToUrl};
use cargo::core::resolver::{mod, Method};
Expand Down
Loading

5 comments on commit 6312107

@bors
Copy link
Contributor

@bors bors commented on 6312107 Dec 3, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from alexcrichton
at codyps@6312107

@bors
Copy link
Contributor

@bors bors commented on 6312107 Dec 3, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging jmesmon/cargo/update-for-nightly = 6312107 into auto-cargo

@bors
Copy link
Contributor

@bors bors commented on 6312107 Dec 3, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

jmesmon/cargo/update-for-nightly = 6312107 merged ok, testing candidate = a0f0abc

@bors
Copy link
Contributor

@bors bors commented on 6312107 Dec 3, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors
Copy link
Contributor

@bors bors commented on 6312107 Dec 3, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding master to auto-cargo = a0f0abc

Please sign in to comment.