changeset 35220:dc623009e0b0

gitweb: render changesets server-side on /graph page
author Anton Shestakov <av6@dwimlabs.net>
date Mon, 04 Dec 2017 17:43:45 +0800
parents 5857eb81c1f3
children 75f9f366e5cc
files contrib/wix/templates.wxs mercurial/templates/gitweb/graph.tmpl mercurial/templates/gitweb/graphentry.tmpl mercurial/templates/gitweb/map tests/test-hgweb-commands.t tests/test-hgweb-symrev.t
diffstat 6 files changed, 52 insertions(+), 62 deletions(-) [+]
line wrap: on
line diff
--- a/contrib/wix/templates.wxs	Mon Dec 04 16:21:15 2017 +0800
+++ b/contrib/wix/templates.wxs	Mon Dec 04 17:43:45 2017 +0800
@@ -85,6 +85,7 @@
             <File Id="gitweb.filerevision.tmpl"   Name="filerevision.tmpl" />
             <File Id="gitweb.footer.tmpl"         Name="footer.tmpl" />
             <File Id="gitweb.graph.tmpl"          Name="graph.tmpl" />
+            <File Id="gitweb.graphentry.tmpl"     Name="graphentry.tmpl" />
             <File Id="gitweb.header.tmpl"         Name="header.tmpl" />
             <File Id="gitweb.index.tmpl"          Name="index.tmpl" />
             <File Id="gitweb.manifest.tmpl"       Name="manifest.tmpl" />
--- a/mercurial/templates/gitweb/graph.tmpl	Mon Dec 04 16:21:15 2017 +0800
+++ b/mercurial/templates/gitweb/graph.tmpl	Mon Dec 04 17:43:45 2017 +0800
@@ -39,7 +39,7 @@
 <div id="wrapper">
 <ul id="nodebgs"></ul>
 <canvas id="graph" width="{canvaswidth}" height="{canvasheight}"></canvas>
-<ul id="graphnodes"></ul>
+<ul id="graphnodes">{nodes%graphentry}</ul>
 </div>
 
 <script{if(nonce, ' nonce="{nonce}"')}>
@@ -58,39 +58,13 @@
 	
 	var bg = '<li class="bg parity' + parity + '"></li>';
 	var left = (this.bg_height - this.box_size) + (this.columns + 1) * this.box_size;
-	var nstyle = 'padding-left: ' + left + 'px;';
 	
-	var tagspan = '';
-	if (cur[7].length || cur[8].length || (cur[6][0] != 'default' || cur[6][1])) \{
-		tagspan = '<span class="logtags">';
-		if (cur[6][1]) \{
-			tagspan += '<span class="branchtag" title="' + cur[6][0] + '">';
-			tagspan += cur[6][0] + '</span> ';
-		} else if (!cur[6][1] && cur[6][0] != 'default') \{
-			tagspan += '<span class="inbranchtag" title="' + cur[6][0] + '">';
-			tagspan += cur[6][0] + '</span> ';
-		}
-		if (cur[7].length) \{
-			for (var t in cur[7]) \{
-				var tag = cur[7][t];
-				tagspan += '<span class="tagtag">' + tag + '</span> ';
-			}
-		}
-		if (cur[8].length) \{
-			for (var t in cur[8]) \{
-				var bookmark = cur[8][t];
-				tagspan += '<span class="bookmarktag">' + bookmark + '</span> ';
-			}
-		}
-		tagspan += '</span>';
+	var item = document.querySelector('[data-node="' + cur.node + '"]');
+	if (item) \{
+		item.style.paddingLeft = left + 'px';
 	}
 	
-	var item = '<li style="' + nstyle + '"><span class="desc">';
-	item += '<a class="list" href="{url|urlescape}rev/' + cur[0] + '{sessionvars%urlparameter}" title="' + cur[0] + '"><b>' + cur[3] + '</b></a>';
-	item += '</span> ' + tagspan + '';
-	item += '<span class="info">' + cur[5] + ', by ' + cur[4] + '</span></li>';
-
-	return [bg, item];
+	return [bg, ''];
 	
 }
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mercurial/templates/gitweb/graphentry.tmpl	Mon Dec 04 17:43:45 2017 +0800
@@ -0,0 +1,7 @@
+<li data-node="{node|short}">
+ <span class="desc">
+  <a class="list" href="{url|urlescape}rev/{node|short}{sessionvars%urlparameter}"><b>{desc|strip|firstline|escape|nonempty}</b></a>
+ </span>
+ {alltags}
+ <span class="info">{date|age}, by {author|person}</span>
+</li>
--- a/mercurial/templates/gitweb/map	Mon Dec 04 16:21:15 2017 +0800
+++ b/mercurial/templates/gitweb/map	Mon Dec 04 17:43:45 2017 +0800
@@ -262,6 +262,7 @@
   </tr>'
 shortlog = shortlog.tmpl
 graph = graph.tmpl
