Skip to content

Commit 6924adf

Browse files
committed
---
yaml --- r: 69338 b: refs/heads/auto c: 467d381 h: refs/heads/master v: v3
1 parent f63ec86 commit 6924adf

File tree

9 files changed

+106
-140
lines changed

9 files changed

+106
-140
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0
1414
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1515
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1616
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
17-
refs/heads/auto: bfac584a03f1e52808dc94aaa95703dd8847ab94
17+
refs/heads/auto: 467d381d3afce474309d6ba9a334fa9b463c3a7f
1818
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1919
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c

branches/auto/src/etc/tidy.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ def do_license_check(name, contents):
4949
report_err("FIXME without issue number")
5050
if line.find("TODO") != -1:
5151
report_err("TODO is deprecated; use FIXME")
52-
idx = line.find("// NOTE")
53-
if idx != -1:
54-
report_warn("NOTE" + line[idx + len("// NOTE"):])
52+
match = re.match(r'^.*//\s*(NOTE.*)$', line)
53+
if match:
54+
report_warn(match.group(1))
5555
if (line.find('\t') != -1 and
5656
fileinput.filename().find("Makefile") == -1):
5757
report_err("tab character")

branches/auto/src/librustpkg/package_source.rs

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,14 @@
1111
use target::*;
1212
use package_id::PkgId;
1313
use std::path::Path;
14-
use std::{os, str};
14+
use std::{os, run, str};
1515
use context::*;
1616
use crate::Crate;
1717
use messages::*;
18-
use source_control::{git_clone, git_clone_general};
18+
use source_control::git_clone;
1919
use path_util::pkgid_src_in_workspace;
2020
use util::compile_crate;
21+
use version::{ExactRevision, SemanticVersion, NoVersion};
2122

2223
// An enumeration of the unpacked source of a package workspace.
2324
// This contains a list of files found in the source workspace.
@@ -101,13 +102,22 @@ impl PkgSrc {
101102
}
102103

103104
let url = fmt!("https://%s", self.id.remote_path.to_str());
104-
note(fmt!("Fetching package: git clone %s %s [version=%s]",
105-
url, local.to_str(), self.id.version.to_str()));
106-
if git_clone_general(url, &local, &self.id.version) {
107-
Some(local)
105+
let branch_args = match self.id.version {
106+
NoVersion => ~[],
107+
ExactRevision(ref s) => ~[~"--branch", (*s).clone()],
108+
SemanticVersion(ref s) => ~[~"--branch", s.to_str()]
109+
};
110+
111+
112+
note(fmt!("Fetching package: git clone %s %s %?", url, local.to_str(), branch_args));
113+
114+
if run::process_output("git",
115+
~[~"clone", url.clone(), local.to_str()] + branch_args).status != 0 {
116+
note(fmt!("fetching %s failed: can't clone repository", url));
117+
None
108118
}
109119
else {
110-
None
120+
Some(local)
111121
}
112122
}
113123

