Show More
@@ -18,8 +18,7 b' import changegroup, util, mdiff, discove' | |||
|
18 | 18 | import localrepo, changelog, manifest, filelog, revlog, error |
|
19 | 19 | |
|
20 | 20 | class bundlerevlog(revlog.revlog): |
|
21 | def __init__(self, opener, indexfile, bundle, | |
|
22 | linkmapper=None): | |
|
21 | def __init__(self, opener, indexfile, bundle, linkmapper): | |
|
23 | 22 | # How it works: |
|
24 | 23 | # to retrieve a revision, we need to know the offset of |
|
25 | 24 | # the revision in the bundle (an unbundle object). |
@@ -32,43 +31,39 b' class bundlerevlog(revlog.revlog):' | |||
|
32 | 31 | revlog.revlog.__init__(self, opener, indexfile) |
|
33 | 32 | self.bundle = bundle |
|
34 | 33 | self.basemap = {} |
|
35 | def chunkpositer(): | |
|
36 | while 1: | |
|
37 | chunk = bundle.chunk() | |
|
38 | if not chunk: | |
|
39 | break | |
|
40 | pos = bundle.tell() | |
|
41 | yield chunk, pos - len(chunk) | |
|
42 | 34 | n = len(self) |
|
43 |
|
|
|
44 | for chunk, start in chunkpositer(): | |
|
45 | size = len(chunk) | |
|
46 |
if |
|
|
47 | raise util.Abort(_("invalid changegroup")) | |
|
48 | start += 80 | |
|
49 | size -= 80 | |
|
50 | node, p1, p2, cs = struct.unpack("20s20s20s20s", chunk[:80]) | |
|
35 | chain = None | |
|
36 | while 1: | |
|
37 | chunkdata = bundle.parsechunk(chain) | |
|
38 | if not chunkdata: | |
|
39 | break | |
|
40 | node = chunkdata['node'] | |
|
41 | p1 = chunkdata['p1'] | |
|
42 | p2 = chunkdata['p2'] | |
|
43 | cs = chunkdata['cs'] | |
|
44 | deltabase = chunkdata['deltabase'] | |
|
45 | delta = chunkdata['delta'] | |
|
46 | ||
|
47 | size = len(delta) | |
|
48 | start = bundle.tell() - size | |
|
49 | ||
|
50 | link = linkmapper(cs) | |
|
51 | 51 | if node in self.nodemap: |
|
52 | prev = node | |
|
52 | # this can happen if two branches make the same change | |
|
53 | chain = node | |
|
53 | 54 | continue |
|
55 | ||
|
54 | 56 | for p in (p1, p2): |
|
55 | 57 | if not p in self.nodemap: |
|
56 | 58 | raise error.LookupError(p, self.indexfile, |
|
57 | 59 | _("unknown parent")) |
|
58 | if linkmapper is None: | |
|
59 | link = n | |
|
60 | else: | |
|
61 | link = linkmapper(cs) | |
|
62 | ||
|
63 | if not prev: | |
|
64 | prev = p1 | |
|
65 | 60 | # start, size, full unc. size, base (unused), link, p1, p2, node |
|
66 | 61 | e = (revlog.offset_type(start, 0), size, -1, -1, link, |
|
67 | 62 | self.rev(p1), self.rev(p2), node) |
|
68 |
self.basemap[n] = |
|
|
63 | self.basemap[n] = deltabase | |
|
69 | 64 | self.index.insert(-1, e) |
|
70 | 65 | self.nodemap[node] = n |
|
71 |
|
|
|
66 | chain = node | |
|
72 | 67 | n += 1 |
|
73 | 68 | |
|
74 | 69 | def inbundle(self, rev): |
@@ -144,7 +139,9 b' class bundlerevlog(revlog.revlog):' | |||
|
144 | 139 | class bundlechangelog(bundlerevlog, changelog.changelog): |
|
145 | 140 | def __init__(self, opener, bundle): |
|
146 | 141 | changelog.changelog.__init__(self, opener) |
|
147 | bundlerevlog.__init__(self, opener, self.indexfile, bundle) | |
|
142 | linkmapper = lambda x: x | |
|
143 | bundlerevlog.__init__(self, opener, self.indexfile, bundle, | |
|
144 | linkmapper) | |
|
148 | 145 | |
|
149 | 146 | class bundlemanifest(bundlerevlog, manifest.manifest): |
|
150 | 147 | def __init__(self, opener, bundle, linkmapper): |
General Comments 0
You need to be logged in to leave comments.
Login now