[PATCH 4 of 4] changelog: lazy decode user (API)

Gregory Szorc gregory.szorc at gmail.com
Sun Feb 28 12:26:48 EST 2016


They are actually a bit more expensive! I wanted to test the waters around refactoring the parsing logic before I wrote the more complicated patches :)

> On Feb 28, 2016, at 07:58, Martin von Zweigbergk <martinvonz at google.com> wrote:
> 
> How about timestamp+extras? I would think most callers don't need those either. Are they cheaper to decode/parse?
> 
>> On Sat, Feb 27, 2016, 23:27 Gregory Szorc <gregory.szorc at gmail.com> wrote:
>> # HG changeset patch
>> # User Gregory Szorc <gregory.szorc at gmail.com>
>> # Date 1456641258 28800
>> #      Sat Feb 27 22:34:18 2016 -0800
>> # Node ID ee98b780730118e8a8948396507633a0460c154e
>> # Parent  8427442ba08dd8dc324ea9e1fd30f65c89b2b753
>> changelog: lazy decode user (API)
>> 
>> This appears to show a similar speedup as the previous patch.
>> 
>> diff --git a/mercurial/changelog.py b/mercurial/changelog.py
>> --- a/mercurial/changelog.py
>> +++ b/mercurial/changelog.py
>> @@ -332,30 +332,30 @@ class changelog(revlog.revlog):
>>                          : older versions ignore it
>>          files\n\n       : files modified by the cset, no \n or \r allowed
>>          (.*)            : 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)
>> +          - user (binary)
>>            - (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 = text[last + 2:]
>>          l = text[:last].split('\n')
>>          manifest = bin(l[0])
>> -        user = encoding.tolocal(l[1])
>> +        user = 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:
>> diff --git a/mercurial/context.py b/mercurial/context.py
>> --- a/mercurial/context.py
>> +++ b/mercurial/context.py
>> @@ -543,17 +543,17 @@ class changectx(basectx):
>>          return [changectx(repo, p1), changectx(repo, p2)]
>> 
>>      def changeset(self):
>>          return self._changeset
>>      def manifestnode(self):
>>          return self._changeset[0]
>> 
>>      def user(self):
>> -        return self._changeset[1]
>> +        return encoding.tolocal(self._changeset[1])
>>      def date(self):
>>          return self._changeset[2]
>>      def files(self):
>>          return self._changeset[3]
>>      def description(self):
>>          return encoding.tolocal(self._changeset[4])
>>      def branch(self):
>>          return encoding.tolocal(self._changeset[5].get("branch"))
>> _______________________________________________
>> Mercurial-devel mailing list
>> Mercurial-devel at mercurial-scm.org
>> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.mercurial-scm.org/pipermail/mercurial-devel/attachments/20160228/69b9ea65/attachment.html>


More information about the Mercurial-devel mailing list