Patchwork [2,of,2,STABLE] templatekw: fix {join(bookmarks, sep)} to always show associated bookmarks

login
register
mail settings
Submitter Yuya Nishihara
Date Feb. 18, 2015, 3:17 p.m.
Message ID <8bbf9cdf40f38454de6d.1424272624@mimosa>
Download mbox | patch
Permalink /patch/7808/
State Accepted
Commit d091f62be5ae5ec541fd17a214ca79abbb4b4f29
Delegated to: Augie Fackler
Headers show

Comments

Yuya Nishihara - Feb. 18, 2015, 3:17 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1424265455 -32400
#      Wed Feb 18 22:17:35 2015 +0900
# Branch stable
# Node ID 8bbf9cdf40f38454de6de510c51da6555b3d4917
# Parent  7cd913864fd52bbd28236db7e47c871dd83f5737
templatekw: fix {join(bookmarks, sep)} to always show associated bookmarks

The default joinfmt, "x.values()[0]", can't be used here because it picks
either 'bookmark' or 'current' randomly.

I got wrong result with PYTHONHASHSEED=1 on my amd64 machine.
Sean Farley - Feb. 18, 2015, 5:46 p.m.
Yuya Nishihara writes:

> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1424265455 -32400
> #      Wed Feb 18 22:17:35 2015 +0900
> # Branch stable
> # Node ID 8bbf9cdf40f38454de6de510c51da6555b3d4917
> # Parent  7cd913864fd52bbd28236db7e47c871dd83f5737
> templatekw: fix {join(bookmarks, sep)} to always show associated bookmarks
>
> The default joinfmt, "x.values()[0]", can't be used here because it picks
> either 'bookmark' or 'current' randomly.
>
> I got wrong result with PYTHONHASHSEED=1 on my amd64 machine.

This series looks good to me.
Augie Fackler - Feb. 19, 2015, 8:22 p.m.
On Wed, Feb 18, 2015 at 09:46:05AM -0800, Sean Farley wrote:
>
> Yuya Nishihara writes:
>
> > # HG changeset patch
> > # User Yuya Nishihara <yuya@tcha.org>
> > # Date 1424265455 -32400
> > #      Wed Feb 18 22:17:35 2015 +0900
> > # Branch stable
> > # Node ID 8bbf9cdf40f38454de6de510c51da6555b3d4917
> > # Parent  7cd913864fd52bbd28236db7e47c871dd83f5737
> > templatekw: fix {join(bookmarks, sep)} to always show associated bookmarks
> >
> > The default joinfmt, "x.values()[0]", can't be used here because it picks
> > either 'bookmark' or 'current' randomly.
> >
> > I got wrong result with PYTHONHASHSEED=1 on my amd64 machine.
>
> This series looks good to me.

I can't reproduce a failure, so I'm not sure if it's right for stable.

> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
Yuya Nishihara - Feb. 20, 2015, 1:21 p.m.
On Thu, 19 Feb 2015 15:22:31 -0500, Augie Fackler wrote:
> On Wed, Feb 18, 2015 at 09:46:05AM -0800, Sean Farley wrote:
> > Yuya Nishihara writes:
> > > # HG changeset patch
> > > # User Yuya Nishihara <yuya@tcha.org>
> > > # Date 1424265455 -32400
> > > #      Wed Feb 18 22:17:35 2015 +0900
> > > # Branch stable
> > > # Node ID 8bbf9cdf40f38454de6de510c51da6555b3d4917
> > > # Parent  7cd913864fd52bbd28236db7e47c871dd83f5737
> > > templatekw: fix {join(bookmarks, sep)} to always show associated bookmarks
> > >
> > > The default joinfmt, "x.values()[0]", can't be used here because it picks
> > > either 'bookmark' or 'current' randomly.
> > >
> > > I got wrong result with PYTHONHASHSEED=1 on my amd64 machine.
> >
> > This series looks good to me.
> 
> I can't reproduce a failure, so I'm not sure if it's right for stable.

It won't happen if hash randomization is off. So it will be no problem in
most cases.

  % python -R -c "print {'bookmark': 'ok', 'current': 'ng'}.values()[0]"

