Skip to content

Commit 13e15c2

Browse files
Merge pull request #847 from RalfJung/toolchain-names-try2
toolchain specifier: we don't need the master# / try# prefix any more
2 parents 3b22712 + c5b70eb commit 13e15c2

3 files changed

Lines changed: 31 additions & 49 deletions

File tree

docs/bot-usage.md

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,13 @@ parents (both should be merge commits by bors):
6262

6363
![Where to look for the commits](images/pr-try-commit.png)
6464

65-
You must prefix the start commit with `master#`, and the end commit with
66-
`try#`, and both of them should be written with the full 40-chars hash.
67-
(See [specifying-toolchains](#specifying-toolchains) for more details on that syntax.)
65+
Both start and end commit need to be given as full 40-char hashes.
6866

6967
Then you need to choose the [experiment mode you want to
7068
use][h-experiment-modes] and type up the command in your GitHub PR:
7169

7270
```
73-
@craterbot run start=master#fullhash end=try#fullhash mode=YOUR-MODE
71+
@craterbot run start=fullhash end=fullhash mode=YOUR-MODE
7472
```
7573

7674
[Go back to the TOC][h-toc]
@@ -149,8 +147,7 @@ that capability.
149147
### Specifying Toolchains
150148

151149
Crater allows some configurations to the toolchains used in an experiment.
152-
You can specify a toolchain using a rustup name or `channel#sha` where `channel`
153-
can be `master` for regular main branch toolchains or `try` for try builds.
150+
You can specify a toolchain using a rustup name or a full 40-character git SHA.
154151
On top of that, you can use the following flags:
155152
* `+rustflags={flags}`: sets the `RUSTFLAGS` environment variable to `{flags}` when
156153
building with this toolchain, e.g. `+rustflags=-Zverbose`

src/server/routes/webhooks/commands.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ pub fn run(
7575
rustflags: None,
7676
rustdocflags: None,
7777
cargoflags: None,
78-
ci_try: false,
7978
patches: Vec::new(),
8079
});
8180
detected_end = Some(Toolchain {
@@ -84,7 +83,6 @@ pub fn run(
8483
rustflags: None,
8584
rustdocflags: None,
8685
cargoflags: None,
87-
ci_try: true,
8886
patches: Vec::new(),
8987
});
9088
message = message.line(

src/toolchain.rs

Lines changed: 28 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ lazy_static! {
1414
rustflags: None,
1515
rustdocflags: None,
1616
cargoflags: None,
17-
ci_try: false,
1817
patches: Vec::new(),
1918
};
2019

@@ -25,7 +24,6 @@ lazy_static! {
2524
rustflags: None,
2625
rustdocflags: None,
2726
cargoflags: None,
28-
ci_try: false,
2927
patches: Vec::new(),
3028
};
3129
}
@@ -37,7 +35,6 @@ pub struct Toolchain {
3735
pub rustflags: Option<String>,
3836
pub rustdocflags: Option<String>,
3937
pub cargoflags: Option<String>,
40-
pub ci_try: bool,
4138
pub patches: Vec<CratePatch>,
4239
}
4340

@@ -62,11 +59,7 @@ impl fmt::Display for Toolchain {
6259
if let Some(dist) = self.source.as_dist() {
6360
write!(f, "{}", dist.name())?;
6461
} else if let Some(ci) = self.source.as_ci() {
65-
if self.ci_try {
66-
write!(f, "try#{}", ci.sha())?;
67-
} else {
68-
write!(f, "master#{}", ci.sha())?;
69-
}
62+
write!(f, "{}", ci.sha())?;
7063
} else {
7164
panic!("unsupported rustwide toolchain");
7265
}
@@ -101,10 +94,10 @@ pub enum ToolchainParseError {
10194
EmptyName,
10295
#[error("invalid toolchain source name: {0}")]
10396
InvalidSourceName(String),
97+
#[error("invalid old-style toolchain source name (try removing the leading `master#` or `try#`): {0}")]
98+
OldSourceName(String),
10499
#[error("invalid toolchain flag: {0}")]
105100
InvalidFlag(String),
106-
#[error("invalid toolchain SHA: {0} is missing a `try#` or `master#` prefix")]
107-
PrefixMissing(String),
108101
#[error("invalid url {0:?}: {1}")]
109102
InvalidUrl(String, url::ParseError),
110103
}
@@ -119,30 +112,27 @@ impl FromStr for Toolchain {
119112
fn from_str(input: &str) -> Result<Self, ToolchainParseError> {
120113
let mut parts = input.split('+');
121114

115+
// Note that string-ified toolchain names are stored in the databse, so a name that
116+
// was once accepted has to remain valid ~forever.
122117
let raw_source = parts.next().ok_or(ToolchainParseError::EmptyName)?;
123-
let mut ci_try = false;
124-
let source = if let Some(hash_idx) = raw_source.find('#') {
118+
let source = if TOOLCHAIN_SHA_RE.is_match(raw_source) {
119+
// A full 40-char SHA is definitely a CI-built toolchain.
120+
RustwideToolchain::ci(raw_source, /* alt */ false)
121+
} else if let Some(hash_idx) = raw_source.find('#') {
122+
// Old-style `source#sha` syntax.
123+
// We accept (and ignore) "master" and "try" to parse old database entries.
125124
let (source_name, sha_with_hash) = raw_source.split_at(hash_idx);
126-
127125
let sha = &sha_with_hash[1..];
128126
if sha.is_empty() {
129127
return Err(ToolchainParseError::EmptyName);
130128
}
131129

132130
match source_name {
133-
"try" => {
134-
ci_try = true;
135-
RustwideToolchain::ci(sha, false)
136-
}
137-
"master" => RustwideToolchain::ci(sha, false),
131+
"master" | "try" => RustwideToolchain::ci(sha, /* alt */ false),
138132
name => return Err(ToolchainParseError::InvalidSourceName(name.to_string())),
139133
}
140134
} else if raw_source.is_empty() {
141135
return Err(ToolchainParseError::EmptyName);
142-
} else if TOOLCHAIN_SHA_RE.is_match(raw_source) {
143-
// A common user error is unprefixed SHAs for the `start` or `end` toolchains, check for
144-
// these here.
145-
return Err(ToolchainParseError::PrefixMissing(raw_source.to_string()));
146136
} else {
147137
RustwideToolchain::dist(raw_source)
148138
};
@@ -180,7 +170,6 @@ impl FromStr for Toolchain {
180170
rustflags,
181171
rustdocflags,
182172
cargoflags,
183-
ci_try,
184173
patches,
185174
})
186175
}
@@ -229,7 +218,7 @@ mod tests {
229218
#[test]
230219
fn test_string_repr() {
231220
macro_rules! test_from_str {
232-
($($str:expr => { source: $source:expr, ci_try: $ci_try:expr, },)*) => {
221+
($($str:expr => { source: $source:expr, },)*) => {
233222
$(
234223
// Test parsing without flags
235224
test_from_str!($str => Toolchain {
@@ -238,7 +227,6 @@ mod tests {
238227
rustflags: None,
239228
rustdocflags: None,
240229
cargoflags: None,
241-
ci_try: $ci_try,
242230
patches: Vec::new(),
243231
});
244232

@@ -249,7 +237,6 @@ mod tests {
249237
rustflags: None,
250238
rustdocflags: None,
251239
cargoflags: None,
252-
ci_try: $ci_try,
253240
patches: Vec::new(),
254241
});
255242

@@ -260,7 +247,6 @@ mod tests {
260247
rustflags: Some("foo bar".to_string()),
261248
rustdocflags: None,
262249
cargoflags: None,
263-
ci_try: $ci_try,
264250
patches: Vec::new(),
265251
});
266252

@@ -271,7 +257,6 @@ mod tests {
271257
rustflags: None,
272258
rustdocflags: Some("-Zunstable-options -wjson".to_string()),
273259
cargoflags: None,
274-
ci_try: $ci_try,
275260
patches: Vec::new(),
276261
});
277262

@@ -282,7 +267,6 @@ mod tests {
282267
rustflags: None,
283268
rustdocflags: None,
284269
cargoflags: Some("foo bar".to_string()),
285-
ci_try: $ci_try,
286270
patches: Vec::new(),
287271
});
288272

@@ -293,7 +277,6 @@ mod tests {
293277
rustflags: None,
294278
rustdocflags: None,
295279
cargoflags: None,
296-
ci_try: $ci_try,
297280
patches: vec![CratePatch {
298281
name: "example".to_string(),
299282
repo: url::Url::parse("https://git.example.com/some/repo").unwrap(),
@@ -308,7 +291,6 @@ mod tests {
308291
rustflags: Some("foo bar".to_string()),
309292
rustdocflags: None,
310293
cargoflags: None,
311-
ci_try: $ci_try,
312294
patches: vec![CratePatch {
313295
name: "example".to_string(),
314296
repo: url::Url::parse("https://git.example.com/some/repo").unwrap(),
@@ -333,26 +315,32 @@ mod tests {
333315
test_from_str! {
334316
"stable" => {
335317
source: RustwideToolchain::dist("stable"),
336-
ci_try: false,
337318
},
338319
"beta-1970-01-01" => {
339320
source: RustwideToolchain::dist("beta-1970-01-01"),
340-
ci_try: false,
341321
},
342322
"nightly-1970-01-01" => {
343323
source: RustwideToolchain::dist("nightly-1970-01-01"),
344-
ci_try: false,
345324
},
346-
"master#0000000000000000000000000000000000000000" => {
325+
"0000000000000000000000000000000000000000" => {
347326
source: RustwideToolchain::ci("0000000000000000000000000000000000000000", false),
348-
ci_try: false,
349-
},
350-
"try#0000000000000000000000000000000000000000" => {
351-
source: RustwideToolchain::ci("0000000000000000000000000000000000000000", false),
352-
ci_try: true,
353327
},
354328
};
355329

330+
// Test compatibility reprs that do not round-trip.
331+
assert_eq!(
332+
Toolchain::from_str("master#0000000000000000000000000000000000000000")
333+
.unwrap()
334+
.source,
335+
RustwideToolchain::ci("0000000000000000000000000000000000000000", false)
336+
);
337+
assert_eq!(
338+
Toolchain::from_str("try#0000000000000000000000000000000000000000")
339+
.unwrap()
340+
.source,
341+
RustwideToolchain::ci("0000000000000000000000000000000000000000", false)
342+
);
343+
356344
// Test invalid reprs
357345
assert!(Toolchain::from_str("").is_err());
358346
assert!(Toolchain::from_str("master#").is_err());
@@ -371,6 +359,5 @@ mod tests {
371359
super::ToolchainParseError::InvalidUrl(..)
372360
));
373361
assert!(Toolchain::from_str("try#1234+target=").is_err());
374-
assert!(Toolchain::from_str("0000000000000000000000000000000000000000").is_err());
375362
}
376363
}

0 commit comments

Comments
 (0)