| ||
|
The "Design of Software" discussion group has been merged with the main
Joel on Software discussion group.
The archives will remain online indefinitely. |
Fairly simple question: I want to copy a directory (and its subdirs) of source from one place to another, omitting the .svn directories that are in each and every directory. My first thought is to copy it all then delete the .svn dirs. cp -a src dest for file in $(find -name '.svn'} do rm -rf $file done Is there a way to accomplish this without copying the .svn dirs over in the first place?
Ugnonimous Tuesday, August 07, 2007
Can't you tar and untar? Something like: tar cvf d.tar --exclude='.svn' test_svn/ mkdir temp_dir tar xvf d.tar -C temp_dir/ mv temp_dir/test_svn/ dest_svn rm -fr temp_dir/ I hope it's a good solution. In the past, folks used to use techniques like this because there wasn't an easy cp -a command I think.
Joao Pedrosa Tuesday, August 07, 2007
You could copy everything to the new directory then delete the files you don't want. I know, it wastes cpu cycles, disk IO, etc... There is an old saying "That an unused cpu cycle is a wasted cpu cycle." Make your hardware vendor happy move as much as possible as often as possible. ;-)
Jim. Tuesday, August 07, 2007
I've been down this road twice before. 1) For a probably identical case (authoring build scripts that checked code from SVN) I ended up copying everything and deleting after the fact. 2) For a very different case, which involved doing a wget web crawl and then renaming all of the files and directories to meet a formatting requirement, I ended up writing my own recursive shell script. Feel free to email me if you want me to dig up code.
Hm, try this (as an executable script, called with two parameters: the source directory to copy from and the destination directory to copy to): SRC="$1" DST="$2" for F in "$SRC"/.* "$SRC"/* do # for every entry in the source directory if [ $(basename "$F") != .svn ] then # for everything that isn't an SVN directory if [ -d "$F" ] then # recursively copy subdirectories mkdir "$DST"/$(basename "$F") "$0" "$F" "$DST" else # simple copy for files cp -a "$F" "$DST" fi fi done A little more unix-foo is needed to copy the subdirectories themselves while preserving the ownership and dates, as well as make sure that the right number of parameters were given and that the destination directory exists, but you get the idea.
If you don't want to depend on a specific fancy version of tar, try good old find and cpio: find . -print | grep -v '\.svn' | cpio -pmud <destdir> You can use the various knobs on both find and grep to suit. This will work on anything from a SunOS 3 box to the latest AMD64 Linux box.
I see 3 options: 1) rsync with --exclude 2) gnu tar with --exclude 3) use "svn export" to check out the repository without .svn directories. Wednesday, August 08, 2007
you can do 'svn export' which excludes the .svn dirs svn export <you project>
gooch Wednesday, August 08, 2007
Something like find topDir | appropriate filter | <cpio in passthrough mode> might work. You will need to fuss with working directories to get the output tree where you want it, though. If this is a one-time thing, just do what you originally wrote. If it is going to be done a lot, then use filtering, since you will just about halve the data transfer. Also, if the code is checked in, you can use "svn export" to get the files without the .svn. For this to work, you have to want to copy just the checked in file, so if there are files from a build, this won't do what you need.
frustrated Thursday, August 09, 2007 | |
Powered by FogBugz
