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
1a349699dd78
Commit
2bdd36fe
authored
Oct 13, 2020
by
Elouan Martinet
Browse files
Reformat using black
parent
8278d0f68560
Changes
1
Hide whitespace changes
Inline
Side-by-side
hggithub.py
View file @
1a349699
...
...
@@ -15,34 +15,35 @@ command = registrar.command(cmdtable)
def
git_clone
(
path_url
,
destination
):
ret_code
=
call
([
'
git
'
,
'
clone
'
,
path_url
,
destination
,
'
--bare
'
])
ret_code
=
call
([
"
git
"
,
"
clone
"
,
path_url
,
destination
,
"
--bare
"
])
print
(
ret_code
)
def
hg_clone
(
path
,
destination
):
ret_code
=
call
([
'
hg
'
,
'
clone
'
,
path
,
destination
])
ret_code
=
call
([
"
hg
"
,
"
clone
"
,
path
,
destination
])
print
(
ret_code
)
ret_code
=
call
([
'
hg
'
,
'
phase
'
,
'
-p
'
,
'
master
'
],
cwd
=
destination
)
ret_code
=
call
([
"
hg
"
,
"
phase
"
,
"
-p
"
,
"
master
"
],
cwd
=
destination
)
print
(
ret_code
)
def
update_hgrc
(
git_repo
,
hg_repo
):
hgrc_path
=
osp
.
join
(
hg_repo
,
'
.hg
'
,
'
hgrc
'
)
with
open
(
hgrc_path
,
'a'
)
as
fobj
:
fobj
.
write
(
'
\n
'
)
fobj
.
write
(
'
[gitrepo]
\n
'
)
fobj
.
write
(
'
gitrepo = {}
\n
'
.
format
(
git_repo
))
hgrc_path
=
osp
.
join
(
hg_repo
,
"
.hg
"
,
"
hgrc
"
)
with
open
(
hgrc_path
,
"a"
)
as
fobj
:
fobj
.
write
(
"
\n
"
)
fobj
.
write
(
"
[gitrepo]
\n
"
)
fobj
.
write
(
"
gitrepo = {}
\n
"
.
format
(
git_repo
))
def
_ghclone
(
path_url
,
destination
):
project_name
=
osp
.
split
(
destination
)[
-
1
]
git_repo
=
osp
.
abspath
(
osp
.
join
(
destination
,
'git_{}'
.
format
(
project_name
)))
hg_repo
=
osp
.
abspath
(
osp
.
join
(
destination
,
'hg_{}'
.
format
(
project_name
)))
git_repo
=
osp
.
abspath
(
osp
.
join
(
destination
,
"git_{}"
.
format
(
project_name
)))
hg_repo
=
osp
.
abspath
(
osp
.
join
(
destination
,
"hg_{}"
.
format
(
project_name
)))
if
osp
.
isdir
(
destination
):
raise
ValueError
(
'Destination directory {} for hg repository should not exist'
.
format
(
destination
))
"Destination directory {} for hg repository should not exist"
.
format
(
destination
)
)
else
:
os
.
mkdir
(
destination
)
os
.
mkdir
(
hg_repo
)
...
...
@@ -51,36 +52,29 @@ def _ghclone(path_url, destination):
update_hgrc
(
git_repo
,
hg_repo
)
@
command
(
'ghclone'
,
[],
_
(
'git_path working_directory'
),
norepo
=
True
)
@
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'
,
[],
_
(
''
))
@
command
(
"ghpull"
,
[],
_
(
""
))
def
ghpull
(
ui
,
repo
,
**
opts
):
"""Prepare working directory to work with github"""
git_repo
=
ui
.
config
(
'gitrepo'
,
'gitrepo'
)
ret_code
=
call
([
'git'
,
'fetch'
,
'-q'
,
'origin'
,
'master:master'
],
cwd
=
git_repo
)
ret_code
=
call
([
'hg'
,
'pull'
])
ret_code
=
call
([
'hg'
,
'phase'
,
'-p'
,
'master'
])
@
command
(
'ghpush'
,
[],
_
(
'bookmark'
))
git_repo
=
ui
.
config
(
"gitrepo"
,
"gitrepo"
)
ret_code
=
call
([
"git"
,
"fetch"
,
"-q"
,
"origin"
,
"master:master"
],
cwd
=
git_repo
)
ret_code
=
call
([
"hg"
,
"pull"
])
ret_code
=
call
([
"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
'
)
ret_code
=
call
([
'
hg
'
,
'
push
'
,
'
-B
'
,
bookmark
,
'
-f
'
])
#ret_code = call(['git', 'push', '--set-upstream',
git_repo
=
ui
.
config
(
"
gitrepo
"
,
"
gitrepo
"
)
ret_code
=
call
([
"
hg
"
,
"
push
"
,
"
-B
"
,
bookmark
,
"
-f
"
])
#
ret_code = call(['git', 'push', '--set-upstream',
# 'origin', bookmark, '--force-with-lease'], cwd=git_repo)
ret_code
=
call
([
'git'
,
'push'
,
'--set-upstream'
,
'origin'
,
bookmark
,
'-f'
],
cwd
=
git_repo
)
ret_code
=
call
(
[
"git"
,
"push"
,
"--set-upstream"
,
"origin"
,
bookmark
,
"-f"
],
cwd
=
git_repo
,
)
Write
Preview
Markdown
is supported
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