diff --git a/mercurial/hgweb/webcommands.py b/mercurial/hgweb/webcommands.py
index 3ac1735a2265a1f0d0f5ea47a5e428e09c8b581d_bWVyY3VyaWFsL2hnd2ViL3dlYmNvbW1hbmRzLnB5..81318ca090a2d5e66942b60ed28b33450bfc881a_bWVyY3VyaWFsL2hnd2ViL3dlYmNvbW1hbmRzLnB5 100644
--- a/mercurial/hgweb/webcommands.py
+++ b/mercurial/hgweb/webcommands.py
@@ -204,7 +204,7 @@
         if pos != -1:
             revs = web.repo.changelog.revs(pos, 0)
         if latestonly:
-            revs = (next(revs),)
+            revs = (revs.next(),)
         curcount = 0
         for i in revs:
             ctx = web.repo[i]