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

Augie Fackler raf at durin42.com
Tue Mar 1 18:45:08 UTC 2016


On Sat, Feb 27, 2016 at 11:27:33PM -0800, Gregory Szorc 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)

I like where this is going. Please send more like this.

Queued.

> 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


More information about the Mercurial-devel mailing list