Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
hg-git
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mercurial
hg-git
Commits
7e98757deadc
Commit
7e98757deadc
authored
15 years ago
by
Scott Chacon
Browse files
Options
Downloads
Patches
Plain Diff
author and extra data fixes
parent
74f38b519887
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
TODO.txt
+1
-2
1 addition, 2 deletions
TODO.txt
git_handler.py
+25
-7
25 additions, 7 deletions
git_handler.py
with
26 additions
and
9 deletions
TODO.txt
+
1
−
2
View file @
7e98757d
...
...
@@ -4,7 +4,7 @@
- hg push git@...
- hg fetch [remote] (remote is url, hg alias or hg-git remote)
- hg clone url
* work fine with eclipse plugin or tortoise-hg
MAPPING ISSUES
==============
...
...
@@ -26,7 +26,6 @@
===========
* more usage documentation
* screencast
* git+ssh, git@ descriptions, better error detection for that
SPEED/EFFICIENCY
...
...
This diff is collapsed.
Click to expand it.
git_handler.py
+
25
−
7
View file @
7e98757d
import
os
,
errno
,
sys
,
time
,
datetime
,
pickle
,
copy
,
math
import
os
,
errno
,
sys
,
time
,
datetime
,
pickle
,
copy
,
math
,
urllib
import
toposort
import
dulwich
from
dulwich.repo
import
Repo
...
...
@@ -254,7 +254,7 @@
# hg authors might not have emails
author
=
ctx
.
user
()
if
not
'
>
'
in
author
:
# TODO : this kills losslessness - die (submodules)?
if
not
'
>
'
in
author
:
author
=
author
+
'
<none@none>
'
commit
[
'
author
'
]
=
author
+
'
'
+
str
(
int
(
time
))
+
'
'
+
format_timezone
(
-
timezone
)
message
=
ctx
.
description
()
...
...
@@ -282,7 +282,14 @@
add_extras
=
True
for
oldfile
,
newfile
in
renames
:
extra_message
+=
"
rename :
"
+
oldfile
+
"
=>
"
+
newfile
+
"
\n
"
for
key
,
value
in
extra
.
iteritems
():
if
key
in
[
'
committer
'
,
'
encoding
'
,
'
branch
'
,
'
hg-git
'
,
'
git
'
]:
continue
else
:
add_extras
=
True
extra_message
+=
"
extra :
"
+
key
+
"
:
"
+
urllib
.
quote
(
value
)
+
"
\n
"
if
add_extras
:
commit
[
'
message
'
]
+=
"
\n
--HG--
\n
"
+
extra_message
...
...
@@ -627,6 +634,8 @@
def
extract_hg_metadata
(
self
,
message
):
split
=
message
.
split
(
"
\n\n
--HG--
\n
"
,
1
)
renames
=
{}
extra
=
{}
files
=
[]
branch
=
False
if
len
(
split
)
==
2
:
message
,
meta
=
split
...
...
@@ -636,8 +645,9 @@
continue
command
,
data
=
line
.
split
(
"
:
"
,
1
)
if
command
==
'
rename
'
:
before
,
after
=
data
.
split
(
"
=>
"
,
1
)
renames
[
after
]
=
before
if
command
==
'
branch
'
:
branch
=
data
...
...
@@ -639,9 +649,14 @@
if
command
==
'
rename
'
:
before
,
after
=
data
.
split
(
"
=>
"
,
1
)
renames
[
after
]
=
before
if
command
==
'
branch
'
:
branch
=
data
return
(
message
,
renames
,
branch
)
if
command
==
'
files
'
:
files
.
append
(
data
)
if
command
==
'
extra
'
:
before
,
after
=
data
.
split
(
"
:
"
,
1
)
extra
[
before
]
=
urllib
.
unquote
(
after
)
return
(
message
,
renames
,
branch
,
files
,
extra
)
def
pseudo_import_git_commit
(
self
,
commit
):
(
strip_message
,
hg_renames
,
hg_branch
)
=
self
.
extract_hg_metadata
(
commit
.
message
)
...
...
@@ -669,8 +684,8 @@
self
.
ui
.
debug
(
_
(
"
importing: %s
\n
"
)
%
commit
.
id
)
# TODO : Do something less coarse-grained than try/except on the
# get_file call for removed files
(
strip_message
,
hg_renames
,
hg_branch
)
=
self
.
extract_hg_metadata
(
commit
.
message
)
(
strip_message
,
hg_renames
,
hg_branch
,
files
,
extra
)
=
self
.
extract_hg_metadata
(
commit
.
message
)
# get a list of the changed, added, removed files
files
=
self
.
git
.
get_files_changed
(
commit
)
...
...
@@ -716,5 +731,6 @@
vals
=
[
item
for
item
in
self
.
renames
[
p1
].
values
()
if
not
item
in
self
.
renames
[
p2
].
values
()]
for
removefile
in
vals
:
files
.
remove
(
removefile
)
author
=
commit
.
author
extra
=
{}
...
...
@@ -719,5 +735,7 @@
extra
=
{}
if
'
<none@none>
'
in
commit
.
author
:
author
=
commit
.
author
[:
-
12
]
# if named branch, add to extra
if
hg_branch
:
...
...
@@ -737,7 +755,7 @@
extra
[
'
hg-git
'
]
=
'
octopus-done
'
ctx
=
context
.
memctx
(
self
.
repo
,
(
p1
,
p2
),
text
,
files
,
getfilectx
,
commit
.
author
,
date
,
extra
)
author
,
date
,
extra
)
node
=
self
.
repo
.
commitctx
(
ctx
)
# save changeset to mapping file
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment