Necessity to commit immediately after using svn delete?
A 'build' directory in my project needs to be deleted and created again after every check out. Here is what I do which is kind of a long and c开发者_开发知识库umbersome process and creates a large number of unnecessary commits:
$ svn delete build
$ svn commit -m "build directory deleted..." [Unnecessary commit]
$ svn update
$ mkdir build [to create a fresh empty directory of build]
$ cd build [perfom operations in build]
$ svn add build
$ svn commit -m "New revision having following XYZ changes"
Problem: Is there a workaround to avoid the redundant commit just after delete? I just want to delete everything related to my project inside the 'build' directory to be deleted so that I may create new versions of them. Following steps, which I thought should have worked, give problems
$ svn delete build
$ rm -r build
$ mkdir build
$ svn add build
$ svn commit -m "New revision having following XYZ changes"
A build directory is not something you typically want in a repository. What you should ideally be doing is 1) Ignore the build directory from svn using the svn:ignore
property, 2) remove or create the build directory using your build script
This way you will also avoid having any (needless) commits in your repository which just create or remove the build directory.
The traditional approach is to check out and build, but not commit the resulting build artefacts. Instead, create a tag (in svn, you do this with svn cp, customarily to tags/_build_id_). If you need to keep track of what compiler version etc was used for the build, you can generate and commit a text file with the necessary information. This way, you can - at least in theory - regenerate an identical build if you ever need to. Copying the build artefacts to a separate archive is still a goid idea, but this is usually not kept under version control.
From your svn commands I guess that you want to commit a version of the code without the local build directory, then update from the svn repo (also without the build dir), but then re-create the "build" directory and save it the repository.
If the build directory must be re-created after each "svn update" (e.g. because something changed due to the "svn update") then you can use the svn ignore to ignore the "build" dir on the first commit, but can't escape re-creating it.
If you can re-use the old "build" directory after the "svn update", you can save time by setting and resetting the svn ignore property before/after the commits:
$ svn propset svn:ignore build
$ svn commit -m "build directory deleted..." [Unnecessary commit]
$ svn update
$ svn propdel svn:ignore build
$ svn commit -m "New revision having following XYZ changes"
I haven't tried it myself, but it should work :)
精彩评论