[PATCH] hgweb: always start log with searched revision

Alexander Plavin me at aplavin.ru
Fri Jul 12 18:42:40 CDT 2013


# HG changeset patch
# User Alexander Plavin <me at 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.

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>test</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>test</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)


More information about the Mercurial-devel mailing list