-
Notifications
You must be signed in to change notification settings - Fork 1
/
svn-files-since.pl
executable file
·81 lines (71 loc) · 2.2 KB
/
svn-files-since.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/usr/bin/perl -w
#
# svn-files-since.pl -- aggregate all source files files
# (added, modified, changed) in the specified revision range.
#
# Mainly useful for determining how a libtool -version number should change.
#
use strict;
use XML::Simple;
#use Data::Dumper;
if ((scalar(@ARGV) == 0)
or ($ARGV[0] eq '-?')
or ($ARGV[0] eq '-h')
or ($ARGV[0] eq '--help')) {
print <<EOF;
Show the log message and diff for a revision.
usage: $0 REVISION [WC_PATH|URL]
EOF
exit 0;
}
my $revision = shift || die ("Revision argument required.\n");
if ($revision =~ /r([0-9]+)/) {
$revision = $1;
}
my $url = shift || "";
my $svn = "svn";
my $prev_revision = $revision - 1;
if (not $url) {
# If no URL was provided, use the repository root from the current
# directory's working copy. We want the root, rather than the URL
# of the current dir, because when someone's asking for a change
# by name (that is, by revision number), they generally don't want
# to have to cd to a particular working copy directory to get it.
my @info_lines = `${svn} info`;
foreach my $info_line (@info_lines) {
if ($info_line =~ s/^Repository Root: (.*)$/$1/e) {
$url = $info_line;
}
}
}
my $xmlLog = `${svn} log -v --xml -r${revision}:HEAD $url`;
my $xs = XML::Simple->new();
my $ref = $xs->XMLin($xmlLog);
my %alteredFiles = ();
#print Dumper($ref);
my $source_file_re = qr/\.(?:[sS]|c(?:pp|xx|c)?|h(?:pp|xx|h)?)$/;
foreach my $rev (@{$ref->{'logentry'}}) {
# print "revision: " . $rev->{'revision'} . "\n";
foreach my $path ($rev->{'paths'}) {
if (ref($path->{'path'}) eq 'ARRAY') {
foreach my $p (@{$path->{'path'}}) {
if ($p->{'kind'} eq 'file') {
my $fn = $p->{'content'};
if ($fn =~ $source_file_re) {
$alteredFiles{$fn} = 1;
}
}
}
} else {
if ($path->{'path'}->{'kind'} eq 'file') {
my $fn = $path->{'path'}->{'content'};
if ($fn =~ $source_file_re) {
$alteredFiles{$fn} = 1;
}
}
}
}
}
for my $key (sort keys %alteredFiles) {
print $key . "\n";
}