fredley
fredley

Reputation: 33921

Is there a way of automatically making the checked in version of a directory identical to mine?

I've made a large number of changes to a versioned directory. I've renamed, added, deleted and done a lot of tidying up (it's a directory of resources). Is there a way of avoiding lots of error-prone use of svn delete and svn add to make sure the correct files are added/removed, or is there a way of automating the addition/removal of files from version control (i.e. a single command that makes every file that exists in the directory versioned, and makes any absent ones unversioned)?

Upvotes: 1

Views: 31

Answers (1)

codeling
codeling

Reputation: 11408

If you're on a bash, writing a script which derives it's todo list from the output of svn's status command is pretty easy:

svn st | grep '^\?' | awk '{print \$2}' | xargs svn add
svn st | grep '^\!' | awk '{print \$2}' | xargs svn rm

(Source: http://www.plexusweb.com/staff/travis/blog/post/267/Batch-addremove-files-to-Subversion)

That will handle all occured changes as adding or removing of files, however; recognizing renamed files is a rather difficult problem, since such a tool would have to know how to get the latest version of each file via subversion which seems deleted, and then compare it to each of the "new" files in your working directory - and maybe even consider small changes to it you might have made (meaning that comparison by hash value would not be possible) - indeed a challenging task!

Upvotes: 1

Related Questions