gitweb: don't show '[up]' in file view when in root directory already
authorAnton Shestakov <av6@dwimlabs.net>
Thu, 31 May 2018 18:33:49 +0800
changeset 38204 d6aa1fc8292f
parent 38203 c2e3bc99fba4
child 38205 9ed3527019b5
gitweb: don't show '[up]' in file view when in root directory already
mercurial/templates/gitweb/manifest.tmpl
mercurial/templates/gitweb/map
tests/test-hgweb-descend-empties.t
tests/test-hgweb-symrev.t
tests/test-hgweb.t
--- a/mercurial/templates/gitweb/manifest.tmpl	Thu May 31 18:01:54 2018 +0800
+++ b/mercurial/templates/gitweb/manifest.tmpl	Thu May 31 18:33:49 2018 +0800
@@ -30,13 +30,7 @@
 
 <div class="title">{path|escape} {alltags}</div>
 <table cellspacing="0">
-<tr class="parity{upparity}">
-<td style="font-family:monospace">drwxr-xr-x</td>
-<td style="font-family:monospace"></td>
-<td style="font-family:monospace"></td>
-<td><a href="{url|urlescape}file/{symrev}{up|urlescape}{sessionvars%urlparameter}">[up]</a></td>
-<td class="link">&nbsp;</td>
-</tr>
+{ifeq(path, up, '', updirentry)}
 {dentries%direntry}
 {fentries%fileentry}
 </table>
--- a/mercurial/templates/gitweb/map	Thu May 31 18:01:54 2018 +0800
+++ b/mercurial/templates/gitweb/map	Thu May 31 18:33:49 2018 +0800
@@ -59,6 +59,16 @@
 changelogentry = changelogentry.tmpl
 changeset = changeset.tmpl
 manifest = manifest.tmpl
+updirentry = '
+  <tr class="parity{upparity}">
+    <td style="font-family:monospace">drwxr-xr-x</td>
+    <td style="font-family:monospace"></td>
+    <td style="font-family:monospace"></td>
+    <td>
+      <a href="{url|urlescape}file/{symrev}{up|urlescape}{sessionvars%urlparameter}">[up]</a>
+    </td>
+    <td class="link">&nbsp;</td>
+  </tr>'
 direntry = '
   <tr class="parity{parity}">
     <td style="font-family:monospace">drwxr-xr-x</td>
--- a/tests/test-hgweb-descend-empties.t	Thu May 31 18:01:54 2018 +0800
+++ b/tests/test-hgweb-descend-empties.t	Thu May 31 18:33:49 2018 +0800
@@ -425,13 +425,7 @@
   
   <div class="title">/ <span class="logtags"><span class="phasetag" title="draft">draft</span> <span class="branchtag" title="default">default</span> <span class="tagtag" title="tip">tip</span> </span></div>
   <table cellspacing="0">
-  <tr class="parity0">
-  <td style="font-family:monospace">drwxr-xr-x</td>
-  <td style="font-family:monospace"></td>
-  <td style="font-family:monospace"></td>
-  <td><a href="/file/tip/?style=gitweb">[up]</a></td>
-  <td class="link">&nbsp;</td>
-  </tr>
+  
   
   <tr class="parity1">
   <td style="font-family:monospace">drwxr-xr-x</td>
--- a/tests/test-hgweb-symrev.t	Thu May 31 18:01:54 2018 +0800
+++ b/tests/test-hgweb-symrev.t	Thu May 31 18:33:49 2018 +0800
@@ -516,7 +516,6 @@
 
   $ "$TESTDIR/get-with-headers.py" $LOCALIP:$HGPORT 'file?style=gitweb' | egrep $REVLINKS
   <a href="/rev/tip?style=gitweb">changeset</a>  | <a href="/archive/tip.zip">zip</a>  |
-  <td><a href="/file/tip/?style=gitweb">[up]</a></td>
   <a href="/file/tip/dir?style=gitweb">dir</a>
   <a href="/file/tip/dir/?style=gitweb"></a>
   <a href="/file/tip/dir?style=gitweb">files</a>
@@ -590,7 +589,6 @@
 
   $ "$TESTDIR/get-with-headers.py" $LOCALIP:$HGPORT 'file/xyzzy?style=gitweb' | egrep $REVLINKS
   <a href="/rev/xyzzy?style=gitweb">changeset</a>  | <a href="/archive/xyzzy.zip">zip</a>  |
-  <td><a href="/file/xyzzy/?style=gitweb">[up]</a></td>
   <a href="/file/xyzzy/dir?style=gitweb">dir</a>
   <a href="/file/xyzzy/dir/?style=gitweb"></a>
   <a href="/file/xyzzy/dir?style=gitweb">files</a>
--- a/tests/test-hgweb.t	Thu May 31 18:01:54 2018 +0800
+++ b/tests/test-hgweb.t	Thu May 31 18:33:49 2018 +0800
@@ -808,6 +808,10 @@
   [1]
   $ get-with-headers.py localhost:$HGPORT 'file/tip/da?style=coal' | grep -F '[up]'
   <a href="/file/tip/?style=coal">[up]</a>
+  $ get-with-headers.py localhost:$HGPORT 'file/tip?style=gitweb' | grep -F '[up]'
+  [1]
+  $ get-with-headers.py localhost:$HGPORT 'file/tip/da?style=gitweb' | grep -F '[up]'
+  <a href="/file/tip/?style=gitweb">[up]</a>
 
 no style can be loaded from directories other than the specified paths