Patchwork [3,of,3] hgweb: fix incorrect revisions count in graph (issue3977)

login
register
mail settings
Submitter Alexander Plavin
Date July 20, 2013, 1:33 p.m.
Message ID <7d261fb5e87c0dd4fda1.1374327180@debian-alexander.dolgopa>
Download mbox | patch
Permalink /patch/1938/
State Superseded
Headers show

Comments

Alexander Plavin - July 20, 2013, 1:33 p.m.
# HG changeset patch
# User Alexander Plavin <me@aplavin.ru>
# Date 1374323375 -14400
#      Sat Jul 20 16:29:35 2013 +0400
# Branch stable
# Node ID 7d261fb5e87c0dd4fda156c33fc92cdfbd7cc483
# Parent  b7abfadc267c6d018b38f424c0d568f99c0009e1
hgweb: fix incorrect revisions count in graph (issue3977)

Actual amount of revisions is used now instead of their numbers in the repo
befor to deal with skipped numbers correctly.
This also automatically makes graph start with the revision specified in
the url, like log after a recent patch.

Patch

diff -r b7abfadc267c -r 7d261fb5e87c mercurial/hgweb/webcommands.py
--- a/mercurial/hgweb/webcommands.py	Sat Jul 20 16:07:52 2013 +0400
+++ b/mercurial/hgweb/webcommands.py	Sat Jul 20 16:29:35 2013 +0400
@@ -920,19 +920,15 @@ 
 
     count = len(web.repo)
     pos = rev
-    start = max(0, pos - revcount + 1)
-    end = min(count, start + revcount)
-    pos = end - 1
 
     uprev = min(max(0, count - 1), rev + revcount)
     downrev = max(0, rev - revcount)
     changenav = webutil.revnav(web.repo).gen(pos, revcount, count)
 
     tree = []
-    if start < end:
-        revs = list(web.repo.changelog.revs(end - 1, start))
-        dag = graphmod.dagwalker(web.repo, revs)
-        tree = list(graphmod.colored(dag, web.repo))
+    revs = list(web.repo.changelog.revs(pos, count=-revcount))
+    dag = graphmod.dagwalker(web.repo, revs)
+    tree = list(graphmod.colored(dag, web.repo))
 
     def getcolumns(tree):
         cols = 0
diff -r b7abfadc267c -r 7d261fb5e87c tests/test-hgweb-commands.t
--- a/tests/test-hgweb-commands.t	Sat Jul 20 16:07:52 2013 +0400
+++ b/tests/test-hgweb-commands.t	Sat Jul 20 16:29:35 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