# HG changeset patch # User Gregory Szorc # Date 2016-03-06 22:31:06 # Node ID 7796473c11b3b0c132bea567a4660626cb57fdb2 # Parent 837f1c437d5832e8efe4b7211a7ea96d1cf3e047 changelog: lazily parse files More of the same. Again, modest revset performance wins: author(mpm) 0.896565 0.822961 0.805156 desc(bug) 0.887169 0.847054 0.798101 date(2015) 0.878797 0.811613 0.786689 extra(rebase_source) 0.865446 0.797756 0.777408 author(mpm) or author(greg) 1.801832 1.668172 1.626547 author(mpm) or desc(bug) 1.812438 1.677608 1.613941 date(2015) or branch(default) 0.968276 0.896032 0.869017 diff --git a/mercurial/changelog.py b/mercurial/changelog.py --- a/mercurial/changelog.py +++ b/mercurial/changelog.py @@ -153,7 +153,7 @@ class changelogrevision(object): __slots__ = ( '_rawdateextra', '_rawdesc', - 'files', + '_rawfiles', '_rawmanifest', '_rawuser', ) @@ -196,8 +196,12 @@ class changelogrevision(object): nl3 = text.index('\n', nl2 + 1) self._rawdateextra = text[nl2 + 1:nl3] - l = text[:doublenl].split('\n') - self.files = l[3:] + # The list of files may be empty. Which means nl3 is the first of the + # double newline that precedes the description. + if nl3 == doublenl: + self._rawfiles = None + else: + self._rawfiles = text[nl3 + 1:doublenl] return self @@ -242,6 +246,13 @@ class changelogrevision(object): return decodeextra(raw) @property + def files(self): + if self._rawfiles is None: + return [] + + return self._rawfiles.split('\n') + + @property def description(self): return encoding.tolocal(self._rawdesc)