[PATCH 3 of 3 V2 STABLE] hgweb: fix incorrect revisions count in graph (issue3977)

Alexander Plavin me at aplavin.ru
Mon Jul 22 04:54:27 CDT 2013


# HG changeset patch
# User Alexander Plavin <me at aplavin.ru>
# Date 1374323375 -14400
#      Sat Jul 20 16:29:35 2013 +0400
# Node ID 1c938ef530c0373c9ec86f4662ff66a4a401d39a
# Parent  ca4c805ec72ac3bedb7a3e661ea236b7704a97fe
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.

diff -r ca4c805ec72a -r 1c938ef530c0 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
@@ -869,19 +869,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 ca4c805ec72a -r 1c938ef530c0 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


More information about the Mercurial-devel mailing list