aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--components/servo/Cargo.lock2
-rw-r--r--python/tidy.py46
2 files changed, 44 insertions, 4 deletions
diff --git a/components/servo/Cargo.lock b/components/servo/Cargo.lock
index 5acf07fafc6..af8c32f26b0 100644
--- a/components/servo/Cargo.lock
+++ b/components/servo/Cargo.lock
@@ -627,7 +627,7 @@ version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"gl_common 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
- "gl_generator 0.0.26 (registry+https://github.com/rust-lang/crates.io-index)",
+ "gl_generator 0.0.27 (registry+https://github.com/rust-lang/crates.io-index)",
"khronos_api 0.0.7 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
]
diff --git a/python/tidy.py b/python/tidy.py
index 1185a08e759..e576d501a37 100644
--- a/python/tidy.py
+++ b/python/tidy.py
@@ -16,7 +16,7 @@ import StringIO
import sys
from licenseck import licenses
-filetypes_to_check = [".rs", ".rc", ".cpp", ".c", ".h", ".py", ".toml", ".webidl"]
+filetypes_to_check = [".rs", ".rc", ".cpp", ".c", ".h", ".lock", ".py", ".toml", ".webidl"]
reftest_dir = "./tests/ref"
reftest_filetype = ".list"
python_dependencies = [
@@ -70,7 +70,7 @@ VIM_HEADER = "/* vim:"
def check_license(file_name, contents):
- if file_name.endswith(".toml"):
+ if file_name.endswith(".toml") or file_name.endswith(".lock"):
raise StopIteration
while contents.startswith(EMACS_HEADER) or contents.startswith(VIM_HEADER):
_, _, contents = contents.partition("\n")
@@ -148,6 +148,46 @@ def check_flake8(file_name, contents):
yield line_num, message.strip()
+def check_lock(file_name, contents):
+ if not file_name.endswith(".lock"):
+ raise StopIteration
+ contents = contents.splitlines(True)
+ idx = 1
+ packages = {}
+ exceptions = ["glutin", "wayland-kbd"] # package names to be neglected (as named by cargo)
+
+ while idx < len(contents):
+ content = contents[idx].strip()
+ if 'name' in content:
+ base_name = content.split('"')[1]
+ # we need the base package because some other package might demand a new version in the following lines
+ packages[base_name] = contents[idx + 1].split('"')[1], idx + 2, base_name
+ if 'dependencies' in content:
+ idx += 1
+ while contents[idx].strip() != ']':
+ package = contents[idx].strip().strip('",').split()
+ name, version = package[0], package[1]
+ if name not in packages: # store the line number & base package name for future comparison
+ packages[name] = (version, idx + 1, base_name)
+ elif all([packages[name][0] != version, name not in exceptions, base_name not in exceptions]):
+ line = idx + 1
+ version_1 = tuple(map(int, packages[name][0].split('.')))
+ version_2 = tuple(map(int, version.split('.')))
+ if version_1 < version_2: # get the line & base package containing the older version
+ packages[name], (version, line, base_name) = (version, line, base_name), packages[name]
+
+ message = 'conflicting versions for package "%s"' % name
+ error = '\n\t\033[93mexpected maximum version "{}"\033[0m'.format(packages[name][0]) + \
+ '\n\t\033[91mbut, "{}" demands "{}"\033[0m' \
+ .format(base_name, version)
+ suggest = "\n\t\033[93mtry upgrading with\033[0m " + \
+ "\033[96m./mach cargo-update -p {}:{}\033[0m" \
+ .format(name, version)
+ yield (line, message + error + suggest)
+ idx += 1
+ idx += 1
+
+
def check_toml(file_name, contents):
if not file_name.endswith(".toml"):
raise StopIteration
@@ -433,7 +473,7 @@ def scan():
files_to_check = filter(should_check, all_files)
checking_functions = [check_license, check_by_line, check_flake8, check_toml,
- check_rust, check_webidl_spec, check_spec]
+ check_lock, check_rust, check_webidl_spec, check_spec]
errors = collect_errors_for_files(files_to_check, checking_functions)
reftest_files = (os.path.join(r, f) for r, _, files in os.walk(reftest_dir) for f in files)