[PATCH 2 of 2 v2] paper, coal: display diffstat on the changeset page

Steven Brown stevengbrown at gmail.com
Sat Jun 11 08:54:17 CDT 2011


# HG changeset patch
# User Steven Brown <StevenGBrown at gmail.com>
# Date 1307798690 -28800
# Node ID 0985c3827521d237e78c5c88fe87f656939edc84
# Parent  002e66bb87d13f1a0af3b7081c7ab8f6397a7a27
paper, coal: display diffstat on the changeset page

Displayed in a row of the changeset summary table, underneath the list of
files. When the page is loaded, only the diff summary is displayed. The full
diffstat is only displayed when the [+] link is selected.

diff --git a/mercurial/templates/paper/changeset.tmpl b/mercurial/templates/paper/changeset.tmpl
--- a/mercurial/templates/paper/changeset.tmpl
+++ b/mercurial/templates/paper/changeset.tmpl
@@ -62,6 +62,18 @@
  <th class="files">files</th>
  <td class="files">{files}</td>
 </tr>
+<tr>
+  <th class="diffstat">diffstat</th>
+  <td class="diffstat">
+    {diffsummary}
+    <a id="diffstatexpand" href="javascript:showDiffstat()"/>[+]</a>
+    <div id="diffstatdetails" style="display:none;">
+      <a href="javascript:hideDiffstat()"/>[-]</a>
+      <p>
+      <table>{diffstat}</table>
+    </div>
+  </td>
+</tr>
 </table>
 
 <div class="overflow">
diff --git a/mercurial/templates/static/mercurial.js b/mercurial/templates/static/mercurial.js
--- a/mercurial/templates/static/mercurial.js
+++ b/mercurial/templates/static/mercurial.js
@@ -2,6 +2,7 @@
 //
 // Rendering of branch DAGs on the client side
 // Display of elapsed time
+// Show or hide diffstat
 //
 // Copyright 2008 Dirkjan Ochtman <dirkjan AT ochtman DOT nl>
 // Copyright 2006 Alexander Schremmer <alex AT alexanderweb DOT de>
@@ -218,3 +219,13 @@
 		}
 	}
 })(document, RegExp, Math, isNaN, Date, false, true)
+
+function showDiffstat() {
+	document.getElementById('diffstatdetails').style.display = 'inline';
+	document.getElementById('diffstatexpand').style.display = 'none';
+}
+
+function hideDiffstat() {
+	document.getElementById('diffstatdetails').style.display = 'none';
+	document.getElementById('diffstatexpand').style.display = 'inline';
+}
diff --git a/tests/test-hgweb-commands.t b/tests/test-hgweb-commands.t
--- a/tests/test-hgweb-commands.t
+++ b/tests/test-hgweb-commands.t
@@ -352,6 +352,35 @@
    <th class="files">files</th>
    <td class="files"><a href="/file/2ef0ac749a14/da/foo">da/foo</a> <a href="/file/2ef0ac749a14/foo">foo</a> </td>
   </tr>
+  <tr>
+    <th class="diffstat">diffstat</th>
+    <td class="diffstat">
+       2 files changed, 2 insertions(+), 0 deletions(-)
+  
+      <a id="diffstatexpand" href="javascript:showDiffstat()"/>[+]</a>
+      <div id="diffstatdetails" style="display:none;">
+        <p>
+        <table>  <tr class="parity0">
+      <td class="diffstat-file"><a href="#l1.1">da/foo</a></td>
+      <td class="diffstat-total" align="right">1</td>
+      <td class="diffstat-graph">
+        <span class="diffstat-add" style="width:100.0%;">&nbsp;</span>
+        <span class="diffstat-remove" style="width:0.0%;">&nbsp;</span>
+      </td>
+    </tr>
+    <tr class="parity1">
+      <td class="diffstat-file"><a href="#l2.1">foo</a></td>
+      <td class="diffstat-total" align="right">1</td>
+      <td class="diffstat-graph">
+        <span class="diffstat-add" style="width:100.0%;">&nbsp;</span>
+        <span class="diffstat-remove" style="width:0.0%;">&nbsp;</span>
+      </td>
+    </tr>
+  </table>
+        <a href="javascript:hideDiffstat()"/>[-]</a>
+      </div>
+    </td>
+  </tr>
   </table>
   
   <div class="overflow">
