Home » How-to: “svn update --dry-run”

How-to: “svn update --dry-run”

October 12th, 2005 by Jim

My 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

  1. Change to the root directory of your working copy.
  2. 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.

  3. 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.
  4. Review the output of svn merge and check for conflicts. If you spot any, try using svn diff to determine what is causing the conflict, or just prepare yourself to fix the conflict ASAP! 😀
  5. Now that you know how friendly or destructive update will be with your working copy, run svn update to let the fun begin!

Leave a Reply »

Revision History

2005.10.12 Added this Revision History block.
2005.10.12 Initial revision.

Disclaimer

I do not offer a warranty or guarantee for anything described in this article. All of my tips are based on personal and professional experience, but you are solely responsible for your own actions. Please backup your data first, and exercise extreme caution when using this information!

2 Responses to “How-to: “svn update --dry-run””

  1. Hayden Says:

    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).

  2. MaciekD Says:

    This should help:

    svn status –show-updates