224 d, self._h = self._h[:n], self._h[n:] |
224 d, self._h = self._h[:n], self._h[n:] |
225 if len(d) < n: |
225 if len(d) < n: |
226 d += readexactly(self._fh, n - len(d)) |
226 d += readexactly(self._fh, n - len(d)) |
227 return d |
227 return d |
228 return readexactly(self._fh, n) |
228 return readexactly(self._fh, n) |
229 |
|
230 def readbundle(fh, fname, vfs=None): |
|
231 header = readexactly(fh, 6) |
|
232 |
|
233 if not fname: |
|
234 fname = "stream" |
|
235 if not header.startswith('HG') and header.startswith('\0'): |
|
236 fh = headerlessfixup(fh, header) |
|
237 header = "HG10UN" |
|
238 elif vfs: |
|
239 fname = vfs.join(fname) |
|
240 |
|
241 magic, version, alg = header[0:2], header[2:4], header[4:6] |
|
242 |
|
243 if magic != 'HG': |
|
244 raise util.Abort(_('%s: not a Mercurial bundle') % fname) |
|
245 if version != '10': |
|
246 raise util.Abort(_('%s: unknown bundle version %s') % (fname, version)) |
|
247 return unbundle10(fh, alg) |
|
248 |
229 |
249 class bundle10(object): |
230 class bundle10(object): |
250 deltaheader = _BUNDLE10_DELTA_HEADER |
231 deltaheader = _BUNDLE10_DELTA_HEADER |
251 def __init__(self, repo, bundlecaps=None): |
232 def __init__(self, repo, bundlecaps=None): |
252 """Given a source repo, construct a bundler. |
233 """Given a source repo, construct a bundler. |