# HG changeset patch # User Gregory Szorc # Date 2016-02-28 06:25:14 # Node ID 1778770e198244405bdb5f435e9b4186ccbc6adc # Parent f5ae291dfedf8627efd1782dba3e724eee1b5f09 changelog: lazy decode description (API) Currently, changelog reading decodes read values. This is wasteful because a lot of times consumers aren't interested in some of these values. This patch changes description decoding to occur in changectx as needed. revsets reading changelog entries appear to speed up slightly: revset #7: author(lmoscovicz) plain 0) 0.906329 1) 0.872653 revset #8: author(mpm) plain 0) 0.903478 1) 0.878037 revset #9: author(lmoscovicz) or author(mpm) plain 0) 1.817855 1) 1.778680 revset #10: author(mpm) or author(lmoscovicz) plain 0) 1.837052 1) 1.764568 diff --git a/mercurial/changelog.py b/mercurial/changelog.py --- a/mercurial/changelog.py +++ b/mercurial/changelog.py @@ -334,12 +334,20 @@ class changelog(revlog.revlog): (.*) : comment (free text, ideally utf-8) changelog v0 doesn't use extra + + Returns a 6-tuple consisting of the following: + - manifest node (binary) + - user (encoding.localstr) + - (time, timezone) 2-tuple of a float and int offset + - list of files modified by the cset + - commit message / description (binary) + - dict of extra entries """ text = self.revision(node) if not text: return nullid, "", (0, 0), [], "", _defaultextra last = text.index("\n\n") - desc = encoding.tolocal(text[last + 2:]) + desc = text[last + 2:] l = text[:last].split('\n') manifest = bin(l[0]) user = encoding.tolocal(l[1]) diff --git a/mercurial/context.py b/mercurial/context.py --- a/mercurial/context.py +++ b/mercurial/context.py @@ -554,7 +554,7 @@ class changectx(basectx): def files(self): return self._changeset[3] def description(self): - return self._changeset[4] + return encoding.tolocal(self._changeset[4]) def branch(self): return encoding.tolocal(self._changeset[5].get("branch")) def closesbranch(self):