comparison mercurial/bundlerepo.py @ 4266:1b5c38e9d7aa

revlog: don't pass datafile as an argument
author Matt Mackall <mpm@selenic.com>
date Thu, 22 Mar 2007 19:12:03 -0500
parents 9210fba03d16
children 63b9d2deed48
comparison
equal deleted inserted replaced
4256:fe0fe0b4d73b 4266:1b5c38e9d7aa
15 import changegroup, util, os, struct, bz2, tempfile 15 import changegroup, util, os, struct, bz2, tempfile
16 16
17 import localrepo, changelog, manifest, filelog, revlog 17 import localrepo, changelog, manifest, filelog, revlog
18 18
19 class bundlerevlog(revlog.revlog): 19 class bundlerevlog(revlog.revlog):
20 def __init__(self, opener, indexfile, datafile, bundlefile, 20 def __init__(self, opener, indexfile, bundlefile,
21 linkmapper=None): 21 linkmapper=None):
22 # How it works: 22 # How it works:
23 # to retrieve a revision, we need to know the offset of 23 # to retrieve a revision, we need to know the offset of
24 # the revision in the bundlefile (an opened file). 24 # the revision in the bundlefile (an opened file).
25 # 25 #
26 # We store this offset in the index (start), to differentiate a 26 # We store this offset in the index (start), to differentiate a
27 # rev in the bundle and from a rev in the revlog, we check 27 # rev in the bundle and from a rev in the revlog, we check
28 # len(index[r]). If the tuple is bigger than 7, it is a bundle 28 # len(index[r]). If the tuple is bigger than 7, it is a bundle
29 # (it is bigger since we store the node to which the delta is) 29 # (it is bigger since we store the node to which the delta is)
30 # 30 #
31 revlog.revlog.__init__(self, opener, indexfile, datafile) 31 revlog.revlog.__init__(self, opener, indexfile)
32 self.bundlefile = bundlefile 32 self.bundlefile = bundlefile
33 self.basemap = {} 33 self.basemap = {}
34 def chunkpositer(): 34 def chunkpositer():
35 for chunk in changegroup.chunkiter(bundlefile): 35 for chunk in changegroup.chunkiter(bundlefile):
36 pos = bundlefile.tell() 36 pos = bundlefile.tell()
138 raise NotImplementedError 138 raise NotImplementedError
139 139
140 class bundlechangelog(bundlerevlog, changelog.changelog): 140 class bundlechangelog(bundlerevlog, changelog.changelog):
141 def __init__(self, opener, bundlefile): 141 def __init__(self, opener, bundlefile):
142 changelog.changelog.__init__(self, opener) 142 changelog.changelog.__init__(self, opener)
143 bundlerevlog.__init__(self, opener, self.indexfile, self.datafile, 143 bundlerevlog.__init__(self, opener, self.indexfile, bundlefile)
144 bundlefile)
145 144
146 class bundlemanifest(bundlerevlog, manifest.manifest): 145 class bundlemanifest(bundlerevlog, manifest.manifest):
147 def __init__(self, opener, bundlefile, linkmapper): 146 def __init__(self, opener, bundlefile, linkmapper):
148 manifest.manifest.__init__(self, opener) 147 manifest.manifest.__init__(self, opener)
149 bundlerevlog.__init__(self, opener, self.indexfile, self.datafile, 148 bundlerevlog.__init__(self, opener, self.indexfile, bundlefile,
150 bundlefile, linkmapper) 149 linkmapper)
151 150
152 class bundlefilelog(bundlerevlog, filelog.filelog): 151 class bundlefilelog(bundlerevlog, filelog.filelog):
153 def __init__(self, opener, path, bundlefile, linkmapper): 152 def __init__(self, opener, path, bundlefile, linkmapper):
154 filelog.filelog.__init__(self, opener, path) 153 filelog.filelog.__init__(self, opener, path)
155 bundlerevlog.__init__(self, opener, self.indexfile, self.datafile, 154 bundlerevlog.__init__(self, opener, self.indexfile, bundlefile,
156 bundlefile, linkmapper) 155 linkmapper)
157 156
158 class bundlerepository(localrepo.localrepository): 157 class bundlerepository(localrepo.localrepository):
159 def __init__(self, ui, path, bundlename): 158 def __init__(self, ui, path, bundlename):
160 localrepo.localrepository.__init__(self, ui, path) 159 localrepo.localrepository.__init__(self, ui, path)
161 160