From f068c3e865c19a5b6244b02a9f6aec3e6abc4f49 Mon Sep 17 00:00:00 2001 From: Josh Matthews Date: Fri, 19 Feb 2021 10:43:59 -0500 Subject: [PATCH] Cherry-pick of https://github.com/web-platform-tests/wpt/commit/1b484b247dd26a364a40b43ee79946c3f38c45e3. --- tests/wpt/metadata/MANIFEST.json | 4 +-- .../tools/wptrunner/wptrunner/update/sync.py | 2 +- .../tools/wptrunner/wptrunner/update/tree.py | 34 +++++++++---------- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/tests/wpt/metadata/MANIFEST.json b/tests/wpt/metadata/MANIFEST.json index 9670ef33e50..3b8e19b5110 100644 --- a/tests/wpt/metadata/MANIFEST.json +++ b/tests/wpt/metadata/MANIFEST.json @@ -372475,11 +372475,11 @@ [] ], "sync.py": [ - "f878752f4514ae9cce5c74a5f994fc5e71eac826", + "4ace28f443cd238c1a0fe0902c7b0db88fdaf6bb", [] ], "tree.py": [ - "f362770ff16d30e449de853f687467297b0ed077", + "4127b0ef7dc61f07b3cff760ba9cbb515a83986f", [] ], "update.py": [ diff --git a/tests/wpt/web-platform-tests/tools/wptrunner/wptrunner/update/sync.py b/tests/wpt/web-platform-tests/tools/wptrunner/wptrunner/update/sync.py index f878752f451..4ace28f443c 100644 --- a/tests/wpt/web-platform-tests/tools/wptrunner/wptrunner/update/sync.py +++ b/tests/wpt/web-platform-tests/tools/wptrunner/wptrunner/update/sync.py @@ -67,7 +67,7 @@ class UpdateCheckout(Step): state.local_branch) sync_path = os.path.abspath(sync_tree.root) if sync_path not in sys.path: - from update import setup_paths + from .update import setup_paths setup_paths(sync_path) def restore(self, state): diff --git a/tests/wpt/web-platform-tests/tools/wptrunner/wptrunner/update/tree.py b/tests/wpt/web-platform-tests/tools/wptrunner/wptrunner/update/tree.py index f362770ff16..4127b0ef7dc 100644 --- a/tests/wpt/web-platform-tests/tools/wptrunner/wptrunner/update/tree.py +++ b/tests/wpt/web-platform-tests/tools/wptrunner/wptrunner/update/tree.py @@ -87,7 +87,7 @@ class HgTree(object): @property def is_clean(self): - return self.hg("status").strip() == "" + return self.hg("status").strip() == b"" def add_new(self, prefix=None): if prefix is not None: @@ -105,7 +105,7 @@ class HgTree(object): except subprocess.CalledProcessError: pass - patch_names = [item.strip() for item in self.hg("qseries").split("\n") if item.strip()] + patch_names = [item.strip() for item in self.hg("qseries").split(b"\n") if item.strip()] suffix = 0 test_name = patch_name @@ -142,7 +142,7 @@ class GitTree(object): def __init__(self, root=None, log_error=True): if root is None: - root = git("rev-parse", "--show-toplevel", log_error=log_error).strip() + root = git("rev-parse", "--show-toplevel", log_error=log_error).strip().decode('utf-8') self.root = root self.git = vcs.bind_to_repo(git, self.root, log_error=log_error) self.message = None @@ -178,7 +178,7 @@ class GitTree(object): @property def is_clean(self): - return self.git("status").strip() == "" + return self.git("status").strip() == b"" def add_new(self, prefix=None): """Add files to the staging area. @@ -203,7 +203,7 @@ class GitTree(object): f.seek(0) ignored_files = sync_tree.git("check-ignore", "--no-index", "--stdin", "-z", stdin=f) args = [] - for entry in ignored_files.split('\0'): + for entry in ignored_files.decode('utf-8').split('\0'): args.append(os.path.join(prefix, entry)) if args: self.git("add", "--force", *args) @@ -219,7 +219,7 @@ class GitTree(object): args.append(ref_filter) data = self.git("show-ref", *args) rv = [] - for line in data.split("\n"): + for line in data.split(b"\n"): if not line.strip(): continue sha1, ref = line.split() @@ -237,7 +237,7 @@ class GitTree(object): args.append(ref_filter) data = self.git("ls-remote", remote, *args) rv = [] - for line in data.split("\n"): + for line in data.split(b"\n"): if not line.strip(): continue sha1, ref = line.split() @@ -250,8 +250,8 @@ class GitTree(object): :param remote: the remote URL :param branch: the branch name""" for sha1, ref in self.list_remote(remote, branch): - if ref == "refs/heads/%s" % branch: - return self.commit_cls(self, sha1) + if ref.decode('utf-8') == "refs/heads/%s" % branch: + return self.commit_cls(self, sha1.decode('utf-8')) assert False def create_patch(self, patch_name, message): @@ -299,8 +299,8 @@ class GitTree(object): args = [] if branch: - branches = [ref[len("refs/heads/"):] for sha1, ref in self.list_refs() - if ref.startswith("refs/heads/")] + branches = [ref[len("refs/heads/"):].decode('utf-8') for sha1, ref in self.list_refs() + if ref.startswith(b"refs/heads/")] branch = get_unique_name(branches, branch) args += ["-b", branch] @@ -336,8 +336,8 @@ class GitTree(object): rv = [] for repo_path in repo_paths: - paths = vcs.git("ls-tree", "-r", "--name-only", "HEAD", repo=repo_path).split("\n") - rv.extend(os.path.relpath(os.path.join(repo_path, item), self.root) for item in paths + paths = vcs.git("ls-tree", "-r", "--name-only", "HEAD", repo=repo_path).split(b"\n") + rv.extend(os.path.relpath(os.path.join(repo_path, item.decode('utf-8')), self.root) for item in paths if item.strip()) return rv @@ -345,11 +345,11 @@ class GitTree(object): """List submodule directories""" output = self.git("submodule", "status", "--recursive") rv = [] - for line in output.split("\n"): + for line in output.split(b"\n"): line = line.strip() if not line: continue - parts = line.split(" ") + parts = line.split(b" ") rv.append(parts[1]) return rv @@ -403,5 +403,5 @@ class Commit(object): self.git = self.tree.git def _get_meta(self): - author, email, message = self.git("show", "-s", "--format=format:%an\n%ae\n%B", self.sha1).split("\n", 2) - return author, email, self.msg_cls(message) + author, email, message = self.git("show", "-s", "--format=format:%an\n%ae\n%B", self.sha1).split(b"\n", 2) + return author.decode('utf-8'), email.decode('utf-8'), self.msg_cls(message.decode('utf-8'))