You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Carl Spalletta <cs...@gmail.com> on 2006/02/06 18:08:39 UTC
Converting output of 'svnlook tree' to canonical format
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: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Re: Converting output of 'svnlook tree' to canonical format
Posted by Peter Samuelson <pe...@p12n.org>.
[Carl Spalletta]
> 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.
Or, a bit shorter and more perly...
#!/usr/bin/perl -nl
s/^( *)//;
$level = length $1;
$name[$level] = $_;
print @name[0..$level];
Re: Converting output of 'svnlook tree' to canonical format
Posted by Bart Robinson <lo...@pobox.com>.
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 <cs...@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
Re: Converting output of 'svnlook tree' to canonical format
Posted by Bart Robinson <lo...@pobox.com>.
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 <cs...@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: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Re: Converting output of 'svnlook tree' to canonical format
Posted by Peter Samuelson <pe...@p12n.org>.
[Carl Spalletta]
> 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.
Or, a bit shorter and more perly...
#!/usr/bin/perl -nl
s/^( *)//;
$level = length $1;
$name[$level] = $_;
print @name[0..$level];
Re: Converting output of 'svnlook tree' to canonical format
Posted by "C. Michael Pilato" <cm...@collab.net>.
Carl Spalletta 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.
Does it deal with path components that have a space as the first
character of their name? :-)
--
C. Michael Pilato <cm...@collab.net>
CollabNet <> www.collab.net <> Distributed Development On Demand
Re: Converting output of 'svnlook tree' to canonical format
Posted by "C. Michael Pilato" <cm...@collab.net>.
Carl Spalletta 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.
Does it deal with path components that have a space as the first
character of their name? :-)
--
C. Michael Pilato <cm...@collab.net>
CollabNet <> www.collab.net <> Distributed Development On Demand