Patchwork [1,of,3] hgweb: always start graph with the revision in url

login
register
mail settings
Submitter Alexander Plavin
Date July 24, 2013, 10:55 p.m.
Message ID <b5afebbaa5bfd232686c.1374706548@debian-alexander.dolgopa>
Download mbox | patch
Permalink /patch/1952/
State Accepted
Commit 02c71f96eb6c7af66131c9a17973b64d2dfa8a5b
Headers show

Comments

Alexander Plavin - July 24, 2013, 10:55 p.m.
# HG changeset patch
# User Alexander Plavin <me@aplavin.ru>
# Date 1374706101 -14400
#      Thu Jul 25 02:48:21 2013 +0400
# Branch stable
# Node ID b5afebbaa5bfd232686c7acac08978a2a5a67dba
# Parent  11685a5a200c4ae5e5b98fa9af036a7b4a676b83
hgweb: always start graph with the revision in url

It is the same fix for graph command, as was recently for log. This makes the
specified revision be always on top of the graph view.
Before the patch, for example with repo having revisions 0, 1, 2, 3 and revision
in url being '2', all revisions were shown and the specified one wasn't
the first.

Patch

diff -r 11685a5a200c -r b5afebbaa5bf mercurial/hgweb/webcommands.py
--- a/mercurial/hgweb/webcommands.py	Sun Jul 21 18:50:54 2013 +0400
+++ b/mercurial/hgweb/webcommands.py	Thu Jul 25 02:48:21 2013 +0400
@@ -879,8 +879,7 @@ 
     count = len(web.repo)
     pos = rev
     start = max(0, pos - revcount + 1)
-    end = min(count, start + revcount)
-    pos = end - 1
+    end = pos + 1
 
     uprev = min(max(0, count - 1), rev + revcount)
     downrev = max(0, rev - revcount)
diff -r 11685a5a200c -r b5afebbaa5bf tests/test-hgweb-commands.t
--- a/tests/test-hgweb-commands.t	Sun Jul 21 18:50:54 2013 +0400
+++ b/tests/test-hgweb-commands.t	Thu Jul 25 02:48:21 2013 +0400
@@ -1324,14 +1324,11 @@ 
 
   $ "$TESTDIR/get-with-headers.py" 127.0.0.1:$HGPORT \
   >   'graph/e06180cbfb0?style=raw&revcount=3' | grep changeset
-  changeset:   ab4f1438558b
   changeset:   e06180cbfb0c
   changeset:   b4e73ffab476
 
   $ "$TESTDIR/get-with-headers.py" 127.0.0.1:$HGPORT \
   >   'graph/b4e73ffab47?style=raw&revcount=3' | grep changeset
-  changeset:   ab4f1438558b
-  changeset:   e06180cbfb0c
   changeset:   b4e73ffab476
 
   $ cat errors.log