Cherry-pick of 1b484b247d.

This commit is contained in:
Josh Matthews 2021-02-19 10:43:59 -05:00
parent 5b8f045f2b
commit f068c3e865
3 changed files with 20 additions and 20 deletions

View file

@ -372475,11 +372475,11 @@
[] []
], ],
"sync.py": [ "sync.py": [
"f878752f4514ae9cce5c74a5f994fc5e71eac826", "4ace28f443cd238c1a0fe0902c7b0db88fdaf6bb",
[] []
], ],
"tree.py": [ "tree.py": [
"f362770ff16d30e449de853f687467297b0ed077", "4127b0ef7dc61f07b3cff760ba9cbb515a83986f",
[] []
], ],
"update.py": [ "update.py": [

View file

@ -67,7 +67,7 @@ class UpdateCheckout(Step):
state.local_branch) state.local_branch)
sync_path = os.path.abspath(sync_tree.root) sync_path = os.path.abspath(sync_tree.root)
if sync_path not in sys.path: if sync_path not in sys.path:
from update import setup_paths from .update import setup_paths
setup_paths(sync_path) setup_paths(sync_path)
def restore(self, state): def restore(self, state):

View file

@ -87,7 +87,7 @@ class HgTree(object):
@property @property
def is_clean(self): def is_clean(self):
return self.hg("status").strip() == "" return self.hg("status").strip() == b""
def add_new(self, prefix=None): def add_new(self, prefix=None):
if prefix is not None: if prefix is not None:
@ -105,7 +105,7 @@ class HgTree(object):
except subprocess.CalledProcessError: except subprocess.CalledProcessError:
pass 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 suffix = 0
test_name = patch_name test_name = patch_name
@ -142,7 +142,7 @@ class GitTree(object):
def __init__(self, root=None, log_error=True): def __init__(self, root=None, log_error=True):
if root is None: 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.root = root
self.git = vcs.bind_to_repo(git, self.root, log_error=log_error) self.git = vcs.bind_to_repo(git, self.root, log_error=log_error)
self.message = None self.message = None
@ -178,7 +178,7 @@ class GitTree(object):
@property @property
def is_clean(self): def is_clean(self):
return self.git("status").strip() == "" return self.git("status").strip() == b""
def add_new(self, prefix=None): def add_new(self, prefix=None):
"""Add files to the staging area. """Add files to the staging area.
@ -203,7 +203,7 @@ class GitTree(object):
f.seek(0) f.seek(0)
ignored_files = sync_tree.git("check-ignore", "--no-index", "--stdin", "-z", stdin=f) ignored_files = sync_tree.git("check-ignore", "--no-index", "--stdin", "-z", stdin=f)
args = [] 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)) args.append(os.path.join(prefix, entry))
if args: if args:
self.git("add", "--force", *args) self.git("add", "--force", *args)
@ -219,7 +219,7 @@ class GitTree(object):
args.append(ref_filter) args.append(ref_filter)
data = self.git("show-ref", *args) data = self.git("show-ref", *args)
rv = [] rv = []
for line in data.split("\n"): for line in data.split(b"\n"):
if not line.strip(): if not line.strip():
continue continue
sha1, ref = line.split() sha1, ref = line.split()
@ -237,7 +237,7 @@ class GitTree(object):
args.append(ref_filter) args.append(ref_filter)
data = self.git("ls-remote", remote, *args) data = self.git("ls-remote", remote, *args)
rv = [] rv = []
for line in data.split("\n"): for line in data.split(b"\n"):
if not line.strip(): if not line.strip():
continue continue
sha1, ref = line.split() sha1, ref = line.split()
@ -250,8 +250,8 @@ class GitTree(object):
:param remote: the remote URL :param remote: the remote URL
:param branch: the branch name""" :param branch: the branch name"""
for sha1, ref in self.list_remote(remote, branch): for sha1, ref in self.list_remote(remote, branch):
if ref == "refs/heads/%s" % branch: if ref.decode('utf-8') == "refs/heads/%s" % branch:
return self.commit_cls(self, sha1) return self.commit_cls(self, sha1.decode('utf-8'))
assert False assert False
def create_patch(self, patch_name, message): def create_patch(self, patch_name, message):
@ -299,8 +299,8 @@ class GitTree(object):
args = [] args = []
if branch: if branch:
branches = [ref[len("refs/heads/"):] for sha1, ref in self.list_refs() branches = [ref[len("refs/heads/"):].decode('utf-8') for sha1, ref in self.list_refs()
if ref.startswith("refs/heads/")] if ref.startswith(b"refs/heads/")]
branch = get_unique_name(branches, branch) branch = get_unique_name(branches, branch)
args += ["-b", branch] args += ["-b", branch]
@ -336,8 +336,8 @@ class GitTree(object):
rv = [] rv = []
for repo_path in repo_paths: for repo_path in repo_paths:
paths = vcs.git("ls-tree", "-r", "--name-only", "HEAD", repo=repo_path).split("\n") 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), self.root) for item in paths rv.extend(os.path.relpath(os.path.join(repo_path, item.decode('utf-8')), self.root) for item in paths
if item.strip()) if item.strip())
return rv return rv
@ -345,11 +345,11 @@ class GitTree(object):
"""List submodule directories""" """List submodule directories"""
output = self.git("submodule", "status", "--recursive") output = self.git("submodule", "status", "--recursive")
rv = [] rv = []
for line in output.split("\n"): for line in output.split(b"\n"):
line = line.strip() line = line.strip()
if not line: if not line:
continue continue
parts = line.split(" ") parts = line.split(b" ")
rv.append(parts[1]) rv.append(parts[1])
return rv return rv
@ -403,5 +403,5 @@ class Commit(object):
self.git = self.tree.git self.git = self.tree.git
def _get_meta(self): def _get_meta(self):
author, email, message = self.git("show", "-s", "--format=format:%an\n%ae\n%B", self.sha1).split("\n", 2) author, email, message = self.git("show", "-s", "--format=format:%an\n%ae\n%B", self.sha1).split(b"\n", 2)
return author, email, self.msg_cls(message) return author.decode('utf-8'), email.decode('utf-8'), self.msg_cls(message.decode('utf-8'))