Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upUse a .toml file to store settings #420
Conversation
This comment has been minimized.
This comment has been minimized.
|
Example toml file: default_toolchain = "nightly-x86_64-pc-windows-msvc"
version = "12"
[overrides]
"\\\\?\\C:\\Users\\diggs\\workspace\\multirust-rs" = "nightly-x86_64-pc-windows-msvc" |
Diggsey
referenced this pull request
May 8, 2016
Closed
Override remove from inner directories lies about successful removal #339
brson
reviewed
May 8, 2016
|
|
||
| pub fn from_toml(mut table: toml::Table, path: &str) -> Result<Self> { | ||
| let version = try!(get_string(&mut table, "version", path)); | ||
| if !SUPPORTED_METADATA_VERSIONS.contains(&&*version) { |
This comment has been minimized.
This comment has been minimized.
brson
May 8, 2016
Contributor
ISTM that "2" shouldn't be considered valid here since there's never been a settings.toml containing version 2.
This comment has been minimized.
This comment has been minimized.
Diggsey
May 8, 2016
Author
Contributor
The upgrade to settings.toml is orthogonal to the metadata version: since it's lossless it gets converted automatically, so if you upgrade from an old version of multirust to rustup, it will result in a settings.toml file with a version of 2, and you will then be required to do a metadata upgrade.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
My only reluctance is that this commits us to deserializing a config file every time someone runs cargo or rustc, but I'm somewhat resigned to that fate. Most if this information must be read anyway so it could even be better to load it all at once. cc @alexcrichton Can you also add the telemetry flag? |
brson
reviewed
May 8, 2016
| let _ = utils::remove_file("version", &legacy_version_file); | ||
| let _ = utils::remove_file("default", &default_file); | ||
| let _ = utils::remove_file("overrides", &override_db); | ||
| } |
This comment has been minimized.
This comment has been minimized.
brson
reviewed
May 8, 2016
| Settings::parse(&content) | ||
| } | ||
| pub fn with<T, F: FnOnce(&Settings) -> Result<T>>(&self, f: F) -> Result<T> { | ||
| f(&try!(self.read_settings())) |
This comment has been minimized.
This comment has been minimized.
brson
May 8, 2016
Contributor
I imagine this file is going to get read several times during each run. Can it instead load the file at startup and reuse it?
This comment has been minimized.
This comment has been minimized.
|
Looks great. I do think it needs to take care to not read the file multiple times. Will you also add a test that this conversion works? A simple way to do it is to modify the files in |
Diggsey
added some commits
May 9, 2016
This comment has been minimized.
This comment has been minimized.
|
I think that's everything! |
This comment has been minimized.
This comment has been minimized.
Yeah unfortunately |
This comment has been minimized.
This comment has been minimized.
|
@Diggsey ok, this looks fine by me. Before merging this big change and risking more breakage I want to get a build out that fixes the windows bustage. I'll merge after that. |
This comment has been minimized.
This comment has been minimized.
|
Great! |
This comment has been minimized.
This comment has been minimized.
|
|
brson
force-pushed the
master
branch
2 times, most recently
from
1acdeb2
to
9830d33
May 12, 2016
brson
reviewed
May 12, 2016
| "a;nightly\nb;stable").unwrap(); | ||
| rustup_utils::raw::write_file(&config.rustupdir.join("telemetry-on"), "").unwrap(); | ||
| expect_err(config, &["rustup", "default", "nightly"], | ||
| "rustup's metadata is out of date. run `rustup self upgrade-data`"); |
This comment has been minimized.
This comment has been minimized.
brson
May 12, 2016
Contributor
Why is this expecting an error message saying to run upgrade-data? Doesn't this upgrade happen silently?
I think this test should be tweaked just a little. Before writing the old metadata, first run the commands that correspond to the metadata, then write the metadata and delete the settings.toml file. Then run some rustup command to force the silent upgrade. Then run further rustc commands that verify that the metadata is intact - that rustc --version prints the right thing for the default and override (telemetry flag probably not worth testing explicitly).
This comment has been minimized.
This comment has been minimized.
Diggsey
May 12, 2016
Author
Contributor
This is testing an upgrade from metadata version 2, ie. an old metadata version, for which we currently require an explicit upgrade (because it wipes the toolchains). I can add a separate test for just the toml upgrade, but it would be a subset of what is tested here.
Diggsey
added some commits
May 15, 2016
This comment has been minimized.
This comment has been minimized.
|
This is back up to date, just waiting on CI again. |
Diggsey commentedMay 8, 2016
This doesn't bump the metadata version. Running rustup will silently convert your
version,defaultandoverridesfiles into a singlesettings.tomlfile.If your metadata version is older than "12" it will first be converted to the new format, and then rustup will require you to perform a metadata upgrade exactly as it would before.
This paves the way for storing additional information in the settings file (such as the host target).