+graphentry = graphentry.tmpl
 phasetag = '{ifeq(phase, 'public', '', '<span class="phasetag" title="{phase|escape}">{phase|escape}</span> ')}'
 obsoletetag = '{if(obsolete, '<span class="obsoletetag" title="obsolete">obsolete</span> ')}'
 instabilitytag = '<span class="instabilitytag" title="{instability|escape}">{instability|escape}</span> '
--- a/tests/test-hgweb-commands.t	Mon Dec 04 16:21:15 2017 +0800
+++ b/tests/test-hgweb-commands.t	Mon Dec 04 17:43:45 2017 +0800
@@ -1782,7 +1782,35 @@
   <div id="wrapper">
   <ul id="nodebgs"></ul>
   <canvas id="graph" width="39" height="168"></canvas>
-  <ul id="graphnodes"></ul>
+  <ul id="graphnodes"><li data-node="cad8025a2e87">
+   <span class="desc">
+    <a class="list" href="/rev/cad8025a2e87?style=gitweb"><b>branch commit with null character: </b></a>
+   </span>
+   <span class="logtags"><span class="phasetag" title="draft">draft</span> <span class="branchtag" title="unstable">unstable</span> <span class="tagtag" title="tip">tip</span> <span class="bookmarktag" title="something">something</span> </span>
+   <span class="info">1970-01-01, by test</span>
+  </li>
+  <li data-node="1d22e65f027e">
+   <span class="desc">
+    <a class="list" href="/rev/1d22e65f027e?style=gitweb"><b>branch</b></a>
+   </span>
+   <span class="logtags"><span class="phasetag" title="draft">draft</span> <span class="branchtag" title="stable">stable</span> </span>
+   <span class="info">1970-01-01, by test</span>
+  </li>
+  <li data-node="a4f92ed23982">
+   <span class="desc">
+    <a class="list" href="/rev/a4f92ed23982?style=gitweb"><b>Added tag 1.0 for changeset 2ef0ac749a14</b></a>
+   </span>
+   <span class="logtags"><span class="phasetag" title="draft">draft</span> <span class="branchtag" title="default">default</span> </span>
+   <span class="info">1970-01-01, by test</span>
+  </li>
+  <li data-node="2ef0ac749a14">
+   <span class="desc">
+    <a class="list" href="/rev/2ef0ac749a14?style=gitweb"><b>base</b></a>
+   </span>
+   <span class="logtags"><span class="phasetag" title="draft">draft</span> <span class="tagtag" title="1.0">1.0</span> <span class="bookmarktag" title="anotherthing">anotherthing</span> </span>
+   <span class="info">1970-01-01, by test</span>
+  </li>
+  </ul>
   </div>
   
   <script>
@@ -1801,39 +1829,13 @@
   	
   	var bg = '<li class="bg parity' + parity + '"></li>';
   	var left = (this.bg_height - this.box_size) + (this.columns + 1) * this.box_size;
-  	var nstyle = 'padding-left: ' + left + 'px;';
   	
-  	var tagspan = '';
-  	if (cur[7].length || cur[8].length || (cur[6][0] != 'default' || cur[6][1])) {
-  		tagspan = '<span class="logtags">';
-  		if (cur[6][1]) {
-  			tagspan += '<span class="branchtag" title="' + cur[6][0] + '">';
-  			tagspan += cur[6][0] + '</span> ';
-  		} else if (!cur[6][1] && cur[6][0] != 'default') {
-  			tagspan += '<span class="inbranchtag" title="' + cur[6][0] + '">';
-  			tagspan += cur[6][0] + '</span> ';
-  		}
-  		if (cur[7].length) {
-  			for (var t in cur[7]) {
-  				var tag = cur[7][t];
-  				tagspan += '<span class="tagtag">' + tag + '</span> ';
-  			}
-  		}
-  		if (cur[8].length) {
-  			for (var t in cur[8]) {
-  				var bookmark = cur[8][t];
-  				tagspan += '<span class="bookmarktag">' + bookmark + '</span> ';
-  			}
-  		}
-  		tagspan += '</span>';
+  	var item = document.querySelector('[data-node="' + cur.node + '"]');
+  	if (item) {
+  		item.style.paddingLeft = left + 'px';
   	}
   	
-  	var item = '<li style="' + nstyle + '"><span class="desc">';
-  	item += '<a class="list" href="/rev/' + cur[0] + '?style=gitweb" title="' + cur[0] + '"><b>' + cur[3] + '</b></a>';
-  	item += '</span> ' + tagspan + '';
-  	item += '<span class="info">' + cur[5] + ', by ' + cur[4] + '</span></li>';
-  
-  	return [bg, item];
+  	return [bg, ''];
   	
   }
   
--- a/tests/test-hgweb-symrev.t	Mon Dec 04 16:21:15 2017 +0800
+++ b/tests/test-hgweb-symrev.t	Mon Dec 04 17:43:45 2017 +0800
@@ -493,6 +493,9 @@
   <a href="/graph/tip?revcount=30&style=gitweb">less</a>
   <a href="/graph/tip?revcount=120&style=gitweb">more</a>
   | <a href="/graph/43c799df6e75?style=gitweb">(0)</a> <a href="/graph/tip?style=gitweb">tip</a> 
+    <a class="list" href="/rev/9d8c40cba617?style=gitweb"><b>third</b></a>
+    <a class="list" href="/rev/a7c1559b7bba?style=gitweb"><b>second</b></a>
+    <a class="list" href="/rev/43c799df6e75?style=gitweb"><b>first</b></a>
   <a href="/graph/tip?revcount=30&style=gitweb">less</a>
   <a href="/graph/tip?revcount=120&style=gitweb">more</a>
   | <a href="/graph/43c799df6e75?style=gitweb">(0)</a> <a href="/graph/tip?style=gitweb">tip</a> 
@@ -583,6 +586,8 @@
   <a href="/graph/xyzzy?revcount=30&style=gitweb">less</a>
   <a href="/graph/xyzzy?revcount=120&style=gitweb">more</a>
   | <a href="/graph/43c799df6e75?style=gitweb">(0)</a> <a href="/graph/tip?style=gitweb">tip</a> 
+    <a class="list" href="/rev/a7c1559b7bba?style=gitweb"><b>second</b></a>
+    <a class="list" href="/rev/43c799df6e75?style=gitweb"><b>first</b></a>
   <a href="/graph/xyzzy?revcount=30&style=gitweb">less</a>
   <a href="/graph/xyzzy?revcount=120&style=gitweb">more</a>
   | <a href="/graph/43c799df6e75?style=gitweb">(0)</a> <a href="/graph/tip?style=gitweb">tip</a>