tags:

views:

71

answers:

3

For doing builds, packaging files up, etc, it's needed to have a completely clean version from SVN. There can't be any non-versioned files which are floating around, e.g test.png might get packaged up if all PNG files are grabbed.

But, getting a totally new checkout is time and bandwidth consuming. So is there a way to take a working directory and get it to be exactly identical to a clean checkout, deleting non-versioned files as well as doing an svn update?

A: 

You can write a script that erases everything file that isn't in a .svn directory, and every directory that doesn't have a .svn subdir. Then run 'up', and all it will do is recopy the files out of the copies in the .svn directory.

However, all those .svn directories still have the potential to give you gas, so read Pascal's answer, even if it takes a long time.

bmargulies
How can this script work? I don't have any svn meta-data on this PC, do they simply list the files in there?
John
How can you not have svn metadata, unless you ran svn export in the first place. svn co ALWAYS makes that extra copy with metadata in the .svn directories.
bmargulies
@John your original question says that you ran an svn co. I stand by my remark. Whenever you run an svn co, you get metadata. If you 'don't have svn metadata' you didn't run co, and so your entire question is misleading and unanswerable.
bmargulies
Again let me refer you to my comment "I don't have any svn meta-data ON THIS PC".
John
@John, the only think I can think of is that we're using the term meta-data in two different ways. I'm talking about the .svn directories delivered, unconditionally, by co. Perhaps you are talking about all the other content on an svn server?
bmargulies
Yes so am I. I don't always work on a dev PC... hence I don't have a SVN checkout on this particular PC to inspect.
John
+2  A: 

If you want to :

  • get what is on the SVN
  • and nothing else
  • and, ideally, no .svn directories

Then, the best solution is to use svn export.


Yes, it will export all files from the SVN, which means it'll take some time and it'll consume a bit of bandwith ; but that's probably the best solution to avoid any trouble.

And, as a sidenote : it allows you to create your archive from your development machine, without having to revert your current work.


Else, you'll have to :

  • Do an svn revert, to cancel the modifications you made on your working copy and didn't commit.
  • And, then, make sure all .svn directories are excluded from your archive.
Pascal MARTIN
Note that svn revert won't remove un-versioned files, it'll only remove the "add" instruction from the svn meta-data.
Andy Shellam
.svn dirs aren't a problem, they are hidden IIRC and easy to filter out. But anyway, it seems I have no choice but to download a clean copy one way or the other?
John
+2  A: 

Here is a command that lists all unversioned files in a subversion directory:

svn status --no-ignore | grep '^\?' | sed 's/^\?      //'

Doing the update and deleting the files would look like this:

svn update && svn status --no-ignore | grep '^\?' | sed 's/^\?      //'  | xargs rm -rf

You might want to do a revert instead of the update if you want the exact same version. Still the best way would probably be to use svn export.

Daff
Did I say I was running *nix? But I'm sure someone will find it useful so thanks anyway.
John
No you didn't say anything about your OS. Btw, maybe if one SVN checkout is so bandwidth consuming you should check if all the files actually belong under version control (like Java JARs which you don't need to check in when you are using a build tool like Maven)
Daff
art files are big
John
@John Those svn command work fine on Windows if you have cygwin. Sarcasm is not called for.
bmargulies
Still yes, even if you complain. Assuming I have Linux or want Linux or want Linux functionality just to run grep isn't logical.
John