Commit 1c3ec903 authored by Elouan Martinet's avatar Elouan Martinet
Browse files

Add command for pulling branch from alternate Git repository

parent 2b39f1fea3bf
......@@ -76,6 +76,14 @@ gitrepo = .hg/git.git
)
def hg_pull():
cmd(
"Updating Mercurial repository",
["hg", "--config", "phases.new-commit=draft", "pull"],
)
cmd("Publishing master bookmark", ["hg", "phase", "-p", "master"])
def _ghclone(git_fork_url, git_upstream_url, destination):
working_dir, project_name = osp.split(destination)
git_repo = osp.abspath(osp.join(working_dir, ".%s.git" % project_name))
......@@ -105,12 +113,7 @@ def _ghpull(git_repo):
["git", "fetch", "origin", "%s:%s" % (branch, branch)],
cwd=git_repo,
)
cmd(
"Updating Mercurial repository",
["hg", "--config", "phases.new-commit=draft", "pull"],
)
cmd("Publishing master bookmark", ["hg", "phase", "-p", "master"])
hg_pull()
def _ghpush(git_repo, bookmark):
......@@ -128,6 +131,18 @@ def _ghpush(git_repo, bookmark):
)
def _ghremote(git_repo, git_remote_url, git_branch, hg_bookmark):
if hg_bookmark == "master":
raise ValueError("Cannot replace master bookmark")
cmd(
"Fetching branch %s to %s from specified remote Git repository"
% (git_branch, hg_bookmark),
["git", "fetch", git_remote_url, "%s:%s" % (git_branch, hg_bookmark)],
cwd=git_repo,
)
hg_pull()
@command(
"ghclone", [], _("git_fork_path git_upstream_path working_directory"), norepo=True
)
......@@ -163,3 +178,14 @@ def ghpush(ui, repo, bookmark, **opts):
pass
except ValueError as ex:
print(ex)
@command("ghremote", [], _("git_remote_path git_branch hg_bookmark"))
def ghremote(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")
try:
_ghremote(git_repo, git_remote_url, git_branch, hg_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