Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
open-source
hggitforge
Commits
119cc9f67298
Commit
1c3ec903
authored
Oct 14, 2020
by
Elouan Martinet
Browse files
Add command for pulling branch from alternate Git repository
parent
2b39f1fea3bf
Changes
1
Hide whitespace changes
Inline
Side-by-side
hggithub.py
View file @
119cc9f6
...
...
@@ -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
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment