Commit a7b1ceb8 authored by Elouan Martinet's avatar Elouan Martinet
Browse files

Catch exceptions and display errors when needed

parent 80595e0b7385
......@@ -70,16 +70,7 @@ def _ghclone(path_url, destination):
update_hgrc(destination)
@command("ghclone", [], _("git_path working_directory"), norepo=True)
def ghclone(ui, git_url, working_directory, **opts):
"""Prepare working directory to work with github"""
_ghclone(git_url, working_directory)
@command("ghpull", [], _(""))
def ghpull(ui, repo, **opts):
"""Prepare working directory to work with github"""
git_repo = ui.config("gitrepo", "gitrepo")
def _ghpull(git_repo):
cmd(
"Fetching remote Git repository",
["git", "fetch", "-q", "origin", "master:master"],
......@@ -89,12 +80,10 @@ def ghpull(ui, repo, **opts):
cmd("Publishing master bookmark", ["hg", "phase", "-p", "master"])
@command("ghpush", [], _("bookmark"))
def ghpush(ui, repo, bookmark, **opts):
"""Prepare working directory to work with github"""
git_repo = ui.config("gitrepo", "gitrepo")
def _ghpush(git_repo, bookmark):
cmd(
"Pushing bookmark to local Git repository", ["hg", "push", "-B", bookmark, "-f"]
"Pushing bookmark to local Git repository",
["hg", "push", "-B", bookmark, "-f"],
)
# TODO use --force-with-lease if possible
cmd(
......@@ -102,3 +91,34 @@ def ghpush(ui, repo, bookmark, **opts):
["git", "push", "--set-upstream", "origin", bookmark, "-f"],
cwd=git_repo,
)
@command("ghclone", [], _("git_path working_directory"), norepo=True)
def ghclone(ui, git_url, working_directory, **opts):
"""Prepare working directory to work with github"""
try:
_ghclone(git_url, working_directory)
except CalledProcessError:
pass
except ValueError as ex:
print(ex)
@command("ghpull", [], _(""))
def ghpull(ui, repo, **opts):
"""Prepare working directory to work with github"""
git_repo = ui.config("gitrepo", "gitrepo")
try:
_ghpull(git_repo)
except CalledProcessError:
pass
@command("ghpush", [], _("bookmark"))
def ghpush(ui, repo, bookmark, **opts):
"""Prepare working directory to work with github"""
git_repo = ui.config("gitrepo", "gitrepo")
try:
_ghpush(git_repo, bookmark)
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