Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
mercurial
hg-git
Commits
d9c98d8eacda
Commit
d9c98d8e
authored
Apr 26, 2022
by
Dan Villiom Podlaski Christiansen
Browse files
clone: copy git state when doing local clones
parent
94af56b4c195
Pipeline
#57749
failed with stages
in 6 minutes and 55 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
hggit/hgrepo.py
View file @
d9c98d8e
...
...
@@ -5,4 +5,5 @@
from
mercurial
import
bundle2
from
mercurial
import
exchange
from
mercurial
import
exthelper
from
mercurial
import
hg
from
mercurial
import
repoview
...
...
@@ -8,4 +9,5 @@
from
mercurial
import
repoview
from
mercurial
import
streamclone
from
mercurial
import
util
as
hgutil
from
mercurial.node
import
bin
,
hex
...
...
@@ -149,6 +151,53 @@
addpartrevgittags
(
repo
,
bundler
,
outgoing
)
if
hasattr
(
streamclone
,
'_v2_walk'
):
# added in mercurial 5.9
@
eh
.
wrapfunction
(
streamclone
,
'_v2_walk'
)
def
_v2_walk
(
orig
,
repo
,
*
args
,
**
kwargs
):
entries
,
totalfilesize
=
orig
(
repo
,
*
args
,
**
kwargs
)
if
repo
.
ui
.
configbool
(
b
'experimental'
,
b
'hg-git-serve'
):
for
fn
in
(
repo
.
githandler
.
map_file
,
repo
.
githandler
.
tags_file
):
totalfilesize
+=
repo
.
svfs
.
lstat
(
fn
).
st_size
entries
.
append
(
(
streamclone
.
_srcstore
,
fn
,
streamclone
.
_filefull
,
None
),
)
return
entries
,
totalfilesize
else
:
@
eh
.
reposetup
def
add_files_to_copylist
(
ui
,
repo
):
if
hasattr
(
repo
,
'store'
):
class
hggitstore
(
repo
.
store
.
__class__
):
def
copylist
(
self
):
fns
=
super
().
copylist
()
if
repo
.
ui
.
configbool
(
b
'experimental'
,
b
'hg-git-serve'
):
fns
+=
[
b
'store/'
+
repo
.
githandler
.
map_file
,
b
'store/'
+
repo
.
githandler
.
tags_file
,
]
return
fns
repo
.
store
.
__class__
=
hggitstore
@
eh
.
wrapfunction
(
bundle2
,
'getrepocaps'
)
def
getrepocaps
(
orig
,
repo
,
**
kwargs
):
caps
=
orig
(
repo
,
**
kwargs
)
if
repo
.
ui
.
configbool
(
b
'experimental'
,
b
'hg-git-serve'
):
caps
[
CAPABILITY_MAP
]
=
()
caps
[
CAPABILITY_TAGS
]
=
()
return
caps
@
eh
.
extsetup
def
install_server_support
(
ui
):
@
bundle2
.
parthandler
(
BUNDLEPART_MAP
)
...
...
tests/test-hg-clone.t
View file @
d9c98d8e
...
...
@@ -56,5 +56,7 @@
$ hg clone -U hgrepo otherhgrepo
$ cd otherhgrepo
$ find .hg -name
'
git
*
'
| sort
.hg/store/git-mapfile
.hg/store/git-tags
$ hg tags -q
tip
...
...
@@ -59,3 +61,4 @@
$ hg tags -q
tip
alpha
$ hg log -r
'
fromgit
()'
-T
'{
rev
}:{
node
|
short
}
{
gitnode
|
short
}
\
n
'
...
...
@@ -61,4 +64,5 @@
$ hg log -r
'
fromgit
()'
-T
'{
rev
}:{
node
|
short
}
{
gitnode
|
short
}
\
n
'
0:ff7a2f2d8d70 7eeab2ea75ec
$ cd ..
Checking using a pull clone
...
...
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