comparison mercurial/changelog.py @ 43143:037a8759eda1

sidedatacopies: get and store sidedata in the changelogrevision object The object provide a simple way to access changelog entry, we need it to also bear the sidedata value. Since the sidedata are retrieved at the same time as the revision, we can do that without extra cost. Differential Revision: https://phab.mercurial-scm.org/D6951
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Sun, 06 Oct 2019 23:36:51 -0400
parents beed7ce61681
children 4296cc3c4ae1
comparison
equal deleted inserted replaced
43142:beed7ce61681 43143:037a8759eda1
266 """ 266 """
267 267
268 __slots__ = ( 268 __slots__ = (
269 r'_offsets', 269 r'_offsets',
270 r'_text', 270 r'_text',
271 r'_sidedata',
271 ) 272 )
272 273
273 def __new__(cls, text): 274 def __new__(cls, text, sidedata):
274 if not text: 275 if not text:
275 return _changelogrevision(extra=_defaultextra) 276 return _changelogrevision(extra=_defaultextra)
276 277
277 self = super(changelogrevision, cls).__new__(cls) 278 self = super(changelogrevision, cls).__new__(cls)
278 # We could return here and implement the following as an __init__. 279 # We could return here and implement the following as an __init__.
300 else: 301 else:
301 doublenl = text.index(b'\n\n', nl3 + 1) 302 doublenl = text.index(b'\n\n', nl3 + 1)
302 303
303 self._offsets = (nl1, nl2, nl3, doublenl) 304 self._offsets = (nl1, nl2, nl3, doublenl)
304 self._text = text 305 self._text = text
306 self._sidedata = sidedata
305 307
306 return self 308 return self
307 309
308 @property 310 @property
309 def manifest(self): 311 def manifest(self):
611 613
612 Unless you need to access all fields, consider calling 614 Unless you need to access all fields, consider calling
613 ``changelogrevision`` instead, as it is faster for partial object 615 ``changelogrevision`` instead, as it is faster for partial object
614 access. 616 access.
615 """ 617 """
616 c = changelogrevision(self.revision(node)) 618 c = changelogrevision(*self._revisiondata(node))
617 return (c.manifest, c.user, c.date, c.files, c.description, c.extra) 619 return (c.manifest, c.user, c.date, c.files, c.description, c.extra)
618 620
619 def changelogrevision(self, nodeorrev): 621 def changelogrevision(self, nodeorrev):
620 """Obtain a ``changelogrevision`` for a node or revision.""" 622 """Obtain a ``changelogrevision`` for a node or revision."""
621 return changelogrevision(self.revision(nodeorrev)) 623 text, sidedata = self._revisiondata(nodeorrev)
624 return changelogrevision(text, sidedata)
622 625
623 def readfiles(self, node): 626 def readfiles(self, node):
624 """ 627 """
625 short version of read that only returns the files modified by the cset 628 short version of read that only returns the files modified by the cset
626 """ 629 """