##// END OF EJS Templates
bundlerepo: inline inbundle()...
Mads Kiilerich -
r18414:c448562a default
parent child Browse files
Show More
@@ -71,29 +71,23 b' class bundlerevlog(revlog.revlog):'
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)),
@@ -117,7 +111,7 b' class bundlerevlog(revlog.revlog):'
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
General Comments 0
You need to be logged in to leave comments. Login now