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
Admin message
This instance will be upgraded to Heptapod 17.9.0rc1 on 2025-03-27 between 17:00 and 18:00 UTC+2
Show more breadcrumbs
mercurial
hg-git
Commits
89992b6d
Commit
89992b6d
authored
15 years ago
by
Scott Chacon
Browse files
Options
Downloads
Patches
Plain Diff
mapping parents properly now
parent
c7719712
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
dulwich/objects.py
+9
-3
9 additions, 3 deletions
dulwich/objects.py
git_handler.py
+42
-14
42 additions, 14 deletions
git_handler.py
with
51 additions
and
17 deletions
dulwich/objects.py
+
9
−
3
View file @
89992b6d
...
...
@@ -502,7 +502,10 @@
self
.
_text
+=
self
.
_message
def
getfile
(
self
,
f
):
return
"
file contents
"
import
random
dt
=
"
file contents:
"
+
str
(
random
.
randrange
(
1
,
100
))
print
dt
return
dt
def
getmode
(
self
,
f
):
return
""
...
...
@@ -507,6 +510,9 @@
def
getmode
(
self
,
f
):
return
""
def
getfiles
(
self
):
return
[
'
test
'
]
@property
def
tree
(
self
):
"""
Returns the tree that is the state of this commit
"""
...
...
This diff is collapsed.
Click to expand it.
git_handler.py
+
42
−
14
View file @
89992b6d
import
os
,
errno
,
sys
,
time
,
datetime
import
os
,
errno
,
sys
,
time
,
datetime
,
pickle
,
copy
import
dulwich
from
dulwich.repo
import
Repo
from
dulwich.client
import
SimpleFetchGraphWalker
...
...
@@ -12,5 +12,9 @@
def
__init__
(
self
,
dest_repo
,
ui
):
self
.
repo
=
dest_repo
self
.
ui
=
ui
self
.
load_git
()
self
.
load_map
()
def
load_git
(
self
):
git_dir
=
os
.
path
.
join
(
self
.
repo
.
path
,
'
git
'
)
self
.
git
=
Repo
(
git_dir
)
...
...
@@ -15,8 +19,21 @@
git_dir
=
os
.
path
.
join
(
self
.
repo
.
path
,
'
git
'
)
self
.
git
=
Repo
(
git_dir
)
def
load_map
(
self
):
self
.
_map
=
{}
if
os
.
path
.
exists
(
self
.
repo
.
join
(
'
git-mapfile
'
)):
for
line
in
self
.
repo
.
opener
(
'
git-mapfile
'
):
gitsha
,
hgsha
=
line
.
strip
().
split
(
'
'
,
1
)
self
.
_map
[
gitsha
]
=
hgsha
def
save_map
(
self
):
file
=
self
.
repo
.
opener
(
'
git-mapfile
'
,
'
w+
'
)
for
gitsha
,
hgsha
in
self
.
_map
.
iteritems
():
file
.
write
(
"
%s %s
\n
"
%
(
gitsha
,
hgsha
))
file
.
close
()
def
fetch
(
self
,
git_url
):
self
.
ui
.
status
(
_
(
"
fetching from git url:
"
+
git_url
+
"
\n
"
))
self
.
export_git_objects
()
self
.
fetch_pack
(
git_url
)
self
.
import_git_objects
()
...
...
@@ -18,9 +35,10 @@
def
fetch
(
self
,
git_url
):
self
.
ui
.
status
(
_
(
"
fetching from git url:
"
+
git_url
+
"
\n
"
))
self
.
export_git_objects
()
self
.
fetch_pack
(
git_url
)
self
.
import_git_objects
()
self
.
save_map
()
def
fetch_pack
(
self
,
git_url
):
client
,
path
=
self
.
get_transport_and_path
(
git_url
)
graphwalker
=
SimpleFetchGraphWalker
(
self
.
git
.
heads
().
values
(),
self
.
git
.
get_parents
)
...
...
@@ -70,6 +88,5 @@
print
bookmarks
.
parse
(
self
.
repo
)
def
import_git_commit
(
self
,
commit
):
# check that parents are all in Hg, or no parents
print
commit
.
parents
...
...
@@ -74,6 +91,7 @@
print
commit
.
parents
# TODO : have to handle merge contexts at some point (two parent files, etc)
def
getfilectx
(
repo
,
memctx
,
f
):
data
=
commit
.
getfile
(
f
)
e
=
commit
.
getmode
(
f
)
return
context
.
memfilectx
(
f
,
data
,
'
l
'
in
e
,
'
x
'
in
e
,
None
)
...
...
@@ -76,7 +94,7 @@
def
getfilectx
(
repo
,
memctx
,
f
):
data
=
commit
.
getfile
(
f
)
e
=
commit
.
getmode
(
f
)
return
context
.
memfilectx
(
f
,
data
,
'
l
'
in
e
,
'
x
'
in
e
,
None
)
p1
=
"
0
"
*
40
p2
=
"
0
"
*
40
...
...
@@ -81,3 +99,13 @@
p1
=
"
0
"
*
40
p2
=
"
0
"
*
40
# TODO : do something if parent is not mapped yet!
if
len
(
commit
.
parents
)
>
0
:
sha
=
commit
.
parents
[
0
]
p1
=
self
.
_map
[
sha
]
if
len
(
commit
.
parents
)
>
1
:
sha
=
commit
.
parents
[
1
]
p2
=
self
.
_map
[
sha
]
if
len
(
commit
.
parents
)
>
2
:
# TODO : map extra parents to the extras file
pass
...
...
@@ -83,4 +111,4 @@
files
=
[
'
test
'
]
files
=
commit
.
getfiles
()
# get a list of the changed, added, removed files
...
...
@@ -85,3 +113,4 @@
# get a list of the changed, added, removed files
extra
=
{}
text
=
commit
.
message
...
...
@@ -87,6 +116,4 @@
text
=
commit
.
message
extra
=
{}
date
=
datetime
.
datetime
.
fromtimestamp
(
commit
.
author_time
).
strftime
(
"
%Y-%m-%d
"
)
print
date
date
=
datetime
.
datetime
.
fromtimestamp
(
commit
.
author_time
).
strftime
(
"
%Y-%m-%d %H:%M:%S
"
)
ctx
=
context
.
memctx
(
self
.
repo
,
(
p1
,
p2
),
text
,
files
,
getfilectx
,
commit
.
author
,
date
,
extra
)
...
...
@@ -91,4 +118,3 @@
ctx
=
context
.
memctx
(
self
.
repo
,
(
p1
,
p2
),
text
,
files
,
getfilectx
,
commit
.
author
,
date
,
extra
)
print
ctx
a
=
self
.
repo
.
commitctx
(
ctx
)
...
...
@@ -94,8 +120,10 @@
a
=
self
.
repo
.
commitctx
(
ctx
)
print
a
#puts p2 = hex(self.repo.changelog.tip())
pass
# get changeset id
p2
=
hex
(
self
.
repo
.
changelog
.
tip
())
# save changeset to mapping file
gitsha
=
commit
.
id
self
.
_map
[
gitsha
]
=
p2
def
getfilectx
(
self
,
source
,
repo
,
memctx
,
f
):
v
=
files
[
f
]
...
...
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