Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Copying the .svn directories from a checkout to a non-checkout to make it a checkout

I have a large application in a production environment that I'm trying to move under version control. So, I created a new repo and imported the app, minus various directories and files that shouldn't be under version control. Now, I need to make the installed copy a checkout (but still retain the extra files). At this point, in a recent version of SVN, I'd simply do a checkout over top the existing directory using the --force option. But sadly, I have an ancient version of SVN, from before when the --force option was added (and can't yet upgrade... long story).

So, I checked out the app to another directory, and want to simply copy all of the .svn directories into the original directory, thus turning the original into a checkout whilst leaving alone the extra files. Now, maybe I'm just having a rough day and missing something that's in plain site, but I can't seem to be able to figure this out. Here are the approaches I've tried so far:

  1. Use rsync: I can't seem to hit the right combination of include and exclude directives to recursively capture all the .svn directories but nothing else.

  2. Use cp: I can't figure out a good way to have it hit all the .svn directories across and down through the whole app.

  3. Use find with -exec cp: I'm running into trouble with the leading part of the pathnames of the found files messing up the destination paths. I can exclude it using -printf '%P', but that doesn't seem to go into the {} replacement for exec.

  4. Use find with xargs to cp: I'm running into trouble with find sending over child directories before sending their parents. Unfortunately, find does not have a --breadth option.

Any thoughts out there?

Other info:

  • bash 3.0.0.14
  • rsync 2.6.3 p28
  • cp 5.2.1
  • svn 1.3.2
like image 937
mr. w Avatar asked Sep 23 '09 21:09

mr. w


People also ask

How do I clone a svn repository?

# Clone a repo with standard SVN directory layout (like git clone): git svn clone http://svn.example.com/project --stdlayout --prefix svn/ # Or, if the repo uses a non-standard directory layout: git svn clone http://svn.example.com/project -T tr -b branch -t tag --prefix svn/ # View all branches and tags you have ...

How do I clean up a .svn folder?

According to this answer and SVN change log, svn cleanup has an option to vacuum pristine copies ( /vacuum ). This is done by default starting from 1.8. From version 1.10 up it is not longer done by default, but can be run using the command svn cleanup --vacuum-pristines (see this answer).

How do I checkout a working copy in svn?

svn Getting started with svn Checking out a working copy Your local copy of the project is called a working copy in Subversion and you get it by issuing the command svn checkout <URL> where <URL> is a repository URL. e.g. Alternatively, you can use svn co <URL> as a shorthand in order to checkout a local copy.

What does svn copy do?

svn copy (cp) — Copy a file or directory in a working copy or in the repository.


1 Answers

Use tar and find to capture the .svn dirs in a clean checkout, then untar into your app.

cd /tmp/
svn co XXX
cd XXX
find . -name .svn -print0 | tar cf /tmp/XXX.tar --null -T -
cd /to/your/app/
tar xf /tmp/XXX.tar

Edit: switched find/tar command to use NUL terminator for robustness in the face of filenames containing spaces. Original command was:

tar cf /tmp/XXX.tar $(find . -name .svn)
like image 180
bstpierre Avatar answered Oct 05 '22 03:10

bstpierre