branches/auto/src/librustpkg/path_util.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ pub fn rust_path() -> ~[Path] {
5252
}
5353
None => ~[]
5454
};
55-
debug!("RUST_PATH entries from environment: %?", env_rust_path);
5655
let cwd = os::getcwd();
5756
// now add in default entries
5857
env_rust_path.push(cwd.clone());
@@ -346,12 +345,7 @@ fn target_file_in_workspace(pkgid: &PkgId, workspace: &Path,
346345
let subdir = match what {
347346
Lib => "lib", Main | Test | Bench => "bin"
348347
};
349-
// Artifacts in the build directory live in a package-ID-specific subdirectory,
350-
// but installed ones don't.
351-
let result = match where {
352-
Build => workspace.push(subdir).push_rel(&*pkgid.local_path),
353-
_ => workspace.push(subdir)
354-
};
348+
let result = workspace.push(subdir);
355349
if !os::path_exists(&result) && !mkdir_recursive(&result, U_RWX) {
356350
cond.raise((result.clone(), fmt!("target_file_in_workspace couldn't \
357351
create the %s dir (pkgid=%s, workspace=%s, what=%?, where=%?",

branches/auto/src/librustpkg/source_control.rs

Lines changed: 12 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,22 @@ pub fn git_clone(source: &Path, target: &Path, v: &Version) {
1818
assert!(os::path_is_dir(source));
1919
assert!(is_git_dir(source));
2020
if !os::path_exists(target) {
21-
debug!("Running: git clone %s %s", source.to_str(),
21+
let version_args = match v {
22+
&ExactRevision(ref s) => ~[~"--branch", s.to_owned()],
23+
_ => ~[]
24+
};
25+
debug!("Running: git clone %s %s %s", version_args.to_str(), source.to_str(),
2226
target.to_str());
23-
assert!(git_clone_general(source.to_str(), target, v));
27+
let outp = run::process_output("git", ~[~"clone"] + version_args +
28+
~[source.to_str(), target.to_str()]);
29+
if outp.status != 0 {
30+
io::println(str::from_bytes_owned(outp.output.clone()));
31+
io::println(str::from_bytes_owned(outp.error));
32+
fail!("Couldn't `git clone` %s", source.to_str());
33+
}
2434
}
2535
else {
2636
// Pull changes
27-
// Note that this ignores tags, which is probably wrong. There are no tests for
28-
// it, though.
2937
debug!("Running: git --work-tree=%s --git-dir=%s pull --no-edit %s",
3038
target.to_str(), target.push(".git").to_str(), source.to_str());
3139
let outp = run::process_output("git", [fmt!("--work-tree=%s", target.to_str()),
@@ -35,34 +43,6 @@ pub fn git_clone(source: &Path, target: &Path, v: &Version) {
3543
}
3644
}
3745

38-
/// Source can be either a URL or a local file path.
39-
/// true if successful
40-
pub fn git_clone_general(source: &str, target: &Path, v: &Version) -> bool {
41-
let outp = run::process_output("git", [~"clone", source.to_str(), target.to_str()]);
42-
if outp.status != 0 {
43-
debug!(str::from_bytes_owned(outp.output.clone()));
44-
debug!(str::from_bytes_owned(outp.error));
45-
false
46-
}
47-
else {
48-
match v {
49-
&ExactRevision(ref s) | &Tagged(ref s) => {
50-
let outp = run::process_output_in_cwd("git", [~"checkout", fmt!("tags/%s", *s)],
51-
target);
52-
if outp.status != 0 {
53-
debug!(str::from_bytes_owned(outp.output.clone()));
54-
debug!(str::from_bytes_owned(outp.error));
55-
false
56-
}
57-
else {
58-
true
59-
}
60-
}
61-
_ => true
62-
}
63-
}
64-
}
65-
6646
pub fn is_git_dir(p: &Path) -> bool {
6747
os::path_is_dir(&p.push(".git"))
6848
}

branches/auto/src/librustpkg/tests.rs

Lines changed: 38 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use std::run::ProcessOutput;
1818
use installed_packages::list_installed_packages;
1919
use package_path::*;
2020
use package_id::{PkgId};
21-
use version::{ExactRevision, NoVersion, Version, Tagged};
21+
use version::{ExactRevision, NoVersion, Version};
2222
use path_util::{target_executable_in_workspace, target_library_in_workspace,
2323
target_test_in_workspace, target_bench_in_workspace,
2424
make_dir_rwx, U_RWX, library_in_workspace,
@@ -61,16 +61,6 @@ fn git_repo_pkg() -> PkgId {
6161
}
6262
}
6363

64-
fn git_repo_pkg_with_tag(a_tag: ~str) -> PkgId {
65-
let remote = RemotePath(Path("mockgithub.com/catamorphism/test-pkg"));
66-
PkgId {
67-
local_path: normalize(remote.clone()),
68-
remote_path: remote,
69-
short_name: ~"test_pkg",
70-
version: Tagged(a_tag)
71-
}
72-
}
73-
7464
fn writeFile(file_path: &Path, contents: &str) {
7565
let out: @io::Writer =
7666
result::unwrap(io::file_writer(file_path,
@@ -160,13 +150,9 @@ fn init_git_repo(p: &Path) -> Path {
160150
}
161151
}
162152

163-
fn add_all_and_commit(repo: &Path) {
164-
git_add_all(repo);
165-
git_commit(repo, ~"floop");
166-
}
167-
168-
fn git_commit(repo: &Path, msg: ~str) {
169-
let mut prog = run::Process::new("git", [~"commit", ~"-m", msg],
153+
fn add_git_tag(repo: &Path, tag: ~str) {
154+
assert!(repo.is_absolute());
155+
let mut prog = run::Process::new("git", [~"add", ~"-A"],
170156
run::ProcessOptions { env: None,
171157
dir: Some(repo),
172158
in_fd: None,
@@ -175,14 +161,9 @@ fn git_commit(repo: &Path, msg: ~str) {
175161
});
176162
let output = prog.finish_with_output();
177163
if output.status != 0 {
178-
fail!("Couldn't commit in %s: output was %s", repo.to_str(),
179-
str::from_bytes(output.output + output.error))
164+
fail!("Couldn't add all files in %s", repo.to_str())
180165
}
181-
182-
}
183-
184-
fn git_add_all(repo: &Path) {
185-
let mut prog = run::Process::new("git", [~"add", ~"-A"],
166+
prog = run::Process::new("git", [~"commit", ~"-m", ~"whatever"],
186167
run::ProcessOptions { env: None,
187168
dir: Some(repo),
188169
in_fd: None,
@@ -191,16 +172,10 @@ fn git_add_all(repo: &Path) {
191172
});
192173
let output = prog.finish_with_output();
193174
if output.status != 0 {
194-
fail!("Couldn't add all files in %s: output was %s",
195-
repo.to_str(), str::from_bytes(output.output + output.error))
175+
fail!("Couldn't commit in %s", repo.to_str())
196176
}
197-
}
198177

199-
fn add_git_tag(repo: &Path, tag: ~str) {
200-
assert!(repo.is_absolute());
201-
git_add_all(repo);
202-
git_commit(repo, ~"whatever");
203-
let mut prog = run::Process::new("git", [~"tag", tag.clone()],
178+
prog = run::Process::new("git", [~"tag", tag.clone()],
204179
run::ProcessOptions { env: None,
205180
dir: Some(repo),
206181
in_fd: None,
@@ -649,6 +624,31 @@ fn test_package_request_version() {
649624
writeFile(&repo_subdir.push("version-0.4-file.txt"), "hello");
650625
add_git_tag(&repo_subdir, ~"0.4");
651626
627+
/*
628+
629+
let pkg_src = PkgSrc::new(&repo, &repo, &temp_pkg_id);
630+
match temp_pkg_id.version {
631+
ExactRevision(~"0.3") => {
632+
debug!("Version matches, calling fetch_git");
633+
match pkg_src.fetch_git() {
634+
Some(p) => {
635+
debug!("does version-0.3-file exist?");
636+
assert!(os::path_exists(&p.push("version-0.3-file.txt")));
637+
debug!("does version-0.4-file exist?");
638+
assert!(!os::path_exists(&p.push("version-0.4-file.txt")));
639+
640+
}
641+
None => fail!("test_package_request_version: fetch_git failed")
642+
}
643+
}
644+
ExactRevision(n) => {
645+
fail!("n is %? and %? %s %?", n, n, if n == ~"0.3" { "==" } else { "!=" }, "0.3");
646+
}
647+
_ => fail!(fmt!("test_package_version: package version was %?, expected ExactRevision(0.3)",
648+
temp_pkg_id.version))
649+
}
650+
*/
651+
652652
command_line_test([~"install", fmt!("%s#0.3", local_path)], &repo);
653653
654654
assert!(match installed_library_in_workspace("test_pkg_version", &repo.push(".rust")) {
@@ -681,7 +681,6 @@ fn rustpkg_install_url_2() {
681681
}
682682
683683
// FIXME: #7956: temporarily disabled
684-
#[test]
685684
fn rustpkg_library_target() {
686685
let foo_repo = init_git_repo(&Path("foo"));
687686
let package_dir = foo_repo.push("foo");
@@ -708,10 +707,8 @@ fn rustpkg_local_pkg() {
708707
assert_executable_exists(&dir, "foo");
709708
}
710709
711-
// FIXME: #7956: temporarily disabled
712-
// Failing on dist-linux bot
713710
#[test]
714-
#[ignore]
711+
#[ignore] // XXX Failing on dist-linux bot
715712
fn package_script_with_default_build() {
716713
let dir = create_local_package(&PkgId::new("fancy-lib", &os::getcwd()));
717714
debug!("dir = %s", dir.to_str());
@@ -770,7 +767,7 @@ fn rustpkg_clean_no_arg() {
770767
}
771768
772769
#[test]
773-
#[ignore (reason = "Specifying env doesn't work -- see #8028")]
770+
#[ignore (reason = "Un-ignore when #7071 is fixed")]
774771
fn rust_path_test() {
775772
let dir_for_path = mkdtemp(&os::tmpdir(), "more_rust").expect("rust_path_test failed");
776773
let dir = mk_workspace(&dir_for_path, &normalize(RemotePath(Path("foo"))), &NoVersion);
@@ -779,13 +776,9 @@ fn rust_path_test() {
779776
780777
let cwd = os::getcwd();
781778
debug!("cwd = %s", cwd.to_str());
782-
debug!("Running command: cd %s; RUST_LOG=rustpkg RUST_PATH=%s rustpkg install foo",
783-
cwd.to_str(), dir_for_path.to_str());
784779
let mut prog = run::Process::new("rustpkg",
785780
[~"install", ~"foo"],
786-
run::ProcessOptions { env: Some(&[(~"RUST_LOG",
787-
~"rustpkg"),
788-
(~"RUST_PATH",
781+
run::ProcessOptions { env: Some(&[(~"RUST_PATH",
789782
dir_for_path.to_str())]),
790783
dir: Some(&cwd),
791784
in_fd: None,
@@ -963,6 +956,7 @@ fn do_rebuild_dep_only_contents_change() {
963956
}
964957
965958
#[test]
959+
#[ignore(reason = "list not yet implemented")]
966960
fn test_versions() {
967961
let workspace = create_local_package(&PkgId::new("foo#0.1", &os::getcwd()));
968962
create_local_package(&PkgId::new("foo#0.2", &os::getcwd()));
@@ -1000,35 +994,11 @@ fn test_rustpkg_test() {
1000994
}
1001995
1002996
#[test]
997+
#[ignore(reason = "uninstall not yet implemented")]
1003998
fn test_uninstall() {
1004999
let workspace = create_local_package(&PkgId::new("foo", &os::getcwd()));
10051000
let _output = command_line_test([~"info", ~"foo"], &workspace);
10061001
command_line_test([~"uninstall", ~"foo"], &workspace);
10071002
let output = command_line_test([~"list"], &workspace);
10081003
assert!(!str::from_bytes(output.output).contains("foo"));
10091004
}
1010-
1011-
#[test]
1012-
fn test_non_numeric_tag() {
1013-
let temp_pkg_id = git_repo_pkg();
1014-
let repo = init_git_repo(&Path(temp_pkg_id.local_path.to_str()));
1015-
let repo_subdir = repo.push("mockgithub.com").push("catamorphism").push("test_pkg");
1016-
writeFile(&repo_subdir.push("foo"), "foo");
1017-
writeFile(&repo_subdir.push("lib.rs"),
1018-
"pub fn f() { let _x = (); }");
1019-
add_git_tag(&repo_subdir, ~"testbranch");
1020-
writeFile(&repo_subdir.push("testbranch_only"), "hello");
1021-
add_git_tag(&repo_subdir, ~"another_tag");
1022-
writeFile(&repo_subdir.push("not_on_testbranch_only"), "bye bye");
1023-
add_all_and_commit(&repo_subdir);
1024-
1025-
1026-
command_line_test([~"install", fmt!("%s#testbranch", temp_pkg_id.remote_path.to_str())],
1027-
&repo);
1028-
let file1 = repo.push_many(["mockgithub.com", "catamorphism",
1029-
"test_pkg", "testbranch_only"]);
1030-
let file2 = repo.push_many(["mockgithub.com", "catamorphism", "test_pkg",
1031-
"master_only"]);
1032-
assert!(os::path_exists(&file1));'
1033-
assert!(!os::path_exists(&file2));
1034-
}

branches/auto/src/librustpkg/usage.rs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,17 +63,20 @@ List all installed packages.");
6363
}
6464

6565
pub fn install() {
66-
io::println("rustpkg [options..] install [package-ID]
66+
io::println("rustpkg [options..] install [url] [target]
6767
68-
Install the given package ID if specified. With no package ID
69-
argument, install the package in the current directory.
70-
In that case, the current directory must be a direct child of a
71-
`src` directory in a workspace.
68+
Install a package from a URL by Git or cURL (FTP, HTTP, etc.).
69+
If target is provided, Git will checkout the branch or tag before
70+
continuing. If the URL is a TAR file (with or without compression),
71+
extract it before installing. If a URL isn't provided, the package will
72+
be built and installed from the current directory (which is
73+
functionally the same as `rustpkg build` and installing the result).
7274
7375
Examples:
7476
rustpkg install
75-
rustpkg install github.com/mozilla/servo
76-
rustpkg install github.com/mozilla/servo#0.1.2
77+
rustpkg install git://github.com/mozilla/servo.git
78+
rustpkg install git://github.com/mozilla/servo.git v0.1.2
79+
rustpkg install http://rust-lang.org/servo-0.1.2.tar.gz
7780
7881
Options:
7982
-c, --cfg Pass a cfg flag to the package script");

branches/auto/src/librustpkg/version.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ use extra::tempfile::mkdtemp;
2222
pub enum Version {
2323
ExactRevision(~str), // Should look like a m.n.(...).x
2424
SemanticVersion(semver::Version),
25-
Tagged(~str), // String that can't be parsed as a version.
26-
// Requirements get interpreted exactly
2725
NoVersion // user didn't specify a version -- prints as 0.1
2826
}
2927

@@ -78,7 +76,7 @@ impl Ord for Version {
7876
impl ToStr for Version {
7977
fn to_str(&self) -> ~str {
8078
match *self {
81-
ExactRevision(ref n) | Tagged(ref n) => fmt!("%s", n.to_str()),
79+
ExactRevision(ref n) => fmt!("%s", n.to_str()),
8280
SemanticVersion(ref v) => fmt!("%s", v.to_str()),
8381
NoVersion => ~"0.1"
8482
}

0 commit comments

Comments
 (0)