How-to: “svn update --dry-run”
October 12th, 2005 by JimMy company uses Subversion to manage several websites. When using a version control system to manage live websites, it is absolutely critical to first verify that an update to the code will not conflict with local modifications. Code conflicts will effectively break a website, leading to downtime and unnecessary embarassment.
What we need is a --dry-run
flag for Subversion’s update
command, but at the time of this writing, Subversion does not offer any such flag. Instead, we invent a clever workaround using the merge
command, which does offer the --dry-run
flag. Note: The update
command is simply a special case of merge
, so we are not really inventing anything. We are working smarter. 😉
How to use svn merge
to preview svn update
- Change to the root directory of your working copy.
- Run the command:
svn merge --dry-run -r BASE:HEAD .
Note: The trailing “dot” is the path of the working copy, and it is required even if you are already inside the working copy, which you should be after step 1.
- The above command requests a “dry run” of what will happen if we receive all changes that occurred after our working revision (BASE) and the most recent revision in the repository (HEAD). This is what
svn update
does, too. - Review the output of
svn merge
and check for conflicts. If you spot any, try usingsvn diff
to determine what is causing the conflict, or just prepare yourself to fix the conflict ASAP! 😀 - Now that you know how friendly or destructive
update
will be with your working copy, runsvn update
to let the fun begin!
Revision History
2005.10.12 | Added this Revision History block. |
2005.10.12 | Initial revision. |
Disclaimer
April 6th, 2006 at 9:24 am
Unfortunately, it just doesn’t alwyas work correctly. It can report conflicts that are simply impossible. Here’s an example using svn 1.2.1:
qa21 haydens/work/trunk> svn merge –dry-run -r BASE:HEAD . | grep ^C
C clients/c++/TupleConnection.cpp
C test/xml/join.xml
C test/xml/modules.xml
qa21 haydens/work/trunk> svn stat test/xml/join.xml test/xml/modules.xml
qa21 haydens/work/trunk> svn diff test/xml/join.xml test/xml/modules.xml
qa21 haydens/work/trunk>
Note that the 2nd and 3rd conflict isn’t possible because the two files haven’t been changed (or even touched).
January 25th, 2007 at 4:10 am
This should help:
svn status –show-updates