diff --git a/tests/test-hgweb-diffs.t b/tests/test-hgweb-diffs.t
--- a/tests/test-hgweb-diffs.t
+++ b/tests/test-hgweb-diffs.t
@@ -94,6 +94,35 @@
    <th class="files">files</th>
    <td class="files"><a href="/file/0cd96de13884/a">a</a> <a href="/file/0cd96de13884/b">b</a> </td>
   </tr>
+  <tr>
+    <th class="diffstat">diffstat</th>
+    <td class="diffstat">
+       2 files changed, 2 insertions(+), 0 deletions(-)
+  
+      <a id="diffstatexpand" href="javascript:showDiffstat()"/>[+]</a>
+      <div id="diffstatdetails" style="display:none;">
+        <p>
+        <table>  <tr class="parity0">
+      <td class="diffstat-file"><a href="#l1.1">a</a></td>
+      <td class="diffstat-total" align="right">1</td>
+      <td class="diffstat-graph">
+        <span class="diffstat-add" style="width:100.0%;">&nbsp;</span>
+        <span class="diffstat-remove" style="width:0.0%;">&nbsp;</span>
+      </td>
+    </tr>
+    <tr class="parity1">
+      <td class="diffstat-file"><a href="#l2.1">b</a></td>
+      <td class="diffstat-total" align="right">1</td>
+      <td class="diffstat-graph">
+        <span class="diffstat-add" style="width:100.0%;">&nbsp;</span>
+        <span class="diffstat-remove" style="width:0.0%;">&nbsp;</span>
+      </td>
+    </tr>
+  </table>
+        <a href="javascript:hideDiffstat()"/>[-]</a>
+      </div>
+    </td>
+  </tr>
   </table>
   
   <div class="overflow">
@@ -325,6 +354,35 @@
    <th class="files">files</th>
    <td class="files"><a href="/file/0cd96de13884/a">a</a> <a href="/file/0cd96de13884/b">b</a> </td>
   </tr>
+  <tr>
+    <th class="diffstat">diffstat</th>
+    <td class="diffstat">
+       2 files changed, 2 insertions(+), 0 deletions(-)
+  
+      <a id="diffstatexpand" href="javascript:showDiffstat()"/>[+]</a>
+      <div id="diffstatdetails" style="display:none;">
+        <p>
+        <table>  <tr class="parity0">
+      <td class="diffstat-file"><a href="#l1.1">a</a></td>
+      <td class="diffstat-total" align="right">1</td>
+      <td class="diffstat-graph">
+        <span class="diffstat-add" style="width:100.0%;">&nbsp;</span>
+        <span class="diffstat-remove" style="width:0.0%;">&nbsp;</span>
+      </td>
+    </tr>
+    <tr class="parity1">
+      <td class="diffstat-file"><a href="#l2.1">b</a></td>
+      <td class="diffstat-total" align="right">1</td>
+      <td class="diffstat-graph">
+        <span class="diffstat-add" style="width:100.0%;">&nbsp;</span>
+        <span class="diffstat-remove" style="width:0.0%;">&nbsp;</span>
+      </td>
+    </tr>
+  </table>
+        <a href="javascript:hideDiffstat()"/>[-]</a>
+      </div>
+    </td>
+  </tr>
   </table>
   
   <div class="overflow">
diff --git a/tests/test-hgweb-removed.t b/tests/test-hgweb-removed.t
--- a/tests/test-hgweb-removed.t
+++ b/tests/test-hgweb-removed.t
@@ -89,6 +89,27 @@
    <th class="files">files</th>
    <td class="files">a </td>
   </tr>
+  <tr>
+    <th class="diffstat">diffstat</th>
+    <td class="diffstat">
+       1 files changed, 0 insertions(+), 1 deletions(-)
+  
+      <a id="diffstatexpand" href="javascript:showDiffstat()"/>[+]</a>
+      <div id="diffstatdetails" style="display:none;">
+        <p>
+        <table>  <tr class="parity0">
+      <td class="diffstat-file"><a href="#l1.1">a</a></td>
+      <td class="diffstat-total" align="right">1</td>
+      <td class="diffstat-graph">
+        <span class="diffstat-add" style="width:0.0%;">&nbsp;</span>
+        <span class="diffstat-remove" style="width:100.0%;">&nbsp;</span>
+      </td>
+    </tr>
+  </table>
+        <a href="javascript:hideDiffstat()"/>[-]</a>
+      </div>
+    </td>
+  </tr>
   </table>
   
   <div class="overflow">


More information about the Mercurial-devel mailing list