Lonli-Lokli
Lonli-Lokli

Reputation: 3784

SVN: analog of hg's addremove

We have a repository with several files (no folders). Each build time we have to download the same folder from another source (db), then commit to SVN changes - update existing, remove not existed and add new files.

So idea is to have 'copy' of db's scripts in SVN each build (that's why MSBuild is used)

Problem is that I don't know analog of hg's addremove - which automatically synchronize two folders.

does anyone know how addremove can be simulated?

Upvotes: 14

Views: 1544

Answers (4)

Chris
Chris

Reputation: 591

For this sort of thing, I just use mercurial, and check in and out of svn with: https://www.mercurial-scm.org/wiki/HgSubversion ... might not be exactly what you want.

Upvotes: 1

Dmitry Sokolov
Dmitry Sokolov

Reputation: 3190

(Improvement of @Eric-Karl's answer)

Works for:

  • paths with 'space' chars
  • paths with '@' chars
  • paths with '\' chars (in MSYS shell)

svn status | perl -ne 'print "$1\0" if /^\?\s+([^\r\n]+)/' | xargs -0 -r -I FILE svn add 'FILE@'
svn status | perl -ne 'print "$1\0" if /^\!\s+([^\r\n]+)/' | xargs -0 -r -I FILE svn remove 'FILE@'

Upvotes: 0

E-K
E-K

Reputation: 1491

I personally have a little bash script to do that (being on linux):

svn status | grep "^\?" | gawk '{print $2}' | xargs -r svn add
svn status | grep "^\!" | gawk '{print $2}' | xargs -r svn remove

EDIT: Thanks to cesar, here's a simpler version:

svn status | gawk '/^\?.*/ {print $2}' | xargs -r svn add
svn status | gawk '/^\!.*/ {print $2}' | xargs -r svn remove

Upvotes: 11

Ringding
Ringding

Reputation: 2856

I've always used the svn_load_dirs.pl script that comes with svn for this purpose.

Upvotes: 0

Related Questions