[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: Converting output of 'svnlook tree' to canonical format

From: Bart Robinson <lomew_at_pobox.com>
Date: 2006-02-07 00:22:16 CET

svnlook in 1.3 has a --full-paths option that I think does what
you want.
Also svn ls -R does something similar but will also work on a
remote repository.

-- bart

On 2006-2-6 Carl Spalletta <cspalletta@gmail.com> wrote:
> Excuse me for reinventing the wheel, but I couldn't find an
> existing script to convert output of 'svnlook tree' to the
> usual unix format.
>
> Hope this is useful to somebody.
>
> Please give credit if you use the logic or code somewhere.
>
> #!/usr/bin/perl -n
> #Copyright (c) 2006 by Carl Spalletta cspalletta@gmail.com under GPL, v2
> #This file takes the output of unix or svnlook 'tree' command, eg:
> #
> # trunk/
> # CVS-LEGACY/
> # cvswrappers
> # checkoutlist
> # PROJ1/
> # config
> # branches/
> # ...
> #
> # And turns it into this:
> #
> #trunk/
> #trunk/CVS-LEGACY/
> #trunk/CVS-LEGACY/cvswrappers
> #trunk/CVS-LEGACY/checkoutlist
> #trunk/PROJ1/config
> #branches/
> # ...
>
> BEGIN
> {
> $level=0;
> $olevel=-1;
> }
>
> #count number of leading spaces
> sub countlevels
> {
> my $line = shift;
> my @ltrs = split "",$line;
> my $levels;
>
> for($levels=0;$levels<=$#ltrs;$levels++)
> {
> last unless $ltrs[$levels] =~ /^ $/;
> }
>
> return $levels;
> }
>
> #chomp,print,next if /^\S/;
> if(/^\S/)
> {
> if(m{^/})
> {
> chomp;
> print "$_";
> }
> else
> {
> die "Extraneous garbage: $_";
> }
> next
> }
>
> $level = countlevels $_;
> if($level<$olevel)
> {
> for($i=$level;$i<$olevel;$i++)
> {
> $l[$i]="";
> }
> }
>
> $l[$level-1]=$_;
> print "$line\n";
>
> $line = join "/",@l;
>
> $line =~ s/\s//g;
> $line =~ tr/\///s;
>
> $olevel=$level;
>
> END
> {
> print "$line\n";
> }

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org
Received on Tue Feb 7 00:23:20 2006

This is an archived mail posted to the Subversion Users mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.