Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
mercurial-devel
Manage
Activity
Members
Labels
Plan
Wiki
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
Environments
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
mercurial-devel
Commits
680fe77ab5b8
Commit
680fe77ab5b8
authored
14 years ago
by
Matt Mackall
Browse files
Options
Downloads
Patches
Plain Diff
bundlerepo: use bundle objects everywhere
parent
40935b59518b
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
mercurial/bundlerepo.py
+36
-40
36 additions, 40 deletions
mercurial/bundlerepo.py
mercurial/changegroup.py
+1
-1
1 addition, 1 deletion
mercurial/changegroup.py
with
37 additions
and
41 deletions
mercurial/bundlerepo.py
+
36
−
40
View file @
680fe77a
...
...
@@ -18,7 +18,7 @@
import
localrepo
,
changelog
,
manifest
,
filelog
,
revlog
,
error
class
bundlerevlog
(
revlog
.
revlog
):
def
__init__
(
self
,
opener
,
indexfile
,
bundle
file
,
def
__init__
(
self
,
opener
,
indexfile
,
bundle
,
linkmapper
=
None
):
# How it works:
# to retrieve a revision, we need to know the offset of
...
...
@@ -22,7 +22,7 @@
linkmapper
=
None
):
# How it works:
# to retrieve a revision, we need to know the offset of
# the revision in the bundle
file
(an
opened file
).
# the revision in the bundle (an
unbundle object
).
#
# We store this offset in the index (start), to differentiate a
# rev in the bundle and from a rev in the revlog, we check
...
...
@@ -30,6 +30,6 @@
# (it is bigger since we store the node to which the delta is)
#
revlog
.
revlog
.
__init__
(
self
,
opener
,
indexfile
)
self
.
bundle
file
=
bundle
file
self
.
bundle
=
bundle
self
.
basemap
=
{}
def
chunkpositer
():
...
...
@@ -34,7 +34,7 @@
self
.
basemap
=
{}
def
chunkpositer
():
for
chunk
in
changegroup
.
chunkiter
(
bundle
file
):
pos
=
bundle
file
.
tell
()
for
chunk
in
changegroup
.
chunkiter
(
bundle
):
pos
=
bundle
.
tell
()
yield
chunk
,
pos
-
len
(
chunk
)
n
=
len
(
self
)
prev
=
None
...
...
@@ -68,7 +68,7 @@
prev
=
node
n
+=
1
def
bundle
(
self
,
rev
):
def
in
bundle
(
self
,
rev
):
"""
is rev from the bundle
"""
if
rev
<
0
:
return
False
...
...
@@ -79,5 +79,5 @@
# Warning: in case of bundle, the diff is against bundlebase,
# not against rev - 1
# XXX: could use some caching
if
not
self
.
bundle
(
rev
):
if
not
self
.
in
bundle
(
rev
):
return
revlog
.
revlog
.
_chunk
(
self
,
rev
)
...
...
@@ -83,6 +83,6 @@
return
revlog
.
revlog
.
_chunk
(
self
,
rev
)
self
.
bundle
file
.
seek
(
self
.
start
(
rev
))
return
self
.
bundle
file
.
read
(
self
.
length
(
rev
))
self
.
bundle
.
seek
(
self
.
start
(
rev
))
return
self
.
bundle
.
read
(
self
.
length
(
rev
))
def
revdiff
(
self
,
rev1
,
rev2
):
"""
return or calculate a delta between two revisions
"""
...
...
@@ -86,8 +86,8 @@
def
revdiff
(
self
,
rev1
,
rev2
):
"""
return or calculate a delta between two revisions
"""
if
self
.
bundle
(
rev1
)
and
self
.
bundle
(
rev2
):
if
self
.
in
bundle
(
rev1
)
and
self
.
in
bundle
(
rev2
):
# hot path for bundle
revb
=
self
.
rev
(
self
.
bundlebase
(
rev2
))
if
revb
==
rev1
:
return
self
.
_chunk
(
rev2
)
...
...
@@ -90,8 +90,8 @@
# hot path for bundle
revb
=
self
.
rev
(
self
.
bundlebase
(
rev2
))
if
revb
==
rev1
:
return
self
.
_chunk
(
rev2
)
elif
not
self
.
bundle
(
rev1
)
and
not
self
.
bundle
(
rev2
):
elif
not
self
.
in
bundle
(
rev1
)
and
not
self
.
in
bundle
(
rev2
):
return
revlog
.
revlog
.
revdiff
(
self
,
rev1
,
rev2
)
return
mdiff
.
textdiff
(
self
.
revision
(
self
.
node
(
rev1
)),
...
...
@@ -107,7 +107,7 @@
iter_node
=
node
rev
=
self
.
rev
(
iter_node
)
# reconstruct the revision if it is from a changegroup
while
self
.
bundle
(
rev
):
while
self
.
in
bundle
(
rev
):
if
self
.
_cache
and
self
.
_cache
[
0
]
==
iter_node
:
text
=
self
.
_cache
[
2
]
break
...
...
@@ -139,5 +139,5 @@
raise
NotImplementedError
class
bundlechangelog
(
bundlerevlog
,
changelog
.
changelog
):
def
__init__
(
self
,
opener
,
bundle
file
):
def
__init__
(
self
,
opener
,
bundle
):
changelog
.
changelog
.
__init__
(
self
,
opener
)
...
...
@@ -143,4 +143,4 @@
changelog
.
changelog
.
__init__
(
self
,
opener
)
bundlerevlog
.
__init__
(
self
,
opener
,
self
.
indexfile
,
bundle
file
)
bundlerevlog
.
__init__
(
self
,
opener
,
self
.
indexfile
,
bundle
)
class
bundlemanifest
(
bundlerevlog
,
manifest
.
manifest
):
...
...
@@ -145,4 +145,4 @@
class
bundlemanifest
(
bundlerevlog
,
manifest
.
manifest
):
def
__init__
(
self
,
opener
,
bundle
file
,
linkmapper
):
def
__init__
(
self
,
opener
,
bundle
,
linkmapper
):
manifest
.
manifest
.
__init__
(
self
,
opener
)
...
...
@@ -148,5 +148,5 @@
manifest
.
manifest
.
__init__
(
self
,
opener
)
bundlerevlog
.
__init__
(
self
,
opener
,
self
.
indexfile
,
bundle
file
,
bundlerevlog
.
__init__
(
self
,
opener
,
self
.
indexfile
,
bundle
,
linkmapper
)
class
bundlefilelog
(
bundlerevlog
,
filelog
.
filelog
):
...
...
@@ -150,5 +150,5 @@
linkmapper
)
class
bundlefilelog
(
bundlerevlog
,
filelog
.
filelog
):
def
__init__
(
self
,
opener
,
path
,
bundle
file
,
linkmapper
):
def
__init__
(
self
,
opener
,
path
,
bundle
,
linkmapper
):
filelog
.
filelog
.
__init__
(
self
,
opener
,
path
)
...
...
@@ -154,5 +154,5 @@
filelog
.
filelog
.
__init__
(
self
,
opener
,
path
)
bundlerevlog
.
__init__
(
self
,
opener
,
self
.
indexfile
,
bundle
file
,
bundlerevlog
.
__init__
(
self
,
opener
,
self
.
indexfile
,
bundle
,
linkmapper
)
class
bundlerepository
(
localrepo
.
localrepository
):
...
...
@@ -171,9 +171,9 @@
self
.
_url
=
'
bundle:
'
+
bundlename
self
.
tempfile
=
None
self
.
bundlefile
=
open
(
bundlename
,
"
rb
"
)
b
=
changegroup
.
readbundle
(
self
.
bundlefile
,
bundlename
)
if
b
.
compressed
():
f
=
open
(
bundlename
,
"
rb
"
)
self
.
bundle
=
changegroup
.
readbundle
(
f
,
bundlename
)
if
self
.
bundle
.
compressed
():
# we need a seekable, decompressed bundle
fdtemp
,
temp
=
tempfile
.
mkstemp
(
prefix
=
"
hg-bundle-
"
,
suffix
=
"
.hg10un
"
,
dir
=
self
.
path
)
...
...
@@ -183,9 +183,9 @@
try
:
fptemp
.
write
(
"
HG10UN
"
)
while
1
:
chunk
=
b
.
read
(
2
**
18
)
chunk
=
self
.
bundle
.
read
(
2
**
18
)
if
not
chunk
:
break
fptemp
.
write
(
chunk
)
finally
:
fptemp
.
close
()
...
...
@@ -187,7 +187,6 @@
if
not
chunk
:
break
fptemp
.
write
(
chunk
)
finally
:
fptemp
.
close
()
self
.
bundlefile
.
close
()
...
...
@@ -193,9 +192,9 @@
self
.
bundlefile
=
open
(
self
.
tempfile
,
"
rb
"
)
self
.
bundle
file
.
seek
(
6
)
f
=
open
(
self
.
tempfile
,
"
rb
"
)
self
.
bundle
=
changegroup
.
readbundle
(
f
,
bundlename
)
# dict with the mapping 'filename' -> position in the bundle
self
.
bundlefilespos
=
{}
@util.propertycache
def
changelog
(
self
):
...
...
@@ -196,12 +195,12 @@
# dict with the mapping 'filename' -> position in the bundle
self
.
bundlefilespos
=
{}
@util.propertycache
def
changelog
(
self
):
c
=
bundlechangelog
(
self
.
sopener
,
self
.
bundle
file
)
self
.
manstart
=
self
.
bundle
file
.
tell
()
c
=
bundlechangelog
(
self
.
sopener
,
self
.
bundle
)
self
.
manstart
=
self
.
bundle
.
tell
()
return
c
@util.propertycache
def
manifest
(
self
):
...
...
@@ -204,10 +203,10 @@
return
c
@util.propertycache
def
manifest
(
self
):
self
.
bundle
file
.
seek
(
self
.
manstart
)
m
=
bundlemanifest
(
self
.
sopener
,
self
.
bundle
file
,
self
.
changelog
.
rev
)
self
.
filestart
=
self
.
bundle
file
.
tell
()
self
.
bundle
.
seek
(
self
.
manstart
)
m
=
bundlemanifest
(
self
.
sopener
,
self
.
bundle
,
self
.
changelog
.
rev
)
self
.
filestart
=
self
.
bundle
.
tell
()
return
m
@util.propertycache
...
...
@@ -225,5 +224,5 @@
def
file
(
self
,
f
):
if
not
self
.
bundlefilespos
:
self
.
bundle
file
.
seek
(
self
.
filestart
)
self
.
bundle
.
seek
(
self
.
filestart
)
while
1
:
...
...
@@ -229,4 +228,4 @@
while
1
:
chunk
=
changegroup
.
getchunk
(
self
.
bundle
file
)
chunk
=
changegroup
.
getchunk
(
self
.
bundle
)
if
not
chunk
:
break
...
...
@@ -231,9 +230,9 @@
if
not
chunk
:
break
self
.
bundlefilespos
[
chunk
]
=
self
.
bundle
file
.
tell
()
for
c
in
changegroup
.
chunkiter
(
self
.
bundle
file
):
self
.
bundlefilespos
[
chunk
]
=
self
.
bundle
.
tell
()
for
c
in
changegroup
.
chunkiter
(
self
.
bundle
):
pass
if
f
[
0
]
==
'
/
'
:
f
=
f
[
1
:]
if
f
in
self
.
bundlefilespos
:
...
...
@@ -235,12 +234,12 @@
pass
if
f
[
0
]
==
'
/
'
:
f
=
f
[
1
:]
if
f
in
self
.
bundlefilespos
:
self
.
bundle
file
.
seek
(
self
.
bundlefilespos
[
f
])
return
bundlefilelog
(
self
.
sopener
,
f
,
self
.
bundle
file
,
self
.
bundle
.
seek
(
self
.
bundlefilespos
[
f
])
return
bundlefilelog
(
self
.
sopener
,
f
,
self
.
bundle
,
self
.
changelog
.
rev
)
else
:
return
filelog
.
filelog
(
self
.
sopener
,
f
)
def
__del__
(
self
):
...
...
@@ -242,12 +241,9 @@
self
.
changelog
.
rev
)
else
:
return
filelog
.
filelog
(
self
.
sopener
,
f
)
def
__del__
(
self
):
bundlefile
=
getattr
(
self
,
'
bundlefile
'
,
None
)
if
bundlefile
and
not
bundlefile
.
closed
:
bundlefile
.
close
()
tempfile
=
getattr
(
self
,
'
tempfile
'
,
None
)
del
self
.
bundle
if
tempfile
is
not
None
:
os
.
unlink
(
tempfile
)
if
self
.
_tempparent
:
...
...
This diff is collapsed.
Click to expand it.
mercurial/changegroup.py
+
1
−
1
View file @
680fe77a
...
...
@@ -149,7 +149,7 @@
def
seek
(
self
,
pos
):
return
self
.
_stream
.
seek
(
pos
)
def
tell
(
self
):
return
self
.
_stream
.
tell
(
pos
)
return
self
.
_stream
.
tell
()
class
headerlessfixup
(
object
):
def
__init__
(
self
,
fh
,
h
):
...
...
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