Native commands

  • Produce a patch file of changes committed in revision 1377:

    1 $ svn diff -r 1376:1377 > diff.patch
  • Merge revision 3403 of the trunk into the β€œ1.0” branch:

    1 $ cd branches/1.0
    2 $ svn merge -c3403 https://svn.example.com/my_project/trunk
    3 $ svn commit -m "Merge r3403 into the 1.0 branch."
  • Revert current local folder to revision 666:

    1 $ svn merge -rHEAD:666 ./
  • Create an empty repository:

    1 $ svnadmin create ./my-repo
  • Dump a repository (a sure way to migrate a subversion repository from one version to another):

    1 $ svnadmin dump ./my-repo > ./my-repo.dmp
  • Migrate a remote Subversion repository without creating an intermediate dump file:

    1 $ ssh -C [email protected] "svnadmin dump /home/user/my-repo" | svnadmin load /home/user2/my-new-repo
  • Launch a standalone Subversion server listening on port 3690 and serving all repositories located in ./repos/:

    1 $ svnserve --daemon --listen-port 3690 --root ./repos/

Local working copy hacking

  • Recursive and case insensitive content search on non-binary files from the current folder, while ignoring .svn folders and their content:

    1 $ find ./ -type f -not -regex ".*\/.svn\/.*" -exec grep -Iil "string to search" {} \;
  • Same thing as above but with an alternative approach (that don’t work with large folder content):

    1 $ grep -Ii "string to search" $(find . | grep -v .svn)

Other alternative: use ack.

  • Use sed to replace text in all files except in subversion metadatas:

    1 $ find ./ -type f -not -regex ".*\/.svn\/.*" -print -exec sed -i 's/str1/str2/g' "{}" \;
  • Use svn delete to remove all files containing a tilde in their name without touching local subversion metadatas:

    1 $ find -type f -not -regex ".*\/.svn\/.*" -name "*˜*" -print -exec svn delete "{}" \;
  • In a repository structure containing sub-projects (thinks of Plone’s collective repository as an example), get the list of all folders in all trunks, while ignoring subversion metadata folders:

    1 $ find ./ -type d -regex ".*\/trunk\/?.*" -not -regex ".*\/.svn\/?.*" -print
  • Similarly to the command above, replace all occurrences of the string @coolcavemen.fr by @coolcavemen.com in all trunk subfolders while ignoring .svn content:

    1 $ find ./ -type f -regex ".*\/trunk\/.*" -not -regex ".*\/.svn\/.*" -print -exec sed -i 's/@coolcavemen\.fr/@coolcavemen\.com/g' "{}" \;
  • Set a svn property to ignore all .mo files during commit in every folder of our local working copy containing .po files:

    1 $ find ./ -type f -name "*.po" -regex ".*\/trunk\/.*" -not -regex ".*\/.svn\/.*" -printf "%h\n" | uniq | xargs svn propset "svn:ignore" "*.mo"