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
13112e40fcee
Commit
13112e40
authored
Jan 08, 2021
by
Dan Villiom Podlaski Christiansen
Browse files
git-cleanup: refactor, simplify, and make output more helpful
parent
b6cf7e366f64
Pipeline
#15778
passed with stages
in 10 minutes and 43 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
hggit/__init__.py
View file @
13112e40
...
...
@@ -264,19 +264,12 @@
@
command
(
b
'git-cleanup'
)
def
git_cleanup
(
ui
,
repo
):
'''clean up Git commit map after history editing'''
new_map
=
[]
gh
=
repo
.
githandler
for
line
in
gh
.
vfs
(
gh
.
map_file
):
gitsha
,
hgsha
=
line
.
strip
().
split
(
b
' '
,
1
)
if
hgsha
in
repo
:
new_map
.
append
(
b
'%s %s
\n
'
%
(
gitsha
,
hgsha
))
wlock
=
repo
.
wlock
()
try
:
f
=
gh
.
vfs
(
gh
.
map_file
,
b
'wb'
)
f
.
writelines
(
new_map
)
finally
:
wlock
.
release
()
ui
.
status
(
_
(
b
'git commit map cleaned
\n
'
))
with
repo
.
wlock
():
gh
=
repo
.
githandler
ncleaned
=
gh
.
clean_map
()
gh
.
save_map
(
gh
.
map_file
)
ui
.
status
(
_
(
b
'%d commits pruned from map
\n
'
)
%
ncleaned
)
def
findcommonoutgoing
(
orig
,
repo
,
other
,
*
args
,
**
kwargs
):
...
...
hggit/git_handler.py
View file @
13112e40
...
...
@@ -197,6 +197,15 @@
def
map_git_get
(
self
,
hgsha
):
return
self
.
_map_hg
.
get
(
hgsha
)
def
clean_map
(
self
):
prior_size
=
len
(
self
.
_map_hg
)
for
hgsha
in
list
(
self
.
_map_hg
):
if
hgsha
not
in
self
.
repo
:
del
self
.
_map_git
[
self
.
_map_hg
.
pop
(
hgsha
)]
return
prior_size
-
len
(
self
.
_map_hg
)
def
load_map
(
self
):
map_git_real
=
{}
map_hg_real
=
{}
...
...
tests/test-clone.t
View file @
13112e40
...
...
@@ -100,7 +100,7 @@
$ ls hgrepo-shared/.hg | grep git
[1]
$ hg -R hgrepo-shared git-cleanup
git
commit
map cleaned
0
commit
s pruned from map
$ rm -rf hgrepo-base hgrepo-shared
clone empty repo
...
...
tests/test-pull-after-strip.t
View file @
13112e40
...
...
@@ -68,7 +68,7 @@
abort:
you
appear
to
have
run
strip
-
please
run
hg
git
-
cleanup
[
255
]
$
hg
git
-
cleanup
git
commit
map
cleaned
1
commit
s
pruned
from
map
pull
works
after
'
hg git-cleanup
'
"
adding remote bookmark
"
message
was
added
in
Mercurial
2.3
$
hg
pull
-
r
beta
|
grep
-
v
"
adding remote bookmark
"
...
...
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