Keep stable rustc versions in clean-nightlies

Check the `rust-stable-version` file to keep the last n
versions of both the nightly and the stable compiler.
This commit is contained in:
Aneesh Agrawal 2017-05-02 02:41:55 -04:00
parent f284a15e4b
commit cc86993857

View file

@ -290,9 +290,13 @@ class MachCommands(CommandBase):
default='1', default='1',
help='Keep up to this many most recent nightlies') help='Keep up to this many most recent nightlies')
def clean_nightlies(self, force=False, keep=None): def clean_nightlies(self, force=False, keep=None):
rust_current = self.rust_version() self.set_use_stable_rust(False)
rust_current_nightly = self.rust_version()
self.set_use_stable_rust(True)
rust_current_stable = self.rust_version()
cargo_current = self.cargo_build_id() cargo_current = self.cargo_build_id()
print("Current Rust version: {}".format(rust_current)) print("Current Rust nightly version: {}".format(rust_current_nightly))
print("Current Rust stable version: {}".format(rust_current_stable))
print("Current Cargo version: {}".format(cargo_current)) print("Current Cargo version: {}".format(cargo_current))
to_keep = { to_keep = {
'rust': set(), 'rust': set(),
@ -300,20 +304,24 @@ class MachCommands(CommandBase):
} }
if int(keep) == 1: if int(keep) == 1:
# Optimize keep=1 case to not invoke git # Optimize keep=1 case to not invoke git
to_keep['rust'].add(rust_current) to_keep['rust'].add(rust_current_nightly)
to_keep['rust'].add(rust_current_stable)
to_keep['cargo'].add(cargo_current) to_keep['cargo'].add(cargo_current)
else: else:
for tool in ["rust", "cargo"]: for tool, version_files in {
commit_file = '{}-commit-hash'.format(tool) 'rust': ['rust-commit-hash', 'rust-stable-version'],
cmd = subprocess.Popen( 'cargo': ['cargo-commit-hash'],
['git', 'log', '--oneline', '--no-color', '-n', keep, '--patch', commit_file], }.items():
stdout=subprocess.PIPE, for version_file in version_files:
universal_newlines=True cmd = subprocess.Popen(
) ['git', 'log', '--oneline', '--no-color', '-n', keep, '--patch', version_file],
stdout, _ = cmd.communicate() stdout=subprocess.PIPE,
for line in stdout.splitlines(): universal_newlines=True
if line.startswith("+") and not line.startswith("+++"): )
to_keep[tool].add(line[1:]) stdout, _ = cmd.communicate()
for line in stdout.splitlines():
if line.startswith("+") and not line.startswith("+++"):
to_keep[tool].add(line[1:])
removing_anything = False removing_anything = False
for tool in ["rust", "cargo"]: for tool in ["rust", "cargo"]: