Commit 87f074d9 authored by Aurelien Lubert's avatar Aurelien Lubert
Browse files

Fix code to work with Python 3.9

parent 9dfacac4637d
......@@ -24,7 +24,7 @@ def cmd(description, *args, **kwargs):
check_output(*args, **kwargs)
except CalledProcessError as ex:
if not quiet:
print(ex.output).strip()
print(ex.output.decode("utf-8").strip())
print("Command exited with code %d" % ex.returncode)
raise
......@@ -109,7 +109,7 @@ def _gfpull(git_repo):
["git", "branch", "--format=%(refname:lstrip=2)"], cwd=git_repo
)
git_pull_master(git_repo)
for branch in branches.splitlines():
for branch in branches.decode("utf-8").splitlines():
if branch != "master":
try:
cmd(
......@@ -156,7 +156,9 @@ def _gfremote(git_repo, git_remote_url, git_branch, hg_bookmark):
def gfclone(ui, git_fork_url, git_upstream_url, working_directory, **opts):
"""Prepare working directory to work with forge"""
try:
_gfclone(git_fork_url, git_upstream_url, working_directory)
_gfclone(git_fork_url.decode("utf-8"),
git_upstream_url.decode("utf-8"),
working_directory.decode("utf-8"))
except CalledProcessError:
pass
except ValueError as ex:
......@@ -167,9 +169,9 @@ def gfclone(ui, git_fork_url, git_upstream_url, working_directory, **opts):
def gfpull(ui, repo, **opts):
"""Prepare working directory to work with forge"""
os.chdir(repo.root)
git_repo = ui.config("gitrepo", "gitrepo")
git_repo = ui.config(b"gitrepo", b"gitrepo")
try:
_gfpull(git_repo)
_gfpull(git_repo.decode("utf-8"))
except CalledProcessError:
pass
......@@ -178,9 +180,10 @@ def gfpull(ui, repo, **opts):
def gfpush(ui, repo, bookmark, **opts):
"""Prepare working directory to work with forge"""
os.chdir(repo.root)
git_repo = ui.config("gitrepo", "gitrepo")
git_repo = ui.config(b"gitrepo", b"gitrepo")
try:
_gfpush(git_repo, bookmark)
_gfpush(git_repo.decode("utf-8"),
bookmark.decode("utf-8"))
except CalledProcessError:
pass
except ValueError as ex:
......@@ -191,8 +194,11 @@ def gfpush(ui, repo, bookmark, **opts):
def gfremote(ui, repo, git_remote_url, git_branch, hg_bookmark, **opts):
"""Pull remote branch from alternate Git repository"""
os.chdir(repo.root)
git_repo = ui.config("gitrepo", "gitrepo")
git_repo = ui.config(b"gitrepo", b"gitrepo")
try:
_gfremote(git_repo, git_remote_url, git_branch, hg_bookmark)
_gfremote(git_repo.decode("utf-8"),
git_remote_url.decode("utf-8"),
git_branch.decode("utf-8"),
hg_bookmark.decode("utf-8"))
except CalledProcessError:
pass
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment