MyCampus About | Getting Started | Writing Plugins | Getting the Source | Branching

Instructions on how to branch and merge MyCampus

Introduction

Contrary to what many believe, branches are a great thing. Branches can be used when:

  • You can to experiment with something.
  • You want to fix a bug over many days, and don't want to have uncommitted code hanging out (remember from my talk how SCM can act as backup).
  • You are fixing multiple bugs and certain ones need to be reviewed by team members. Create a branch for each team member.

There are many other uses, but those are just a few.

Creating a branch

To create a branch:

1. Copy trunk to a branches folder. You can either put it in your user folder (users/NETID) or in our MyCampus branches folder (mycampus/branches). Example below puts it in the latter.

$ svn cp svn+ssh://NETID@hiro.acm.uiuc.edu/afs/acm/sig/macwarriors/svn/MacWarriors/mycampus/trunk 
         svn+ssh://NETID@hiro.acm.uiuc.edu/afs/acm/sig/macwarriors/svn/MacWarriors/mycampus/branches/ExploratoryFeature
         -m 'Branching trunk for work on this exploratory feature'

2. Now you can check out that branch just like you would check out trunk:

$ svn cp svn+ssh://NETID@hiro.acm.uiuc.edu/afs/acm/sig/macwarriors/svn/MacWarriors/mycampus/branches/ExploratoryFeature

Working with your branch

When you have a branch, you can commit to it just like you would normally commit to trunk, but this way, you are not actually putting changes (potentially drastic changes) into trunk.

Merging with trunk

Once you are done with your branch, you need to merge it with trunk.

1. Get the revision number for when your branch was created. For an explanation of why you have to do this, see this.

$ cd YOUR_BRANCH_WORKING_DIRECTORY
$ svn log --stop-on-copy
------------------------------------------------------------------------
r406 | NETID | 2008-02-08 11:17:26 -0600 (Sun, 08 Feb 2009) | 1 line

Branching trunk for work on this exploratory feature
------------------------------------------------------------------------

From this, we see the revision the branch was created was 406.

2. Do the actual merge.

$ cd YOUR_TRUNK_WORKING_COPY
$ svn merge -r 406:HEAD svn+ssh://NETID@hiro.acm.uiuc.edu/afs/acm/sig/macwarriors/svn/MacWarriors/mycampus/branches/ExploratoryFeature

In the example above, 406 was the revision number when we created the branch. And HEAD is the current revision. Yes, you can actually just type the string HEAD and it will get the current revision.

3. Make sure all the merged worked by building the project and running all unit tests and testing manually.

4. Check all your changes with the svn-view-local-diffs script (you will need to get it from the tools folder) before committing.

$ svn-view-local-diffs