hgweb: add file permissions
authormpm@selenic.com
Wed, 15 Jun 2005 10:20:26 -0800
changeset 359 0c4688e9ee5c
parent 358 9f4077d7ef6f
child 360 10519e4cbd02
hgweb: add file permissions -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 hgweb: add file permissions From: Goffredo Baroncelli <kreijack@libero.it> Show permissions in hgweb Tweaked by mpm manifest hash: f11361c6da21f3ba60c5e6a173396754c36efb1d -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (GNU/Linux) iD8DBQFCsHFqywK+sNU5EO8RAoqFAJ44P8kZoZDiY5Fw8LWpL/3ArXNE2QCeO3z4 0zV5rXWa/r/xgf+AVTLeQ/4= =FzLj -----END PGP SIGNATURE-----
mercurial/hgweb.py
templates/fileannotate.tmpl
templates/filerevision.tmpl
templates/manifest.tmpl
templates/map
--- a/mercurial/hgweb.py	Wed Jun 15 10:06:40 2005 -0800
+++ b/mercurial/hgweb.py	Wed Jun 15 10:20:26 2005 -0800
@@ -130,6 +130,7 @@
             "addbreaks": nl2br,
             "obfuscate": obfuscate,
             "firstline": (lambda x: x.splitlines(1)[0]),
+            "permissions": (lambda x: x and "-rwxr-xr-x" or "-rw-r--r--")
             }
 
     def refresh(self):
@@ -376,13 +377,14 @@
         p1, p2 = fl.parents(n)
         t = float(cs[2].split(' ')[0])
         mfn = cs[0]
+        self.repo.manifest.read(mfn)
 
         def lines():
             for l, t in enumerate(text.splitlines(1)):
                 yield self.t("fileline", line = t,
                              linenumber = "% 6d" % (l + 1),
                              parity = l & 1)
-        
+
         yield self.t("filerevision", file = f,
                      header = self.header(),
                      footer = self.footer(),
@@ -400,6 +402,7 @@
                      parent2 = self.parent("filerevparent",
                                            hex(p2), fl.rev(p2), file=f),
                      p1 = hex(p1), p2 = hex(p2),
+                     permissions = self.repo.manifest.readflags(mfn)[f],
                      p1rev = fl.rev(p1), p2rev = fl.rev(p2))
 
     def fileannotate(self, f, node):
@@ -415,6 +418,7 @@
         p1, p2 = fl.parents(n)
         t = float(cs[2].split(' ')[0])
         mfn = cs[0]
+        self.repo.manifest.read(mfn)
 
         def annotate():
             parity = 1
@@ -465,12 +469,14 @@
                      parent2 = self.parent("fileannotateparent",
                                            hex(p2), fl.rev(p2), file=f),
                      p1 = hex(p1), p2 = hex(p2),
+                     permissions = self.repo.manifest.readflags(mfn)[f],
                      p1rev = fl.rev(p1), p2rev = fl.rev(p2))
 
     def manifest(self, mnode, path):
         mf = self.repo.manifest.read(bin(mnode))
         rev = self.repo.manifest.rev(bin(mnode))
         node = self.repo.changelog.node(rev)
+        mff=self.repo.manifest.readflags(bin(mnode))
 
         files = {}
  
@@ -500,7 +506,8 @@
                                  manifest = mnode,
                                  filenode = hex(fnode),
                                  parity = parity,
-                                 basename = f)
+                                 basename = f, 
+                                 permissions = mff[full])
                 else:
                     yield self.t("manifestdirentry",
                                  parity = parity,
--- a/templates/fileannotate.tmpl	Wed Jun 15 10:06:40 2005 -0800
+++ b/templates/fileannotate.tmpl	Wed Jun 15 10:20:26 2005 -0800
@@ -29,6 +29,9 @@
 <tr>
  <td class="metatag">date:</td>
  <td>#date|date# (#date|age# ago)</td></tr>
+<tr>
+ <td class="metatag">permissions:</td>
+ <td>#permissions|permissions#</td></tr>
 </table>
 
 <br/>
--- a/templates/filerevision.tmpl	Wed Jun 15 10:06:40 2005 -0800
+++ b/templates/filerevision.tmpl	Wed Jun 15 10:20:26 2005 -0800
@@ -30,6 +30,9 @@
 <tr>
  <td class="metatag">date:</td>
  <td>#date|date# (#date|age# ago)</td></tr>
+<tr>
+ <td class="metatag">permissions:</td>
+ <td>#permissions|permissions#</td></tr>
 </table>
 
 <pre>
--- a/templates/manifest.tmpl	Wed Jun 15 10:06:40 2005 -0800
+++ b/templates/manifest.tmpl	Wed Jun 15 10:20:26 2005 -0800
@@ -11,7 +11,10 @@
 
 <h2>manifest: #path#</h2>
 
-<div class="parity1"><a href="?cmd=manifest;manifest=#manifest#;path=#up#">[up]</a><br /></div>
+<table cellpadding="0" cellspacing="0">
+<tr class="parity1">
+  <td><tt>drwxr-xr-x</tt>&nbsp;
+  <td><a href="?cmd=manifest;manifest=#manifest#;path=#up#">[up]</a>
 #entries#
-
+</table>
 #footer#
--- a/templates/map	Wed Jun 15 10:06:40 2005 -0800
+++ b/templates/map	Wed Jun 15 10:20:26 2005 -0800
@@ -8,8 +8,8 @@
 changelogentry = changelogentry.tmpl
 changeset = changeset.tmpl
 manifest = manifest.tmpl
-manifestdirentry = "<div class="parity#parity#"><a href="?cmd=manifest;manifest=#manifest#;path=#path#">#basename#/</a><br /></div>"
-manifestfileentry = "<div class="parity#parity#"><a href="?cmd=file;filenode=#filenode#;file=#file#">#basename#</a><br /></div>"
+manifestdirentry = "<tr class="parity#parity#"><td><tt>drwxr-xr-x</tt>&nbsp;<td><a href="?cmd=manifest;manifest=#manifest#;path=#path#">#basename#/</a>"
+manifestfileentry = "<tr class="parity#parity#"><td><tt>#permissions|permissions#</tt>&nbsp;<td><a href="?cmd=file;filenode=#filenode#;file=#file#">#basename#</a>"
 filerevision = filerevision.tmpl
 fileannotate = fileannotate.tmpl
 filediff = filediff.tmpl