Summary : Branching and Merging in Subversion 1.0

http://svnbook.red-bean.com/en/1.0/ch04.html

The current version of SVN is 1.5. But I think study older version usage will be useful for future work for my project because these two functions of Subversion change very fast.

In this blog I’ll summarize key usage of branching & merging in svn 1.0. If you’re looking not for a shortnote or quick reminder, I recommend you to read the official site instead.

Outline: (* means there’s a better/different way in version 1.5)

  1. Copy Changes between Branch
    1. Command to use*
    2. Why don’t we use “patch”
    3. Best practices*
  2. Common use-cases
    1. Merge whole branch to another*
    2. Undo changes*
    3. Resurrecting deleted item
  1. Copy Changes between Branch
    1. Command to usage
      • You’re likely to merge changes from trunk to your developing branch.
      • svn merge -r [from_rev]:[to_revision] [url] [wc]
      • for example svn merge -r [343]:[350] http://repos/xxx/trunk ./branch/20081021-jemmy-new-feature
      • Don’t forget to commit !! Merge will happen in your working(local) copy only.
      • This command will compare different between both revision and *patch* it in the working copy.
    2. Why don’t we use “patch”
      • Patch will only look inside the file’s content.
      • You’ll miss file addition/removal/renaming
    3. Best practices
      • Track manually : Yes, you’ll have to track which revision you have merged already. This is error-prone and annoying task. *version 1.5 solves this problem*
      • Preview merging : Use “svn merge –dry-run”. This will preview the output (list of modification to working copy) but not really run the merge.
      • Ancestry : Consider this scenario – you have file integer.c@99  and update it @100 and delete it @101 and create new integer.c@102. @99 is ancestry of @100 but not @102. Why this is important? When svn see that @99 is not ancestry of @102, instead of updating its content, it will delete @99 and create new file @102.
  2. Common use-cases
    1. Merge whole branch to another
      • You’ll need to do this when your feature branch is finish and want to merge back to the trunk.
      • Don’t merge from HEAD of the branch to HEAD of the trunk. Your works in the trunk those are not merged to branch will disappear.
      • Instead, use “svn log –verbose –stop-on-copy” to find the start revision of the branch.
      • Then use “svn merge -r” command in 1.1
      • Troublesome? Luckily, this feature has been improved in 1.5
    2. Undo changes
      • To undo from revision 303 to 302, use this command
      • “svn merge -r 303:302”
    3. Resurrecting deleted item
      • For example, you want to recover “real.c”
      • First, use “svn log –verbose” to find which revision “real.c” was deleted.
      • You can’t use undo command like in 2.2 because you’ll get all other changes (in other files you’re working)
      • So use “svn copy –revision [rev_no] [url] [wc]”
      • This way, you retain the history of “real.c” (in older revision) You won’t have it if you just add new real.c file into your working copy and commit.

, , , , ,

  1. Summary: Advanced Merging in Subversion 1.5 « It’s your world…. in my view

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: