Subject: | [PATCH] Show all svn properties in "Browse" and "View" actions |
Hi,
here's a patch that enables the display of all svn properties set on
directories, and also when viewing files.
Subject: | all_props.patch |
diff -Naur Web.original/Browse.pm Web/Browse.pm
--- Web.original/Browse.pm 2007-08-08 19:25:24.000000000 +0200
+++ Web/Browse.pm 2007-08-08 19:26:45.000000000 +0200
@@ -205,12 +205,13 @@
@$entries;
my @props = ();
- foreach my $prop_name (qw(svn:externals)) {
- my $prop_value = ($ctx->revprop_get($prop_name, $uri, $rev))[0];
- if(defined $prop_value) {
- $prop_value =~ s/\s*\n$//ms;
- push @props, { name => $prop_name, value => $prop_value };
- }
+ my $proplist = $ctx->proplist($uri, $rev, 0);
+ if ($proplist->[0]) {
+ my $prop_hash = $proplist->[0]->prop_hash;
+ while ( my ($prop_name, $prop_value) = each %$prop_hash ) {
+ $prop_value =~ s/\s*\n$//ms if defined $prop_value;
+ push @props, { name => $prop_name, value => $prop_value };
+ }
}
return {
diff -Naur Web.original/Template/trac/view Web/Template/trac/view
--- Web.original/Template/trac/view 2007-08-08 19:25:24.000000000 +0200
+++ Web/Template/trac/view 2007-08-08 19:26:45.000000000 +0200
@@ -20,4 +20,23 @@
<p>This file can not be displayed in the browser. You can <a href="[% c.script %]/[% c.repos %]/checkout[% c.path %]">download it</a>.</p>
[% END %]
</div>
+
+[% IF props.size != 0 %]
+<table class="listing" id="proplist">
+ <thead>
+ <tr>
+ <th class="name">[%|l%](prop-name)[%END%]</th>
+ <th class="change">[%|l%](prop-value)[%END%]</th>
+ </tr>
+ </thead>
+ <tbody>
+ [% FOREACH props %]
+ <tr class="[% loop.count % 2 ? "even" : "odd" %]">
+ <td class="propname">[% name %]</td>
+ <td class="propvalue">[% value | html | html_line_break %]</td>
+ </tr>
+ [% END %]
+ </tbody>
+</table>
+[% END %]
[% PROCESS footer %]
diff -Naur Web.original/View.pm Web/View.pm
--- Web.original/View.pm 2007-08-08 19:25:24.000000000 +0200
+++ Web/View.pm 2007-08-08 19:39:43.000000000 +0200
@@ -143,12 +143,16 @@
$ctx->cat($fh, $uri . $path, $rev);
close($fc);
- my $mime_type;
- my $props = $ctx->propget('svn:mime-type', $uri . $path, $rev, 0);
- if(exists $props->{$uri . $path}) {
- $mime_type = $props->{$uri . $path};
- } else {
- $mime_type = 'text/plain';
+ my @props = ();
+ my $mime_type = 'text/plain';
+ my $proplist = $ctx->proplist($uri . $path, $rev, 0);
+ if ($proplist->[0]) {
+ my $prop_hash = $proplist->[0]->prop_hash;
+ while ( my ($prop_name, $prop_value) = each %$prop_hash ) {
+ $prop_value =~ s/\s*\n$//ms if defined $prop_value;
+ $mime_type = $prop_value if $prop_name eq 'svn:mime-type';
+ push @props, { name => $prop_name, value => $prop_value };
+ }
}
return {
@@ -160,6 +164,7 @@
at_head => $head,
mimetype => $mime_type,
file => $fc,
+ props => \@props,
%{ $self->{REV} },
}
};