Mercurial > hg
comparison mercurial/bundlerepo.py @ 18413:0ccb16f5956a
bundlerepo: drop bundlebase wrapper function for basemap
author | Mads Kiilerich <madski@unity3d.com> |
---|---|
date | Wed, 16 Jan 2013 20:41:41 +0100 |
parents | a928865b4a4f |
children | c448562ad85b |
comparison
equal
deleted
inserted
replaced
18412:a928865b4a4f | 18413:0ccb16f5956a |
---|---|
74 def inbundle(self, rev): | 74 def inbundle(self, rev): |
75 """is rev from the bundle""" | 75 """is rev from the bundle""" |
76 if rev < 0: | 76 if rev < 0: |
77 return False | 77 return False |
78 return rev in self.basemap | 78 return rev in self.basemap |
79 def bundlebase(self, rev): | 79 |
80 return self.basemap[rev] | |
81 def _chunk(self, rev): | 80 def _chunk(self, rev): |
82 # Warning: in case of bundle, the diff is against bundlebase, | 81 # Warning: in case of bundle, the diff is against self.basemap, |
83 # not against rev - 1 | 82 # not against rev - 1 |
84 # XXX: could use some caching | 83 # XXX: could use some caching |
85 if not self.inbundle(rev): | 84 if not self.inbundle(rev): |
86 return revlog.revlog._chunk(self, rev) | 85 return revlog.revlog._chunk(self, rev) |
87 self.bundle.seek(self.start(rev)) | 86 self.bundle.seek(self.start(rev)) |
89 | 88 |
90 def revdiff(self, rev1, rev2): | 89 def revdiff(self, rev1, rev2): |
91 """return or calculate a delta between two revisions""" | 90 """return or calculate a delta between two revisions""" |
92 if self.inbundle(rev1) and self.inbundle(rev2): | 91 if self.inbundle(rev1) and self.inbundle(rev2): |
93 # hot path for bundle | 92 # hot path for bundle |
94 revb = self.rev(self.bundlebase(rev2)) | 93 revb = self.rev(self.basemap[rev2]) |
95 if revb == rev1: | 94 if revb == rev1: |
96 return self._chunk(rev2) | 95 return self._chunk(rev2) |
97 elif not self.inbundle(rev1) and not self.inbundle(rev2): | 96 elif not self.inbundle(rev1) and not self.inbundle(rev2): |
98 return revlog.revlog.revdiff(self, rev1, rev2) | 97 return revlog.revlog.revdiff(self, rev1, rev2) |
99 | 98 |
100 return mdiff.textdiff(self.revision(self.node(rev1)), | 99 return mdiff.textdiff(self.revision(self.node(rev1)), |
101 self.revision(self.node(rev2))) | 100 self.revision(self.node(rev2))) |
102 | 101 |
103 def revision(self, nodeorrev): | 102 def revision(self, nodeorrev): |
104 """return an uncompressed revision of a given node or revision | 103 """return an uncompressed revision of a given node or revision |
105 number. | 104 number. |
106 """ | 105 """ |
121 while self.inbundle(rev): | 120 while self.inbundle(rev): |
122 if self._cache and self._cache[0] == iter_node: | 121 if self._cache and self._cache[0] == iter_node: |
123 text = self._cache[2] | 122 text = self._cache[2] |
124 break | 123 break |
125 chain.append(rev) | 124 chain.append(rev) |
126 iter_node = self.bundlebase(rev) | 125 iter_node = self.basemap[rev] |
127 rev = self.rev(iter_node) | 126 rev = self.rev(iter_node) |
128 if text is None: | 127 if text is None: |
129 text = revlog.revlog.revision(self, iter_node) | 128 text = revlog.revlog.revision(self, iter_node) |
130 | 129 |
131 while chain: | 130 while chain: |