Skip to content

Commit 6f2e4d6

Browse files
committed
---
yaml --- r: 64831 b: refs/heads/snap-stage3 c: 1137fbd h: refs/heads/master i: 64829: 42cd2d4 64827: f5b20be 64823: ee93270 64815: 28f2c59 64799: 553419b 64767: 6b3415b v: v3
1 parent b880321 commit 6f2e4d6

File tree

10 files changed

+175
-139
lines changed

10 files changed

+175
-139
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: ceba95ced2ecd5f64eae6c8db5ae314b8b1b8822
4+
refs/heads/snap-stage3: 1137fbd9abe7ba941b973c9fdc18845686e02ed6
55
refs/heads/try: 7b78b52e602bb3ea8174f9b2006bff3315f03ef9
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/doc/rustpkg.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,14 @@ A package ID can also specify a version, like:
7676
`github.com/mozilla/rust#0.3`.
7777
In this case, `rustpkg` will check that the repository `github.com/mozilla/rust` has a tag named `0.3`,
7878
and report an error otherwise.
79+
A package ID can also specify a particular revision of a repository, like:
80+
`github.com/mozilla/rust#release-0.7`.
81+
When the refspec (portion of the package ID after the `#`) can't be parsed as a decimal number,
82+
rustpkg passes the refspec along to the version control system without interpreting it.
83+
rustpkg also interprets any dependencies on such a package ID literally
84+
(as opposed to versions, where a newer version satisfies a dependency on an older version).
85+
Thus, `github.com/mozilla/rust#5c4cd30f80` is also a valid package ID,
86+
since git can deduce that 5c4cd30f80 refers to a revision of the desired repository.
7987

8088
## Source files
8189

branches/snap-stage3/mk/tests.mk

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,12 @@ ifdef CHECK_XFAILS
3434
TESTARGS += --ignored
3535
endif
3636

37-
TEST_BENCH = --bench
37+
CTEST_BENCH = --bench
3838

3939
# Arguments to the cfail/rfail/rpass/bench tests
4040
ifdef CFG_VALGRIND
4141
CTEST_RUNTOOL = --runtool "$(CFG_VALGRIND)"
42-
TEST_BENCH =
43-
endif
44-
45-
ifdef NO_BENCH
46-
TEST_BENCH =
42+
CTEST_BENCH =
4743
endif
4844

4945
# Arguments to the perf tests
@@ -73,12 +69,12 @@ TEST_RATCHET_NOISE_PERCENT=10.0
7369
# Whether to ratchet or merely save benchmarks
7470
ifdef CFG_RATCHET_BENCH
7571
CRATE_TEST_BENCH_ARGS=\
76-
--test $(TEST_BENCH) \
72+
--test $(CTEST_BENCH) \
7773
--ratchet-metrics $(call TEST_RATCHET_FILE,$(1),$(2),$(3),$(4)) \
7874
--ratchet-noise-percent $(TEST_RATCHET_NOISE_PERCENT)
7975
else
8076
CRATE_TEST_BENCH_ARGS=\
81-
--test $(TEST_BENCH) \
77+
--test $(CTEST_BENCH) \
8278
--save-metrics $(call TEST_RATCHET_FILE,$(1),$(2),$(3),$(4))
8379
endif
8480

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

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

2322
// An enumeration of the unpacked source of a package workspace.
2423
// This contains a list of files found in the source workspace.
@@ -102,22 +101,13 @@ impl PkgSrc {
102101
}
103102

104103
let url = fmt!("https://%s", self.id.remote_path.to_str());
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
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)
118108
}
119109
else {
120-
Some(local)
110+
None
121111
}
122112
}
123113

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ pub fn rust_path() -> ~[Path] {
5252
}
5353
None => ~[]
5454
};
55+
debug!("RUST_PATH entries from environment: %?", env_rust_path);
5556
let cwd = os::getcwd();
5657
// now add in default entries
5758
env_rust_path.push(cwd.clone());
@@ -345,7 +346,12 @@ fn target_file_in_workspace(pkgid: &PkgId, workspace: &Path,
345346
let subdir = match what {
346347
Lib => "lib", Main | Test | Bench => "bin"
347348
};
348-
let result = workspace.push(subdir);
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+
};
349355
if !os::path_exists(&result) && !mkdir_recursive(&result, U_RWX) {
350356
cond.raise((result.clone(), fmt!("target_file_in_workspace couldn't \
351357
create the %s dir (pkgid=%s, workspace=%s, what=%?, where=%?",

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

Lines changed: 40 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,30 +10,23 @@
1010

1111
// Utils for working with version control repositories. Just git right now.
1212

13-
use std::{io, os, run, str};
13+
use std::{os, run, str};
14+
use std::run::{ProcessOutput, ProcessOptions, Process};
1415
use version::*;
1516

1617
/// For a local git repo
1718
pub fn git_clone(source: &Path, target: &Path, v: &Version) {
1819
assert!(os::path_is_dir(source));
1920
assert!(is_git_dir(source));
2021
if !os::path_exists(target) {
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(),
22+
debug!("Running: git clone %s %s", source.to_str(),
2623
target.to_str());
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-
}
24+
assert!(git_clone_general(source.to_str(), target, v));
3425
}
3526
else {
3627
// Pull changes
28+
// Note that this ignores tags, which is probably wrong. There are no tests for
29+
// it, though.
3730
debug!("Running: git --work-tree=%s --git-dir=%s pull --no-edit %s",
3831
target.to_str(), target.push(".git").to_str(), source.to_str());
3932
let outp = run::process_output("git", [fmt!("--work-tree=%s", target.to_str()),
@@ -43,6 +36,40 @@ pub fn git_clone(source: &Path, target: &Path, v: &Version) {
4336
}
4437
}
4538

39+
/// Source can be either a URL or a local file path.
40+
/// true if successful
41+
pub fn git_clone_general(source: &str, target: &Path, v: &Version) -> bool {
42+
let outp = run::process_output("git", [~"clone", source.to_str(), target.to_str()]);
43+
if outp.status != 0 {
44+
debug!(str::from_bytes_owned(outp.output.clone()));
45+
debug!(str::from_bytes_owned(outp.error));
46+
false
47+
}
48+
else {
49+
match v {
50+
&ExactRevision(ref s) | &Tagged(ref s) => {
51+
let outp = process_output_in_cwd("git", [~"checkout", fmt!("%s", *s)],
52+
target);
53+
if outp.status != 0 {
54+
debug!(str::from_bytes_owned(outp.output.clone()));
55+
debug!(str::from_bytes_owned(outp.error));
56+
false
57+
}
58+
else {
59+
true
60+
}
61+
}
62+
_ => true
63+
}
64+
}
65+
}
66+
67+
fn process_output_in_cwd(prog: &str, args: &[~str], cwd: &Path) -> ProcessOutput {
68+
let mut prog = Process::new(prog, args, ProcessOptions{ dir: Some(cwd)
69+
,..ProcessOptions::new()});
70+
prog.finish_with_output()
71+
}
72+
4673
pub fn is_git_dir(p: &Path) -> bool {
4774
os::path_is_dir(&p.push(".git"))
4875
}

0 commit comments

Comments
 (0)