How to sort SVN LS -R output by date
I want to list all files in my svn, sorted by the date of the last commit. svn ls -Rv
all files are listed, but it doesn't accept a switch -t
. Does anyone know how to do this?
(I saw an answer to a similar question for svn status
, but it wasn't obvious to me how to change it to work with svn ls
.)
STILL UNANSWERED: It would be helpful to be able to sort files by date added to SVN.
source to share
I ran into this problem today. Other options didn't work for me. I came up with a short Perl script that does the job. Perhaps this could be secured in a one line liner, but I didn't like that.
Place the code in svn-sort.pl. The command line will look something like this:
svn ls $url | perl svn-sort.pl | sort
Hope this helps.
#!/usr/bin/env perl
use strict;
use warnings;
# Main entry point.
sub main {
my $input;
# Read into string instead of array.
{
local $/ = undef;
$input = <>;
}
my $count = 0;
my $limit = 0;
my @matches;
while ($input =~ m|<entry.+?<name>([^<]+?)</name>.*?<date>([^<]+?)</date>.*?</entry>|gs) {
push @matches, [$1, $2];
}
foreach my $m (@matches) {
print "$m->[1]\t$m->[0]\n";
if ($limit > 0 && ++$count > $limit) {
last;
}
}
}
# Go.
&main(@ARGV);
source to share