Mercurial > hg
comparison mercurial/changelog.py @ 43230:e51f5d06a99c
sidedatacopies: only read from copies when in this mode
If we know we expect data from sidedata, we read them from sidedata and nothing
else.
This avoid looking into extra for revision without sidedata entries. Such
revision will be introduced in the next changesets.
Differential Revision: https://phab.mercurial-scm.org/D7067
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Wed, 02 Oct 2019 14:16:30 -0400 |
parents | 54e943b28101 |
children | 30570a056fa8 |
comparison
equal
deleted
inserted
replaced
43229:9fa941faef94 | 43230:e51f5d06a99c |
---|---|
213 | 213 |
214 __slots__ = ( | 214 __slots__ = ( |
215 r'_offsets', | 215 r'_offsets', |
216 r'_text', | 216 r'_text', |
217 r'_sidedata', | 217 r'_sidedata', |
218 r'_cpsd', | |
218 ) | 219 ) |
219 | 220 |
220 def __new__(cls, text, sidedata): | 221 def __new__(cls, text, sidedata, cpsd): |
221 if not text: | 222 if not text: |
222 return _changelogrevision(extra=_defaultextra) | 223 return _changelogrevision(extra=_defaultextra) |
223 | 224 |
224 self = super(changelogrevision, cls).__new__(cls) | 225 self = super(changelogrevision, cls).__new__(cls) |
225 # We could return here and implement the following as an __init__. | 226 # We could return here and implement the following as an __init__. |
248 doublenl = text.index(b'\n\n', nl3 + 1) | 249 doublenl = text.index(b'\n\n', nl3 + 1) |
249 | 250 |
250 self._offsets = (nl1, nl2, nl3, doublenl) | 251 self._offsets = (nl1, nl2, nl3, doublenl) |
251 self._text = text | 252 self._text = text |
252 self._sidedata = sidedata | 253 self._sidedata = sidedata |
254 self._cpsd = cpsd | |
253 | 255 |
254 return self | 256 return self |
255 | 257 |
256 @property | 258 @property |
257 def manifest(self): | 259 def manifest(self): |
306 | 308 |
307 return self._text[off[2] + 1 : off[3]].split(b'\n') | 309 return self._text[off[2] + 1 : off[3]].split(b'\n') |
308 | 310 |
309 @property | 311 @property |
310 def filesadded(self): | 312 def filesadded(self): |
311 if sidedatamod.SD_FILESADDED in self._sidedata: | 313 if self._cpsd: |
312 rawindices = self._sidedata.get(sidedatamod.SD_FILESADDED) | 314 rawindices = self._sidedata.get(sidedatamod.SD_FILESADDED) |
315 if not rawindices: | |
316 return [] | |
313 else: | 317 else: |
314 rawindices = self.extra.get(b'filesadded') | 318 rawindices = self.extra.get(b'filesadded') |
315 if rawindices is None: | 319 if rawindices is None: |
316 return None | 320 return None |
317 return copies.decodefileindices(self.files, rawindices) | 321 return copies.decodefileindices(self.files, rawindices) |
318 | 322 |
319 @property | 323 @property |
320 def filesremoved(self): | 324 def filesremoved(self): |
321 if sidedatamod.SD_FILESREMOVED in self._sidedata: | 325 if self._cpsd: |
322 rawindices = self._sidedata.get(sidedatamod.SD_FILESREMOVED) | 326 rawindices = self._sidedata.get(sidedatamod.SD_FILESREMOVED) |
327 if not rawindices: | |
328 return [] | |
323 else: | 329 else: |
324 rawindices = self.extra.get(b'filesremoved') | 330 rawindices = self.extra.get(b'filesremoved') |
325 if rawindices is None: | 331 if rawindices is None: |
326 return None | 332 return None |
327 return copies.decodefileindices(self.files, rawindices) | 333 return copies.decodefileindices(self.files, rawindices) |
328 | 334 |
329 @property | 335 @property |
330 def p1copies(self): | 336 def p1copies(self): |
331 if sidedatamod.SD_P1COPIES in self._sidedata: | 337 if self._cpsd: |
332 rawcopies = self._sidedata.get(sidedatamod.SD_P1COPIES) | 338 rawcopies = self._sidedata.get(sidedatamod.SD_P1COPIES) |
339 if not rawcopies: | |
340 return {} | |
333 else: | 341 else: |
334 rawcopies = self.extra.get(b'p1copies') | 342 rawcopies = self.extra.get(b'p1copies') |
335 if rawcopies is None: | 343 if rawcopies is None: |
336 return None | 344 return None |
337 return copies.decodecopies(self.files, rawcopies) | 345 return copies.decodecopies(self.files, rawcopies) |
338 | 346 |
339 @property | 347 @property |
340 def p2copies(self): | 348 def p2copies(self): |
341 if sidedatamod.SD_P2COPIES in self._sidedata: | 349 if self._cpsd: |
342 rawcopies = self._sidedata.get(sidedatamod.SD_P2COPIES) | 350 rawcopies = self._sidedata.get(sidedatamod.SD_P2COPIES) |
351 if not rawcopies: | |
352 return {} | |
343 else: | 353 else: |
344 rawcopies = self.extra.get(b'p2copies') | 354 rawcopies = self.extra.get(b'p2copies') |
345 if rawcopies is None: | 355 if rawcopies is None: |
346 return None | 356 return None |
347 return copies.decodecopies(self.files, rawcopies) | 357 return copies.decodecopies(self.files, rawcopies) |
579 | 589 |
580 Unless you need to access all fields, consider calling | 590 Unless you need to access all fields, consider calling |
581 ``changelogrevision`` instead, as it is faster for partial object | 591 ``changelogrevision`` instead, as it is faster for partial object |
582 access. | 592 access. |
583 """ | 593 """ |
584 c = changelogrevision(*self._revisiondata(node)) | 594 d, s = self._revisiondata(node) |
595 c = changelogrevision( | |
596 d, s, self._copiesstorage == b'changeset-sidedata' | |
597 ) | |
585 return (c.manifest, c.user, c.date, c.files, c.description, c.extra) | 598 return (c.manifest, c.user, c.date, c.files, c.description, c.extra) |
586 | 599 |
587 def changelogrevision(self, nodeorrev): | 600 def changelogrevision(self, nodeorrev): |
588 """Obtain a ``changelogrevision`` for a node or revision.""" | 601 """Obtain a ``changelogrevision`` for a node or revision.""" |
589 text, sidedata = self._revisiondata(nodeorrev) | 602 text, sidedata = self._revisiondata(nodeorrev) |
590 return changelogrevision(text, sidedata) | 603 return changelogrevision( |
604 text, sidedata, self._copiesstorage == b'changeset-sidedata' | |
605 ) | |
591 | 606 |
592 def readfiles(self, node): | 607 def readfiles(self, node): |
593 """ | 608 """ |
594 short version of read that only returns the files modified by the cset | 609 short version of read that only returns the files modified by the cset |
595 """ | 610 """ |