First impressions of Mercurial
Goffredo Baroncelli
kreijack at libero.it
Wed Jun 15 11:29:47 UTC 2005
On Tuesday 14 June 2005 23:24, you (Matt Mackall) wrote:
> On Tue, Jun 14, 2005 at 11:14:14PM +0200, Goffredo Baroncelli wrote:
> > On Tuesday 14 June 2005 18:34, Thomas Arendsen Hein wrote:
> > > - show permissions in hgweb
> >
> > This is my patch:
>
> I like it. If you could make two changes:
> > +def dprint(s):
> Some debug code snuck in
Removed
> > + mfflags=self.repo.manifest.readflags(mfn)
> > + if f in mfflags.keys() and mfflags[f] :
> > + mode="x"
> > + else:
> > + mode="-"
>
> This ought to instead be done with a filter function like date.
I wrote the function flags2permission( ) that converts the value of the map ( booloean now )
into an appropriate text ( true -> 'x', false ->'-' )
> Mode might be a bit too generic for a template key name.
I changed 'mode' in 'permissions'
Below the new patch ( I send it also in cc to the mailing list )
--- a/mercurial/hgweb.py Tue Jun 14 02:36:40 2005
+++ b/mercurial/hgweb.py Wed Jun 15 13:24:42 2005
@@ -42,6 +42,12 @@
for t, s in scales:
n = delta / s
if n >= 2 or s == 1: return fmt(t, n)
+
+def flags2permissions( map, path ):
+ if map[path]:
+ return "x"
+ else:
+ return "-"
def nl2br(text):
return text.replace('\n', '<br/>\n')
@@ -376,13 +382,15 @@
p1, p2 = fl.parents(n)
t = float(cs[2].split(' ')[0])
mfn = cs[0]
+ self.repo.manifest.read(mfn)
+ mode=flags2permissions(self.repo.manifest.readflags(mfn),f)
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(),
@@ -399,7 +407,7 @@
hex(p1), fl.rev(p1), file=f),
parent2 = self.parent("filerevparent",
hex(p2), fl.rev(p2), file=f),
- p1 = hex(p1), p2 = hex(p2),
+ p1 = hex(p1), p2 = hex(p2), permissions = mode,
p1rev = fl.rev(p1), p2rev = fl.rev(p2))
def fileannotate(self, f, node):
@@ -415,6 +423,8 @@
p1, p2 = fl.parents(n)
t = float(cs[2].split(' ')[0])
mfn = cs[0]
+ self.repo.manifest.read(mfn)
+ mode = flags2permissions(self.repo.manifest.readflags(mfn),f)
def annotate():
parity = 1
@@ -464,13 +474,14 @@
hex(p1), fl.rev(p1), file=f),
parent2 = self.parent("fileannotateparent",
hex(p2), fl.rev(p2), file=f),
- p1 = hex(p1), p2 = hex(p2),
+ p1 = hex(p1), p2 = hex(p2), permissions = mode,
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)
+ manifest_files_flags=self.repo.manifest.readflags(bin(mnode))
files = {}
@@ -495,17 +506,20 @@
for f in fl:
full, fnode = files[f]
if fnode:
+ mode=flags2permissions(manifest_files_flags,full)
yield self.t("manifestfileentry",
file = full,
manifest = mnode,
filenode = hex(fnode),
parity = parity,
- basename = f)
+ basename = f,
+ permissions = mode )
else:
yield self.t("manifestdirentry",
parity = parity,
path = os.path.join(path, f),
- manifest = mnode, basename = f[:-1])
+ manifest = mnode, basename = f[:-1],
+ mode="d")
parity = 1 - parity
yield self.t("manifest",
--- a/templates/fileannotate.tmpl Tue Jun 14 02:36:40 2005
+++ b/templates/fileannotate.tmpl Wed Jun 15 13:24:42 2005
@@ -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#</td></tr>
</table>
<br/>
--- a/templates/filerevision.tmpl Tue Jun 14 02:36:40 2005
+++ b/templates/filerevision.tmpl Wed Jun 15 13:24:42 2005
@@ -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#</td></tr>
</table>
<pre>
--- a/templates/manifest.tmpl Tue Jun 14 02:36:40 2005
+++ b/templates/manifest.tmpl Wed Jun 15 13:24:42 2005
@@ -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>d
+ <td><a href="?cmd=manifest;manifest=#manifest#;path=#up#">[up]</a>
#entries#
-
+</table>
#footer#
--- a/templates/map Tue Jun 14 02:36:40 2005
+++ b/templates/map Wed Jun 15 13:24:42 2005
@@ -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>#permissions# <td><a href="?cmd=manifest;manifest=#manifest#;path=#path#">#basename#/</a>"
+manifestfileentry = "<tr class="parity#parity#"><td>#permissions# <td><a href="?cmd=file;filenode=#filenode#;file=#file#">#basename#</a>"
filerevision = filerevision.tmpl
fileannotate = fileannotate.tmpl
filediff = filediff.tmpl
--
gpg key@ keyserver.linux.it: Goffredo Baroncelli (ghigo) <kreijack at inwind.it>
Key fingerprint = CE3C 7E01 6782 30A3 5B87 87C0 BB86 505C 6B2A CFF9
More information about the Mercurial
mailing list