Patchwork hgweb: fix unstoppable loading of graph when no more results

login
register
mail settings
Submitter Alexander Plavin
Date Oct. 12, 2013, 7:45 a.m.
Message ID <fba96e7641874a174988.1381563949@debian-alexander.dolgopa>
Download mbox | patch
Permalink /patch/2753/
State Accepted
Commit aebfbb68fe9277803d9f68943bf2e63391bd08c5
Headers show

Comments

Alexander Plavin - Oct. 12, 2013, 7:45 a.m.
# HG changeset patch
# User Alexander Plavin <alexander@plav.in>
# Date 1381562968 -14400
#      Sat Oct 12 11:29:28 2013 +0400
# Node ID fba96e7641874a17498835ce605f62538a519cdf
# Parent  face8173a31e50a744bc879fb24d8618ee0561d6
hgweb: fix unstoppable loading of graph when no more results

When a user reaches the end of repo history with graph view, it (unsuccessfully)
tried to load more entries. This patch disables further loading attempts.
Matt Mackall - Oct. 14, 2013, 11:34 p.m.
On Sat, 2013-10-12 at 11:45 +0400, Alexander Plavin wrote:
> # HG changeset patch
> # User Alexander Plavin <alexander@plav.in>
> # Date 1381562968 -14400
> #      Sat Oct 12 11:29:28 2013 +0400
> # Node ID fba96e7641874a17498835ce605f62538a519cdf
> # Parent  face8173a31e50a744bc879fb24d8618ee0561d6
> hgweb: fix unstoppable loading of graph when no more results

These three are queued for default, thanks.

Patch

diff -r face8173a31e -r fba96e764187 mercurial/templates/static/mercurial.js
--- a/mercurial/templates/static/mercurial.js	Fri Sep 06 13:30:59 2013 +0400
+++ b/mercurial/templates/static/mercurial.js	Sat Oct 12 11:29:28 2013 +0400
@@ -369,8 +369,6 @@ 
                     appendFormatHTML(container, messageFormat, message);
                 },
                 function onsuccess(htmlText) {
-                    nextPageVar = nextPageVarGet(htmlText, nextPageVar);
-
                     if (mode == 'graph') {
                         var addHeight = htmlText.match(/^<canvas id="graph".*height="(\d+)"><\/canvas>$/m)[1];
                         addHeight = parseInt(addHeight);
@@ -378,6 +376,9 @@ 
 
                         var dataStr = htmlText.match(/^\s*var data = (.*);$/m)[1];
                         var data = JSON.parse(dataStr)
+                        if (data.length < nextPageVar) {
+                            nextPageVar = undefined;
+                        }
                         graph.reset();
                         graph.render(data);
                     } else {
@@ -392,6 +393,8 @@ 
                         }
                         process_dates('.' + curClass);
                     }
+
+                    nextPageVar = nextPageVarGet(htmlText, nextPageVar);
                 },
                 function onerror(errorText) {
                     var message = {