How to sort SVN LS -R output by date

点点圈 提交于 2019-12-23 15:32:52

问题


I want to list all the files in my svn, sorted by date of last commit. svn ls -Rv lists all the files, but it doesn't accept a -t switch. Does anyone know how to do this?

(I have seen an answer to a similar question for svn status, but it wasn't obvious to me how to change this to work with svn ls.)

STILL UNANSWERED: It would also be helpful to be able to sort the files by date added to SVN.


回答1:


On my Windoz box the below does the job

svn ls -Rv | sort

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




回答2:


Use svn list --xml and sort by <date>2014-08-20T12:34:46.712712Z</date>.




回答3:


Came across this challenge today. The other options didn't work for me. I came up with a short Perl script that does the job. It might be possible to bastardize this into a one-liner but I didn't feel like it.

Put the code into svn-sort.pl. Command line would look something like this:

svn ls $url | perl svn-sort.pl | sort

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


来源:https://stackoverflow.com/questions/25426001/how-to-sort-svn-ls-r-output-by-date

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!