I typically work on large chunks of code on a project, and from time to time have to back up my data to patches:
svn diff > /backups/assignment-XX_diff-YY.patch
I then revert-and-update my local working copy:
svn revert -R . && svn up
I then go to work on my other assignment, and when it is committed, I clean up and revert locally, then re-apply my patch from the work I was doing earlier:
svn revert -R .
svn up
patch -p0 < /backups/assignment-XX_diff-YY.patch
One thing I have noticed is that when I have created a new file, then add the file, e.g.:
touch newFile.cpp
svn add newFile.cpp
Newly added files and their contents are in the patch I create, and the files are recreated when I apply the patch, but the “added” status is not automatically set when I apply the patch. This has resulted in my applying a patch that is ready to commit, but only the “modified” files get committed, not the “added” files. Also, the “new” files, if they were already present, now have the entire patch appended to the EOF, breaking them.
So, in summary: Is it possible to have patch automatically issue the svn add command on new/added files when it applies a patch to my local working copy?
Yes, it is possible with svn 1.7 new command
svn patch.Run
svn patch /backups/assignment-XX_diff-YY.patchinstead ofpatch -p0 < /backups/assignment-XX_diff-YY.patch. From Apache Subversion 1.7 Release Notes: