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.

+3


source to share


3 answers


There is work in progress in my Windoz window

svn ls -Rv | sort

      



On Unix you will most likely have to specify the sort order with the "-n" switch

+6


source


Use svn list --xml

and sort by <date>2014-08-20T12:34:46.712712Z</date>

.



+1


source


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);

      

0


source







All Articles