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
759ac56497e7
Commit
759ac56497e7
authored
15 years ago
by
Scott Chacon
Browse files
Options
Downloads
Patches
Plain Diff
adding hg explicit file renames to the git commit message
parent
a061dce264b7
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
+10
-2
10 additions, 2 deletions
TODO.txt
git_handler.py
+22
-9
22 additions, 9 deletions
git_handler.py
with
32 additions
and
11 deletions
TODO.txt
+
10
−
2
View file @
759ac564
GENERAL
==========
* integrate as native protocol handler (hg push git://...)
* fully integrate as native protocol handler
- hg push git@...
- hg fetch [remote] (remote is url, hg alias or hg-git remote)
- hg clone url
* more tests
* submodules?
* .gitignore, etc - try to convert?
...
...
@@ -26,8 +29,12 @@
* octopus merge explode/implode
* different committer in Git objects
WEBSITE
===========
* more usage documentation
* screencast
SPEED/EFFICIENCY
================
* switch object mapping to hg->git since the many to one is that direction
* don't send blobs/trees already on server
...
...
@@ -29,6 +36,7 @@
SPEED/EFFICIENCY
================
* switch object mapping to hg->git since the many to one is that direction
* don't send blobs/trees already on server
* packfile creation benchmarking (seems to take a while sometimes)
\ No newline at end of file
* packfile creation benchmarking (seems to take a while sometimes)
- at least provide status output
\ No newline at end of file
This diff is collapsed.
Click to expand it.
git_handler.py
+
22
−
9
View file @
759ac564
...
...
@@ -186,11 +186,8 @@
self
.
export_hg_commit
(
p_rev
)
ctx
=
self
.
repo
.
changectx
(
rev
)
tree_sha
=
self
.
write_git_tree
(
ctx
)
# TODO : something with tags?
# TODO : explicit file renaming, copying?
tree_sha
,
renames
=
self
.
write_git_tree
(
ctx
)
commit
=
{}
commit
[
'
tree
'
]
=
tree_sha
(
time
,
timezone
)
=
ctx
.
date
()
...
...
@@ -200,5 +197,6 @@
# HG EXTRA INFORMATION
add_extras
=
False
extra_message
=
''
if
not
ctx
.
branch
()
==
'
default
'
:
add_extras
=
True
...
...
@@ -203,3 +201,4 @@
if
not
ctx
.
branch
()
==
'
default
'
:
add_extras
=
True
extra_message
+=
"
branch :
"
+
ctx
.
branch
()
+
"
\n
"
...
...
@@ -205,2 +204,7 @@
if
renames
:
add_extras
=
True
for
oldfile
,
newfile
in
renames
:
extra_message
+=
"
rename :
"
+
oldfile
+
"
=>
"
+
newfile
+
"
\n
"
if
add_extras
:
...
...
@@ -206,6 +210,5 @@
if
add_extras
:
commit
[
'
message
'
]
+=
"
\n\n
--HG--
\n
"
commit
[
'
message
'
]
+=
"
branch :
"
+
ctx
.
branch
()
+
"
\n
"
commit
[
'
message
'
]
+=
"
\n\n
--HG--
\n
"
+
extra_message
commit
[
'
parents
'
]
=
[]
for
parent
in
parents
:
...
...
@@ -221,6 +224,7 @@
def
write_git_tree
(
self
,
ctx
):
trees
=
{}
man
=
ctx
.
manifest
()
renames
=
[]
for
filenm
in
man
.
keys
():
# write blob if not in our git database
fctx
=
ctx
.
filectx
(
filenm
)
...
...
@@ -224,6 +228,10 @@
for
filenm
in
man
.
keys
():
# write blob if not in our git database
fctx
=
ctx
.
filectx
(
filenm
)
rename
=
fctx
.
renamed
()
if
rename
:
filerename
,
sha
=
rename
renames
.
append
((
filerename
,
filenm
))
is_exec
=
'
x
'
in
fctx
.
flags
()
is_link
=
'
l
'
in
fctx
.
flags
()
file_id
=
hex
(
fctx
.
filenode
())
...
...
@@ -287,7 +295,7 @@
tree_data
.
append
(
entry
)
tree_sha
=
self
.
git
.
write_tree_array
(
tree_data
)
# writing new trees to git
tree_shas
[
dirnm
]
=
tree_sha
return
tree_sha
# should be the last root tree sha
return
(
tree_sha
,
renames
)
# should be the last root tree sha
def
remote_head
(
self
,
remote_name
):
for
head
,
sha
in
self
.
git
.
remote_refs
(
remote_name
).
iteritems
():
...
...
@@ -462,9 +470,12 @@
# TODO : (?) have to handle merge contexts at some point (two parent files, etc)
# TODO : Do something less coarse-grained than try/except on the
# get_file call for removed files
# *TODO : parse commit message to extract hg meta info
def
getfilectx
(
repo
,
memctx
,
f
):
try
:
(
mode
,
sha
,
data
)
=
self
.
git
.
get_file
(
commit
,
f
)
e
=
self
.
convert_git_int_mode
(
mode
)
except
TypeError
:
raise
IOError
()
...
...
@@ -465,10 +476,11 @@
def
getfilectx
(
repo
,
memctx
,
f
):
try
:
(
mode
,
sha
,
data
)
=
self
.
git
.
get_file
(
commit
,
f
)
e
=
self
.
convert_git_int_mode
(
mode
)
except
TypeError
:
raise
IOError
()
return
context
.
memfilectx
(
f
,
data
,
'
l
'
in
e
,
'
x
'
in
e
,
None
)
copied_path
=
None
# *TODO : file rename
return
context
.
memfilectx
(
f
,
data
,
'
l
'
in
e
,
'
x
'
in
e
,
copied_path
)
p1
=
"
0
"
*
40
p2
=
"
0
"
*
40
...
...
@@ -486,6 +498,7 @@
# get a list of the changed, added, removed files
extra
=
{}
# *TODO : if committer is different than author, add it to extra
text
=
commit
.
message
date
=
datetime
.
datetime
.
fromtimestamp
(
commit
.
author_time
).
strftime
(
"
%Y-%m-%d %H:%M:%S
"
)
ctx
=
context
.
memctx
(
self
.
repo
,
(
p1
,
p2
),
text
,
files
,
getfilectx
,
...
...
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