Sunday, August 22, 2010

Subtractive Merge

Programming is a fun thing, sometimes the best thing you can do is to remove or undo what you have done. There are many reason for this, some of which could be:
  • You were trying out something and it did not work as planed.
  • You were using a new version of a library and it has bugs in it.
  • You made changes that were not needed and what to just go back to an old version.
In the end, the result is the same, you have changes that you made and now you want to get rid of them.


If you are using a Code Management System, what you'll need to is a subtractive merge. A subtractive merge is a way to remove or undo changes.

Say you have the following Ruby code

Version 1:

# Hello World program in Ruby

puts "Hello World"

Version 2:

# Hello World program in Ruby

puts "Good Bye World"

Version 3:

# Hello World program in Ruby

puts "Good Bye World"
puts "Hello world again"


Say you are currently at the third version of code ("Hello world again") and you want to go back to the first version of the code ("Hello World"), what you'll need to do is subtractive merge back to the first version of the code.

The way to think of a subtractive merge is that you are removing changes that were done. In the case of doing a subtractive merge back to version 1, creating a new version 4 of the code we will have the following for version 4 of our code:

Version 4:

# Hello World program in Ruby

puts "Hello World"

Example in ClearCase:
To do this in ClearCase from the command line you would do the following:

cleartool merge -to filename -delete -ver \main\branch\versionNumber \main\branch\versionNumber

Example with file hello.rb in the \main\dev stream:

cleartool merge -to hello.rb -delete -ver \main\dev\2 \main\dev\3

Next time you find yourself wanting to rollback or undo changes, try a subtractive merge.

Wednesday, August 4, 2010

What Side of the Tracks Should I Be On?

Whenever I can, I try to take a train to the city. Trains are great: no traffic jams, no trouble finding a parking spot, and no taking the wrong exit off the highway. Plus they are green (for the most part).

One thing I noticed is that most of the time the train station gives no indicator as to which side of the tracks to be on. In the morning when there are lots of people going to work, this is not an issue. Just go to where the people are. However, this does not work at odd times when you might be the only person at the station.

When at a station by one's self I find the general rules to help tell which side of the tracks to be on.
  • Most people wait for the train in the morning on their way to work in the city, when they get off the train on their way home they do not wait around they just leave; therefore the benches and covered waiting areas are on the side of the tracks going to the city.
  • If benches and covered waiting areas are on both sides of the tracks, the side with more benches and larger covered waiting areas is the side going to the city (the reason is volume).
  • If there are three or more tracks with a fence splitting the tracks, the slide of the fence with more tracks is the side going to the city (again the reason is volume, but this time in the number of trains).
Following these simple rules should help get you on the right side of the tracks, if they do not work please let me and others know by commenting.