comparison mercurial/bundlerepo.py @ 18414:c448562ad85b

bundlerepo: inline inbundle() It didn't make it faster, it didn't make the code smaller, it didn't make the code simpler. -1 is never in basemap.
author Mads Kiilerich <madski@unity3d.com>
date Wed, 16 Jan 2013 20:41:41 +0100
parents 0ccb16f5956a
children 95b8629fd2de
comparison
equal deleted inserted replaced
18413:0ccb16f5956a 18414:c448562ad85b
69 self.nodemap[node] = n 69 self.nodemap[node] = n
70 self.bundlerevs.add(n) 70 self.bundlerevs.add(n)
71 chain = node 71 chain = node
72 n += 1 72 n += 1
73 73
74 def inbundle(self, rev):
75 """is rev from the bundle"""
76 if rev < 0:
77 return False
78 return rev in self.basemap
79
80 def _chunk(self, rev): 74 def _chunk(self, rev):
81 # Warning: in case of bundle, the diff is against self.basemap, 75 # Warning: in case of bundle, the diff is against self.basemap,
82 # not against rev - 1 76 # not against rev - 1
83 # XXX: could use some caching 77 # XXX: could use some caching
84 if not self.inbundle(rev): 78 if rev not in self.basemap:
85 return revlog.revlog._chunk(self, rev) 79 return revlog.revlog._chunk(self, rev)
86 self.bundle.seek(self.start(rev)) 80 self.bundle.seek(self.start(rev))
87 return self.bundle.read(self.length(rev)) 81 return self.bundle.read(self.length(rev))
88 82
89 def revdiff(self, rev1, rev2): 83 def revdiff(self, rev1, rev2):
90 """return or calculate a delta between two revisions""" 84 """return or calculate a delta between two revisions"""
91 if self.inbundle(rev1) and self.inbundle(rev2): 85 if rev1 in self.basemap and rev2 in self.basemap:
92 # hot path for bundle 86 # hot path for bundle
93 revb = self.rev(self.basemap[rev2]) 87 revb = self.rev(self.basemap[rev2])
94 if revb == rev1: 88 if revb == rev1:
95 return self._chunk(rev2) 89 return self._chunk(rev2)
96 elif not self.inbundle(rev1) and not self.inbundle(rev2): 90 elif rev1 not in self.basemap and rev2 not in self.basemap:
97 return revlog.revlog.revdiff(self, rev1, rev2) 91 return revlog.revlog.revdiff(self, rev1, rev2)
98 92
99 return mdiff.textdiff(self.revision(self.node(rev1)), 93 return mdiff.textdiff(self.revision(self.node(rev1)),
100 self.revision(self.node(rev2))) 94 self.revision(self.node(rev2)))
101 95
115 109
116 text = None 110 text = None
117 chain = [] 111 chain = []
118 iter_node = node 112 iter_node = node
119 # reconstruct the revision if it is from a changegroup 113 # reconstruct the revision if it is from a changegroup
120 while self.inbundle(rev): 114 while rev in self.basemap:
121 if self._cache and self._cache[0] == iter_node: 115 if self._cache and self._cache[0] == iter_node:
122 text = self._cache[2] 116 text = self._cache[2]
123 break 117 break
124 chain.append(rev) 118 chain.append(rev)
125 iter_node = self.basemap[rev] 119 iter_node = self.basemap[rev]