23 # To retrieve a revision, we need to know the offset of the revision in |
23 # To retrieve a revision, we need to know the offset of the revision in |
24 # the bundle (an unbundle object). We store this offset in the index |
24 # the bundle (an unbundle object). We store this offset in the index |
25 # (start). |
25 # (start). |
26 # |
26 # |
27 # basemap is indexed with revisions coming from the bundle, and it |
27 # basemap is indexed with revisions coming from the bundle, and it |
28 # maps to the corresponding node that is the base of the corresponding |
28 # maps to the node that is the base of the corresponding delta. |
29 # delta. |
|
30 # |
29 # |
31 # To differentiate a rev in the bundle from a rev in the revlog, we |
30 # To differentiate a rev in the bundle from a rev in the revlog, we |
32 # check revision against basemap. |
31 # check revision against basemap. |
33 opener = scmutil.readonlyvfs(opener) |
32 opener = scmutil.readonlyvfs(opener) |
34 revlog.revlog.__init__(self, opener, indexfile) |
33 revlog.revlog.__init__(self, opener, indexfile) |
35 self.bundle = bundle |
34 self.bundle = bundle |
36 self.basemap = {} |
35 self.basemap = {} |
37 n = len(self) |
36 n = len(self) |
38 self.disktiprev = n - 1 |
37 self.disktiprev = n - 1 |
39 chain = None |
38 chain = None |
40 self.bundlenodes = [] |
39 self.bundlerevs = set() # used by 'bundle()' revset expression |
41 while True: |
40 while True: |
42 chunkdata = bundle.deltachunk(chain) |
41 chunkdata = bundle.deltachunk(chain) |
43 if not chunkdata: |
42 if not chunkdata: |
44 break |
43 break |
45 node = chunkdata['node'] |
44 node = chunkdata['node'] |
51 |
50 |
52 size = len(delta) |
51 size = len(delta) |
53 start = bundle.tell() - size |
52 start = bundle.tell() - size |
54 |
53 |
55 link = linkmapper(cs) |
54 link = linkmapper(cs) |
56 self.bundlenodes.append(node) |
|
57 if node in self.nodemap: |
55 if node in self.nodemap: |
58 # this can happen if two branches make the same change |
56 # this can happen if two branches make the same change |
59 chain = node |
57 chain = node |
|
58 self.bundlerevs.add(self.nodemap[node]) |
60 continue |
59 continue |
61 |
60 |
62 for p in (p1, p2): |
61 for p in (p1, p2): |
63 if p not in self.nodemap: |
62 if p not in self.nodemap: |
64 raise error.LookupError(p, self.indexfile, |
63 raise error.LookupError(p, self.indexfile, |
67 e = (revlog.offset_type(start, 0), size, -1, -1, link, |
66 e = (revlog.offset_type(start, 0), size, -1, -1, link, |
68 self.rev(p1), self.rev(p2), node) |
67 self.rev(p1), self.rev(p2), node) |
69 self.basemap[n] = deltabase |
68 self.basemap[n] = deltabase |
70 self.index.insert(-1, e) |
69 self.index.insert(-1, e) |
71 self.nodemap[node] = n |
70 self.nodemap[node] = n |
|
71 self.bundlerevs.add(n) |
72 chain = node |
72 chain = node |
73 n += 1 |
73 n += 1 |
74 |
74 |
75 def inbundle(self, rev): |
75 def inbundle(self, rev): |
76 """is rev from the bundle""" |
76 """is rev from the bundle""" |