Cp * except .svn directories

Hi all,

sorry if this is a repost! Don’t know if it’s Pan or my ISP but there’s
some weirdness going on ATM!

What I’d like to be able to do is write a script that can copy all
files/directories from a subversion repository except .svn directories.

This is the best I can come up with from the command line (be gentle
;-)):

  1. cd to repos dir
    1. tar --exclude=".svn" -cvf foo.tar *
    2. mv foo.tar /path/to/new
  2. cd /path/to/new
  3. tar -xvf foo.tar

It works but I’m hoping there’s a way to do this in a ruby script. If
possible
I’d like to be able to input “/path/to/new”.

So if I’m in the repos dir:

    cp_wo_svn.rb
    "to where?":    /var/www
    "done!"

thanks,

Mark W. wrote:

  1. cd to repos dir
    cp_wo_svn.rb
    “to where?”: /var/www
    “done!”

thanks,

Perhaps the svn export command is what you are looking for?

On 31-jul-2006, at 16:00, Mark W. wrote:

What I’d like to be able to do is write a script that can copy all
files/directories from a subversion repository except .svn
directories.

rsync -arvz /from/ /to/ --exclude=".svn"

Julian ‘Julik’ Tarkhanov wrote:

me at julik.nl
And course you can simply run any of the above from a ruby script with
the exec quotes ... or via the system call.

Ken

Julian ‘Julik’ Tarkhanov wrote:

me at julik.nl
And course you can simply run any of the above from a ruby script with
the exec quotes ... or via the system call.

Ken

Mark W. wrote:

  1. cd to repos dir
    cp_wo_svn.rb
    “to where?”: /var/www
    “done!”

I think Julian Tarkh’s solution is the easiest. But if you must do it in
ruby, you can use
the Find module.

Paraphrased from the Ruby Cookbook (pg216):

require ‘find’
Find.find(’./’) do |path|
Find.prune if File.basename(path) == ‘.svn’
puts path
end

In irb:

irb(main):001:0> require ‘find’
=> true
irb(main):002:0> Find.find(’./’) do |path|
irb(main):003:1* Find.prune if File.basename(path) == ‘.svn’
irb(main):004:1> puts path
irb(main):005:1> end
./
./branches
./tags
./trunk
./trunk/fdefmod
./trunk/fdefmod/test
./trunk/fdefmod/test/test.type
./trunk/fdefmod/test/test_ftypedef.rb
./trunk/fdefmod/test/test_fdefmod.rb
./trunk/fdefmod/test/ftypedef.rb
./trunk/fdefmod/lib
./trunk/fdefmod/lib/~fdefmod.rb
./trunk/fdefmod/lib/ftypedef.rb
./trunk/fdefmod/lib/fdefmod.rb
./trunk/learningcurve
./trunk/learningcurve/test
./trunk/learningcurve/lib
./trunk/learningcurve/lib/tconvert.rb
./trunk/util
./trunk/util/test
./trunk/util/lib
./trunk/util/lib/eh2mh.rb

Without the Find.prune, you’ll get everything:

irb(main):001:0> require ‘find’
=> true
irb(main):002:0> Find.find(’./’) do |path|
irb(main):003:1* puts path
irb(main):004:1> end
./
./.svn
./.svn/tmp
./.svn/tmp/props
./.svn/tmp/wcprops
./.svn/tmp/text-base
./.svn/tmp/prop-base
./.svn/props
./.svn/format
./.svn/wcprops
./.svn/text-base
./.svn/prop-base
./.svn/empty-file
./.svn/entries
./.svn/README.txt
./branches
./branches/.svn
./branches/.svn/tmp
./branches/.svn/tmp/props
.etc…lotsa .svn stuff…

cheers,

paulv

On Wed, 02 Aug 2006 21:50:51 +1000, Mark W. wrote:

exec “rsync -arvz $HOME/svnwd/Proj1/www/ /var/www/ --exclude=”.svn""
exec “rsync -arvz $HOME/svnwd/Proj1/includes/ /var/includes/
–exclude=”.svn""

ie chain together commands.

This only does the first exec and I’m wondering is this a ‘thread’ issue
or similar?

Any ideas how I handle this?

‘system’ was what I needed. This is working!!
system (“rsync -arvz $HOME/svnwd/Proj1/www/ /var/www/
–exclude=”.svn"")
system (“rsync -arvz $HOME/svnwd/Proj1/includes/ /var/includes/
–exclude=”.svn"")

So it appears each call to system waits for the previous to finish
whereas
‘exec’ doesn’t?

Hi all,

On Mon, 31 Jul 2006 23:58:52 +1000, Mark W. wrote:

  1. cd to repos dir
    cp_wo_svn.rb
    “to where?”: /var/www
    “done!”

thanks,

thanks to all for the suggestions. Paul, yep I settled on Julians
solution
though they all work!

repos2local.rb
exec “rsync -arvz $HOME/svnwd/Proj1/www/ /var/www/ --exclude=”.svn""

This copies the ‘www’ folder from the repos over to /var/www (ignoring
the .svn folders) but I’d now like to extend this. ie.

repos2local.rb
exec “rsync -arvz $HOME/svnwd/Proj1/www/ /var/www/ --exclude=”.svn""
exec “rsync -arvz $HOME/svnwd/Proj1/includes/ /var/includes/
–exclude=”.svn""

ie chain together commands.

This only does the first exec and I’m wondering is this a ‘thread’ issue
or similar?

Any ideas how I handle this?

thanks,

Hi all,

On Wed, Aug 02, 2006 at 08:50:05PM +0900, Mark W. wrote:

files/directories from a subversion repository except .svn directories.
I’d like to be able to input “/path/to/new”.
thanks to all for the suggestions. Paul, yep I settled on Julians solution
exec “rsync -arvz $HOME/svnwd/Proj1/includes/ /var/includes/
–exclude=”.svn""

ie chain together commands.

This only does the first exec and I’m wondering is this a ‘thread’ issue
or similar?

Any ideas how I handle this?

It’s because #exec replaces the current process with the new one. You
need to fork and exec in the child (and in the parent, wait until the
child is done before continuing).

BTW, you might want to look into svn export, see if that’s usable. The
entire point of that command is to create a copy of the tree without any
of the svn metadata (i.e. no .svn folders).

Hi Kevin,

On Thu, 03 Aug 2006 01:56:12 +0900, Kevin B. wrote:

It’s because #exec replaces the current process with the new one. You
need to fork and exec in the child (and in the parent, wait until the
child is done before continuing).

BTW, you might want to look into svn export, see if that’s usable. The
entire point of that command is to create a copy of the tree without any
of the svn metadata (i.e. no .svn folders).

Thanks,
I was aware of ‘export’ but wanted to do this as a little ruby
experiment.
Finally got what I was after which was to backup localhost as a
timestamped folder (eg www03072230) and the includes folder, then delete
everything and copy over the repos.

If all goes well, which it appears to be, I’ll work on copying the local
development over to my live host next.

cheers,

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs