Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Traversing SVN Tree

by brwarn (Novice)
on Feb 29, 2008 at 17:35 UTC ( #671243=perlquestion: print w/ replies, xml ) Need Help??
brwarn has asked for the wisdom of the Perl Monks concerning the following question:

I want to traverse an SVN tree and gather the list of files I find along the way. Can someone point me to a package, etc. that does this? I haven't been able to find one so far. I also have discovered -d and -f file test operations (as well as stat/lstat) don't work on directories in the SVN trunk. Thanks.

Comment on Traversing SVN Tree
Re: Traversing SVN Tree
by blahblahblah (Priest) on Mar 01, 2008 at 03:56 UTC
    Are you talking about traversing a local checked-out copy of the repository? If so, then there should be nothing special about svn directories: -d, -f, stat, etc. should work normally. Can you post your code? Also check out File::Find.

    If on the other hand you're talking about querying the subversion server, then you can get the info with a subversion command such as svn list -R. For example:

    my $repos = q{svn://.../trunk}; my $svn = q{/usr/local/bin/svn}; my $tree = qx{$svn list -R $repos}; print $tree;
    Joe
      Sorry for the delay. I modified code that I found but get out of memory errors after six or so file names are listed. I see in the File::Slurp documentation that there's a way to read just filenames (and not the entire file contents as I believe that I'm doing below), but am not sure what to do with the following to just read the filenames.
      #!/usr/bin/perl use strict; use warnings; use File::Slurp; use File::Find; my $dir="C:\\Documents and Settings\\Administrator\\Desktop\\SVN\\trun +k"; # read an entire file into a scalar (a.k.a. 'slurping') find( \&show_subdirectories, $dir); sub show_subdirectories{ if ( -d ) { if ( $_ eq '.svn' ) { # don't traverse into subversion related directories $File::Find::prune = 1; return; } # for directories, only print path my $filepath ="$File::Find::name"; return; } -f or return; # if not a file /\.(xls|mdb)$/ or return; # if not the right extension my $perl = read_file( $_ ); my $filepath="$File::Find::name"; my @filearray=split(/\\trunk\//,$filepath); my $fileElt = $filearray[1]; print "FILEARRAY is $fileElt and FILE is $_\n"; }
        This line is reading in the file contents:
        my $perl = read_file( $_ );
        If you don't want to read the file contents, then just remove that line.
Re: Traversing SVN Tree
by Anonymous Monk on Mar 01, 2008 at 14:43 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://671243]
Approved by Arunbear
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (6)
As of 2014-07-24 02:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (156 votes), past polls