Patchwork [STABLE] hgweb: fix navigation label (issue3792)

login
register
mail settings
Submitter Pierre-Yves David
Date Jan. 30, 2013, 4:42 p.m.
Message ID <fa8ea8f63008d377c28c.1359564165@crater1.logilab.fr>
Download mbox | patch
Permalink /patch/764/
State Accepted
Commit 7f769d3a8ad241d689a3011fb21f4b04f84f3712
Delegated to: Kevin Bullock
Headers show

Comments

Pierre-Yves David - Jan. 30, 2013, 4:42 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@logilab.fr>
# Date 1359563537 -3600
# Branch stable
# Node ID fa8ea8f63008d377c28c5dc962b4302fd7f67eb5
# Parent  68eecbaf1bd32a616748331cc9f22d55b1316ce3
hgweb: fix navigation label (issue3792)

Latest refactoring was buggy and used a variable from another loop.
Tests are run on repo too small to cache that.
Mads Kiilerich - Jan. 30, 2013, 5:39 p.m.
On 01/30/2013 05:42 PM, pierre-yves.david@logilab.fr wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@logilab.fr>
> # Date 1359563537 -3600
> # Branch stable
> # Node ID fa8ea8f63008d377c28c5dc962b4302fd7f67eb5
> # Parent  68eecbaf1bd32a616748331cc9f22d55b1316ce3
> hgweb: fix navigation label (issue3792)
>
> Latest refactoring was buggy and used a variable from another loop.
> Tests are run on repo too small to cache that.

Q: So how can we test that?
A: Unit testing?

/Mads

Patch

diff --git a/mercurial/hgweb/webutil.py b/mercurial/hgweb/webutil.py
--- a/mercurial/hgweb/webutil.py
+++ b/mercurial/hgweb/webutil.py
@@ -89,13 +89,13 @@  class revnav(object):
         navafter = []
         for rev in targets:
             if rev not in self._revlog:
                 continue
             if pos < rev < limit:
-                navafter.append(("+%d" % f, self.hex(rev)))
+                navafter.append(("+%d" % abs(rev - pos), self.hex(rev)))
             if 0 < rev < pos:
-                navbefore.append(("-%d" % f, self.hex(rev)))
+                navbefore.append(("-%d" % abs(rev - pos), self.hex(rev)))
 
 
         navafter.append(("tip", "tip"))
 
         data = lambda i: {"label": i[0], "node": i[1]}