[PATCH 05 of 10 lazy-changelog-parse] changelog: lazily parse user
Gregory Szorc
gregory.szorc at gmail.com
Sun Mar 6 18:58:51 EST 2016
# HG changeset patch
# User Gregory Szorc <gregory.szorc at gmail.com>
# Date 1457303386 28800
# Sun Mar 06 14:29:46 2016 -0800
# Node ID 5850dab8a22608aff069198e4d9e0157bbad6828
# Parent a42fc3233c0886129c9e71b201f9f01880bf9e75
changelog: lazily parse user
Same strategy as before.
Revsets not accessing the user demonstrate a slight performance win:
desc(bug)
0.887169
0.910400
0.895514
date(2015)
0.878797
0.870697
0.820987
extra(rebase_source)
0.865446
0.841644
0.823811
date(2015) or branch(default)
0.968276
0.945792
0.910981
diff --git a/mercurial/changelog.py b/mercurial/changelog.py
--- a/mercurial/changelog.py
+++ b/mercurial/changelog.py
@@ -151,17 +151,17 @@ class changelogrevision(object):
"""
__slots__ = (
'date',
'_rawdesc',
'extra',
'files',
'_rawmanifest',
- 'user',
+ '_rawuser',
)
def __new__(cls, text):
if not text:
return _changelogrevision(
manifest=nullid,
user='',
date=(0, 0),
@@ -186,18 +186,20 @@ class changelogrevision(object):
# changelog v0 doesn't use extra
doublenl = text.index('\n\n')
self._rawdesc = text[doublenl + 2:]
nl1 = text.index('\n')
self._rawmanifest = text[0:nl1]
+ nl2 = text.index('\n', nl1 + 1)
+ self._rawuser = text[nl1 + 1:nl2]
+
l = text[:doublenl].split('\n')
- self.user = encoding.tolocal(l[1])
tdata = l[2].split(' ', 2)
if len(tdata) != 3:
time = float(tdata[0])
try:
# various tools did silly things with the time zone field.
timezone = int(tdata[1])
except ValueError:
@@ -212,16 +214,20 @@ class changelogrevision(object):
return self
@property
def manifest(self):
return bin(self._rawmanifest)
@property
+ def user(self):
+ return encoding.tolocal(self._rawuser)
+
+ @property
def description(self):
return encoding.tolocal(self._rawdesc)
class changelog(revlog.revlog):
def __init__(self, opener):
revlog.revlog.__init__(self, opener, "00changelog.i")
if self._initempty:
# changelogs don't benefit from generaldelta
More information about the Mercurial-devel
mailing list