Regards,
Augie Fackler - Feb. 20, 2015, 3:06 p.m.
On Feb 20, 2015 8:24 AM, "Yuya Nishihara" <yuya@tcha.org> wrote:
>
> On Thu, 19 Feb 2015 15:22:31 -0500, Augie Fackler wrote:
> > On Wed, Feb 18, 2015 at 09:46:05AM -0800, Sean Farley wrote:
> > > Yuya Nishihara writes:
> > > > # HG changeset patch
> > > > # User Yuya Nishihara <yuya@tcha.org>
> > > > # Date 1424265455 -32400
> > > > #      Wed Feb 18 22:17:35 2015 +0900
> > > > # Branch stable
> > > > # Node ID 8bbf9cdf40f38454de6de510c51da6555b3d4917
> > > > # Parent  7cd913864fd52bbd28236db7e47c871dd83f5737
> > > > templatekw: fix {join(bookmarks, sep)} to always show associated
bookmarks
> > > >
> > > > The default joinfmt, "x.values()[0]", can't be used here because it
picks
> > > > either 'bookmark' or 'current' randomly.
> > > >
> > > > I got wrong result with PYTHONHASHSEED=1 on my amd64 machine.
> > >
> > > This series looks good to me.
> >
> > I can't reproduce a failure, so I'm not sure if it's right for stable.
>
> It won't happen if hash randomization is off. So it will be no problem in
> most cases.
>
>   % python -R -c "print {'bookmark': 'ok', 'current': 'ng'}.values()[0]"
>
> Regards,

Right, but I specified the hash seed you gave and didn't see a failure.
I'll double check to make sure I didn't typo something.
Matt Mackall - March 2, 2015, 6:42 a.m.
On Fri, 2015-02-20 at 10:06 -0500, Augie Fackler wrote:
> On Feb 20, 2015 8:24 AM, "Yuya Nishihara" <yuya@tcha.org> wrote:
> >
> > On Thu, 19 Feb 2015 15:22:31 -0500, Augie Fackler wrote:
> > > On Wed, Feb 18, 2015 at 09:46:05AM -0800, Sean Farley wrote:
> > > > Yuya Nishihara writes:
> > > > > # HG changeset patch
> > > > > # User Yuya Nishihara <yuya@tcha.org>
> > > > > # Date 1424265455 -32400
> > > > > #      Wed Feb 18 22:17:35 2015 +0900
> > > > > # Branch stable
> > > > > # Node ID 8bbf9cdf40f38454de6de510c51da6555b3d4917
> > > > > # Parent  7cd913864fd52bbd28236db7e47c871dd83f5737
> > > > > templatekw: fix {join(bookmarks, sep)} to always show associated
> bookmarks
> > > > >
> > > > > The default joinfmt, "x.values()[0]", can't be used here because it
> picks
> > > > > either 'bookmark' or 'current' randomly.
> > > > >
> > > > > I got wrong result with PYTHONHASHSEED=1 on my amd64 machine.
> > > >
> > > > This series looks good to me.
> > >
> > > I can't reproduce a failure, so I'm not sure if it's right for stable.
> >
> > It won't happen if hash randomization is off. So it will be no problem in
> > most cases.
> >
> >   % python -R -c "print {'bookmark': 'ok', 'current': 'ng'}.values()[0]"
> >
> > Regards,
> 
> Right, but I specified the hash seed you gave and didn't see a failure.
> I'll double check to make sure I didn't typo something.

Worked for me. These are queued for stable, thanks.

Patch

diff --git a/mercurial/templatekw.py b/mercurial/templatekw.py
--- a/mercurial/templatekw.py
+++ b/mercurial/templatekw.py
@@ -202,7 +202,7 @@  def showbookmarks(**args):
     current = repo._bookmarkcurrent
     c = [{'bookmark': x, 'current': current} for x in bookmarks]
     f = _showlist('bookmark', bookmarks, **args)
-    return _hybrid(f, c)
+    return _hybrid(f, c, lambda x: x['bookmark'])
 
 def showchildren(**args):
     """:children: List of strings. The children of the changeset."""
diff --git a/tests/test-command-template.t b/tests/test-command-template.t
--- a/tests/test-command-template.t
+++ b/tests/test-command-template.t
@@ -2381,6 +2381,11 @@  Test current bookmark templating
   2 
   1 
   0 
+  $ hg book -r1 baz
+  $ hg log --template "{rev} {join(bookmarks, ' ')}\n"
+  2 bar foo
+  1 baz
+  0 
 
 Test stringify on sub expressions