[PATCH 2 of 5] paper: don't show '[up]' in file view when in root directory already

Anton Shestakov av6 at dwimlabs.net
Thu May 31 09:11:37 EDT 2018


# HG changeset patch
# User Anton Shestakov <av6 at dwimlabs.net>
# Date 1527760914 -28800
#      Thu May 31 18:01:54 2018 +0800
# Node ID 75ffc56c904c74db5f77643de8bfe8c84a31ccbf
# Parent  5763aad1f7b9643c761d82a757ee0504a32b7c41
paper: don't show '[up]' in file view when in root directory already

diff --git a/mercurial/templates/paper/manifest.tmpl b/mercurial/templates/paper/manifest.tmpl
--- a/mercurial/templates/paper/manifest.tmpl
+++ b/mercurial/templates/paper/manifest.tmpl
@@ -46,11 +46,7 @@
 </tr>
 </thead>
 <tbody class="stripes2">
-<tr class="fileline">
-  <td class="name"><a href="{url|urlescape}file/{symrev}{up|urlescape}{sessionvars%urlparameter}">[up]</a></td>
-  <td class="size"></td>
-  <td class="permissions">drwxr-xr-x</td>
-</tr>
+{ifeq(path, up, '', updirentry)}
 {dentries%direntry}
 {fentries%fileentry}
 </tbody>
diff --git a/mercurial/templates/paper/map b/mercurial/templates/paper/map
--- a/mercurial/templates/paper/map
+++ b/mercurial/templates/paper/map
@@ -41,6 +41,15 @@ navshort = '{before%navshortentry}{after
 navgraph = '{before%navgraphentry}{after%navgraphentry}'
 filenav = '{before%filenaventry}{after%filenaventry}'
 
+updirentry = '
+  <tr class="fileline">
+    <td class="name">
+      <a href="{url|urlescape}file/{symrev}{up|urlescape}{sessionvars%urlparameter}">[up]</a>
+    </td>
+    <td class="size"></td>
+    <td class="permissions">drwxr-xr-x</td>
+  </tr>'
+
 direntry = '
   <tr class="fileline">
     <td class="name">
diff --git a/tests/test-hgweb-descend-empties.t b/tests/test-hgweb-descend-empties.t
--- a/tests/test-hgweb-descend-empties.t
+++ b/tests/test-hgweb-descend-empties.t
@@ -93,11 +93,7 @@ manifest with descending (paper)
   </tr>
   </thead>
   <tbody class="stripes2">
-  <tr class="fileline">
-    <td class="name"><a href="/file/tip/">[up]</a></td>
-    <td class="size"></td>
-    <td class="permissions">drwxr-xr-x</td>
-  </tr>
+  
   
   <tr class="fileline">
   <td class="name">
@@ -213,11 +209,7 @@ manifest with descending (coal)
   </tr>
   </thead>
   <tbody class="stripes2">
-  <tr class="fileline">
-    <td class="name"><a href="/file/tip/?style=coal">[up]</a></td>
-    <td class="size"></td>
-    <td class="permissions">drwxr-xr-x</td>
-  </tr>
+  
   
   <tr class="fileline">
   <td class="name">
diff --git a/tests/test-hgweb-empty.t b/tests/test-hgweb-empty.t
--- a/tests/test-hgweb-empty.t
+++ b/tests/test-hgweb-empty.t
@@ -396,11 +396,7 @@ Some tests for hgweb in an empty reposit
   </tr>
   </thead>
   <tbody class="stripes2">
-  <tr class="fileline">
-    <td class="name"><a href="/file/tip/">[up]</a></td>
-    <td class="size"></td>
-    <td class="permissions">drwxr-xr-x</td>
-  </tr>
+  
   
   
   </tbody>
diff --git a/tests/test-hgweb-symrev.t b/tests/test-hgweb-symrev.t
--- a/tests/test-hgweb-symrev.t
+++ b/tests/test-hgweb-symrev.t
@@ -72,7 +72,6 @@ Set up the repo
   <li><a href="/rev/tip?style=paper">changeset</a></li>
   <a href="/archive/tip.zip">zip</a>
    directory / @ 2:<a href="/rev/9d8c40cba617?style=paper">9d8c40cba617</a>
-    <td class="name"><a href="/file/tip/?style=paper">[up]</a></td>
   <a href="/file/tip/dir?style=paper">
   <a href="/file/tip/dir/?style=paper">
   <a href="/file/tip/foo?style=paper">
@@ -138,7 +137,6 @@ Set up the repo
   <li><a href="/rev/xyzzy?style=paper">changeset</a></li>
   <a href="/archive/xyzzy.zip">zip</a>
    directory / @ 1:<a href="/rev/a7c1559b7bba?style=paper">a7c1559b7bba</a>
-    <td class="name"><a href="/file/xyzzy/?style=paper">[up]</a></td>
   <a href="/file/xyzzy/dir?style=paper">
   <a href="/file/xyzzy/dir/?style=paper">
   <a href="/file/xyzzy/foo?style=paper">
@@ -272,7 +270,6 @@ Set up the repo
   <li><a href="/rev/tip?style=coal">changeset</a></li>
   <a href="/archive/tip.zip">zip</a>
    directory / @ 2:<a href="/rev/9d8c40cba617?style=coal">9d8c40cba617</a>
-    <td class="name"><a href="/file/tip/?style=coal">[up]</a></td>
   <a href="/file/tip/dir?style=coal">
   <a href="/file/tip/dir/?style=coal">
   <a href="/file/tip/foo?style=coal">
@@ -338,7 +335,6 @@ Set up the repo
   <li><a href="/rev/xyzzy?style=coal">changeset</a></li>
   <a href="/archive/xyzzy.zip">zip</a>
    directory / @ 1:<a href="/rev/a7c1559b7bba?style=coal">a7c1559b7bba</a>
-    <td class="name"><a href="/file/xyzzy/?style=coal">[up]</a></td>
   <a href="/file/xyzzy/dir?style=coal">
   <a href="/file/xyzzy/dir/?style=coal">
   <a href="/file/xyzzy/foo?style=coal">
diff --git a/tests/test-hgweb.t b/tests/test-hgweb.t
--- a/tests/test-hgweb.t
+++ b/tests/test-hgweb.t
@@ -287,11 +287,7 @@ try bad style
   </tr>
   </thead>
   <tbody class="stripes2">
-  <tr class="fileline">
-    <td class="name"><a href="/file/tip/">[up]</a></td>
-    <td class="size"></td>
-    <td class="permissions">drwxr-xr-x</td>
-  </tr>
+  
   
   <tr class="fileline">
   <td class="name">
@@ -802,6 +798,17 @@ access bookmarks
   200 Script output follows
    changeset 0:<a href="/rev/2ef0ac749a14?style=paper">2ef0ac749a14</a>
 
+no '[up]' entry in file view when in root directory
+
+  $ get-with-headers.py localhost:$HGPORT 'file/tip?style=paper' | grep -F '[up]'
+  [1]
+  $ get-with-headers.py localhost:$HGPORT 'file/tip/da?style=paper' | grep -F '[up]'
+  <a href="/file/tip/?style=paper">[up]</a>
+  $ get-with-headers.py localhost:$HGPORT 'file/tip?style=coal' | grep -F '[up]'
+  [1]
+  $ get-with-headers.py localhost:$HGPORT 'file/tip/da?style=coal' | grep -F '[up]'
+  <a href="/file/tip/?style=coal">[up]</a>
+
 no style can be loaded from directories other than the specified paths
 
   $ mkdir -p x/templates/fallback


More information about the Mercurial-devel mailing list