[PATCH] client: grab the parent revision information from the server in hgclient.log()

Idan Kamara idankk86 at gmail.com
Tue Oct 30 04:57:51 CDT 2012


On Mon, Oct 29, 2012 at 10:48 PM, Alastair Houghton <
alastair at alastairs-place.net> wrote:
>
> # HG changeset patch
> # User Alastair Houghton <alastair at coriolis-systems.com>
> # Date 1351543544 0
> # Node ID 0886df81888d4bf27d5a69f2a41820cf9fbff347
> # Parent  86ff8611a8fad14d4c1dba6d75bc26caaa41e951
> client: grab the parent revision information from the server in
> hgclient.log()

It took me a while to realize that {parents} is trying to be smart
and not always print the parents, which might make sense
for display purposes, but I'm not sure if it's desirable here.

Maybe we should be using {p1/2rev} and {p1/2node}?

>
> Previously in order to walk the revision graph from code, it was necessary
> to call hgclient.parents() for each changeset to obtain the parent
> revision
> number.  This is inefficient as it requires multiple round trips to the
> server; it's much quicker to obtain the parent revision information at the
> same time as the other changeset information, which is what this patch
> does.
>
> I've also updated the docstring for the hgclient.log() method, which was
> in any case out of date, and changed clientctx to use the parent
> information
> from the hgclient.log() method rather than calling hgclient.parents().
>
> diff -r 86ff8611a8fa -r 0886df81888d hglib/client.py
> --- a/hglib/client.py   Mon Oct 15 09:45:43 2012 -0700
> +++ b/hglib/client.py   Mon Oct 29 20:45:44 2012 +0000
> @@ -3,9 +3,23 @@
>
>  from util import cmdbuilder
>
> +class parentinfo(tuple):
> +    def __new__(cls, rev, shortnode=None):
> +        if shortnode is None:
> +            return tuple.__new__(cls, rev)
> +        return tuple.__new__(cls, (rev, shortnode))
> +
> +    @property
> +    def rev(self):
> +        return self[0]
> +
> +    @property
> +    def node(self):
> +        return self[1]
> +
>  class revision(tuple):
> -    def __new__(cls, rev, node, tags, branch, author, desc, date):
> -        return tuple.__new__(cls, (rev, node, tags, branch, author, desc,
> date))
> +    def __new__(cls, rev, node, tags, branch, author, desc, date,
> parents):
> +        return tuple.__new__(cls, (rev, node, tags, branch, author, desc,
> date, parents))
>
>      @property
>      def rev(self):
> @@ -35,6 +49,10 @@
>      def date(self):
>          return self[6]
>
> +    @property
> +    def parents(self):
> +        return self[7]
> +

I'm not sure I like this special 'parent' tuple that is basically
a thin version of revision.

Is there any reason we can't get rid of these tuples altogether
and use changectx everywhere?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://selenic.com/pipermail/mercurial-devel/attachments/20121030/b1aa3051/attachment.html>


More information about the Mercurial-devel mailing list