##// END OF EJS Templates
changelog: avoid slicing raw data until needed...
Gregory Szorc -
r28495:70c2f8a9 default
parent child Browse files
Show More
@@ -151,11 +151,8 b' class changelogrevision(object):'
151 151 """
152 152
153 153 __slots__ = (
154 '_rawdateextra',
155 '_rawdesc',
156 '_rawfiles',
157 '_rawmanifest',
158 '_rawuser',
154 '_offsets',
155 '_text',
159 156 )
160 157
161 158 def __new__(cls, text):
@@ -185,41 +182,41 b' class changelogrevision(object):'
185 182 # changelog v0 doesn't use extra
186 183
187 184 nl1 = text.index('\n')
188 self._rawmanifest = text[0:nl1]
189
190 185 nl2 = text.index('\n', nl1 + 1)
191 self._rawuser = text[nl1 + 1:nl2]
192
193 186 nl3 = text.index('\n', nl2 + 1)
194 self._rawdateextra = text[nl2 + 1:nl3]
195 187
196 188 # The list of files may be empty. Which means nl3 is the first of the
197 189 # double newline that precedes the description.
198 190 if text[nl3 + 1] == '\n':
199 self._rawfiles = None
200 self._rawdesc = text[nl3 + 2:]
191 doublenl = nl3
201 192 else:
202 193 doublenl = text.index('\n\n', nl3 + 1)
203 self._rawfiles = text[nl3 + 1:doublenl]
204 self._rawdesc = text[doublenl + 2:]
194
195 self._offsets = (nl1, nl2, nl3, doublenl)
196 self._text = text
205 197
206 198 return self
207 199
208 200 @property
209 201 def manifest(self):
210 return bin(self._rawmanifest)
202 return bin(self._text[0:self._offsets[0]])
211 203
212 204 @property
213 205 def user(self):
214 return encoding.tolocal(self._rawuser)
206 off = self._offsets
207 return encoding.tolocal(self._text[off[0] + 1:off[1]])
215 208
216 209 @property
217 210 def _rawdate(self):
218 return self._rawdateextra.split(' ', 2)[0:2]
211 off = self._offsets
212 dateextra = self._text[off[1] + 1:off[2]]
213 return dateextra.split(' ', 2)[0:2]
219 214
220 215 @property
221 216 def _rawextra(self):
222 fields = self._rawdateextra.split(' ', 2)
217 off = self._offsets
218 dateextra = self._text[off[1] + 1:off[2]]
219 fields = dateextra.split(' ', 2)
223 220 if len(fields) != 3:
224 221 return None
225 222
@@ -247,14 +244,15 b' class changelogrevision(object):'
247 244
248 245 @property
249 246 def files(self):
250 if self._rawfiles is None:
247 off = self._offsets
248 if off[2] == off[3]:
251 249 return []
252 250
253 return self._rawfiles.split('\n')
251 return self._text[off[2] + 1:off[3]].split('\n')
254 252
255 253 @property
256 254 def description(self):
257 return encoding.tolocal(self._rawdesc)
255 return encoding.tolocal(self._text[self._offsets[3] + 2:])
258 256
259 257 class changelog(revlog.revlog):
260 258 def __init__(self, opener):
General Comments 0
You need to be logged in to leave comments. Login now