Patchwork hgweb: always start log with searched revision

login
register
mail settings
Submitter Alexander Plavin
Date July 12, 2013, 11:42 p.m.
Message ID <fab1615db25b28837a9a.1373672560@debian-alexander.dolgopa>
Download mbox | patch
Permalink /patch/1853/
State Accepted
Commit a87d9102f7aff582b04b9ae7c475381b7ca6e8eb
Headers show

Comments

Alexander Plavin - July 12, 2013, 11:42 p.m.
# HG changeset patch
# User Alexander Plavin <me@aplavin.ru>
# Date 1373668589 -14400
#      Sat Jul 13 02:36:29 2013 +0400
# Node ID fab1615db25b28837a9af906566c4d8634f06ff8
# Parent  112ad12761e449b3edaa7bf10caa0b88193ec9fb
hgweb: always start log with searched revision

This makes the specified revision be always on top of the list.
Before the patch, for example with repo having revisions 0, 1, 2, 3 and user
searching for '2', all revisions were shown and the specified one wasn't
the first.
Matt Mackall - July 19, 2013, 4:37 a.m.
On Sat, 2013-07-13 at 03:42 +0400, Alexander Plavin wrote:
> # HG changeset patch
> # User Alexander Plavin <me@aplavin.ru>
> # Date 1373668589 -14400
> #      Sat Jul 13 02:36:29 2013 +0400
> # Node ID fab1615db25b28837a9af906566c4d8634f06ff8
> # Parent  112ad12761e449b3edaa7bf10caa0b88193ec9fb
> hgweb: always start log with searched revision

Queued for default, thanks.

Patch

diff -r 112ad12761e4 -r fab1615db25b mercurial/hgweb/webcommands.py
--- a/mercurial/hgweb/webcommands.py	Fri Jul 12 01:58:48 2013 +0400
+++ b/mercurial/hgweb/webcommands.py	Sat Jul 13 02:36:29 2013 +0400
@@ -245,8 +245,7 @@ 
     count = len(web.repo)
     pos = ctx.rev()
     start = max(0, pos - revcount + 1)
-    end = min(count, start + revcount)
-    pos = end - 1
+    end = pos + 1
     parity = paritygen(web.stripecount, offset=start - end)
 
     changenav = webutil.revnav(web.repo).gen(pos, revcount, count)
diff -r 112ad12761e4 -r fab1615db25b tests/test-hgweb-commands.t
--- a/tests/test-hgweb-commands.t	Fri Jul 12 01:58:48 2013 +0400
+++ b/tests/test-hgweb-commands.t	Sat Jul 13 02:36:29 2013 +0400
@@ -140,38 +140,6 @@ 
    <updated>1970-01-01T00:00:00+00:00</updated>
   
    <entry>
-    <title>branch commit with null character: </title>
-    <id>http://*:$HGPORT/#changeset-cad8025a2e87f88c06259790adfa15acb4080123</id> (glob)
-    <link href="http://*:$HGPORT/rev/cad8025a2e87"/> (glob)
-    <author>
-     <name>test</name>
-     <email>&#116;&#101;&#115;&#116;</email>
-    </author>
-    <updated>1970-01-01T00:00:00+00:00</updated>
-    <published>1970-01-01T00:00:00+00:00</published>
-    <content type="xhtml">
-     <div xmlns="http://www.w3.org/1999/xhtml">
-      <pre xml:space="preserve">branch commit with null character: </pre>
-     </div>
-    </content>
-   </entry>
-   <entry>
-    <title>branch</title>
-    <id>http://*:$HGPORT/#changeset-1d22e65f027e5a0609357e7d8e7508cd2ba5d2fe</id> (glob)
-    <link href="http://*:$HGPORT/rev/1d22e65f027e"/> (glob)
-    <author>
-     <name>test</name>
-     <email>&#116;&#101;&#115;&#116;</email>
-    </author>
-    <updated>1970-01-01T00:00:00+00:00</updated>
-    <published>1970-01-01T00:00:00+00:00</published>
-    <content type="xhtml">
-     <div xmlns="http://www.w3.org/1999/xhtml">
-      <pre xml:space="preserve">branch</pre>
-     </div>
-    </content>
-   </entry>
-   <entry>
     <title>Added tag 1.0 for changeset 2ef0ac749a14</title>
     <id>http://*:$HGPORT/#changeset-a4f92ed23982be056b9852de5dfe873eaac7f0de</id> (glob)
     <link href="http://*:$HGPORT/rev/a4f92ed23982"/> (glob)