Any code you write should be submitted within 24 hours. If you have made changes to code on any of your projects which has not been submitted in the last day then you need to read this.
Back to Basics
Let’s recap on why it is importance to check code in frequently:
· Your changes are safe – so they won’t be lost if your laptop breaks.
· Other people can take over your work – if you have to go on emergency leave.
· You can rollback changesets – if you want to revert your recent changes.
· You can identify bugs quicker – isolating a bug to a small change makes it easier to fix.
· Each changeset describes the code – it is much easier for someone to work out what a piece of code is designed to do if it was submitted in a small self-contained changeset.
I hope we all agree on most (if not all) of these points, otherwise you question why you are using version control at all.
Submitting Unfinished Code
One of the golden rules of version control is that you don’t submit unfinished code. You can work in your private workspace to develop and test your code in isolation. When you are finished you submit your changes to the Development Stream.
So if it takes a week to develop and test my changes, I can only submit my changes when it is finished.
Wait. Let’s rephrase that slightly.
So if it takes a week to develop and test my changes, I can only submit my changes to the development stream when it is finished.
You can therefore create a feature stream for your changes. In the feature stream you can submit as often as you want. When you have finished your changes you can merge them all back into the development stream.
Feature Streams are Easy
I bet there are some people who stopped reading this as soon as I mentioned the term ‘feature stream’ – development is complicated enough without having feature streams. But let’s break this down and look at why feature streams are perceived as complicated:
· I’m only going to be working on this change for a week. I can’t be bothered setting up a new stream and everything else.
· I don’t want the complexity of merging changes to and from the feature stream.
Now let’s look at these 2 points in turn.
Create a Feature Stream in 10 Seconds
In the PureCM GUI go to the Repository View. In the folder containing the development stream(s) for this project create a new stream folder and call it ‘Stephen’s Features’.
Now right-click the development stream and select ‘Create Stream From’. Call the stream ‘Feature A’ and put it in the new stream folder.
That is it! For the next feature you won’t even need to do the first step.
You can now right-click a workspace for the development stream and select ‘All Tasks | Rebase Workspace’. This will change your workspace to use your new feature stream. Since the files in the feature stream are currently identical to the files in the development stream the rebase will take no time at all.
Automate Merging to a Feature Stream
I lied. It might take 20 seconds to create your first feature stream.
There is another step you should perform after creating the feature stream folder. Right-click the ‘Stephen’s Features’ folder, select Properties and go to the ‘Merge Paths’ page. Uncheck the ‘Inherit Merge Path properties from parent’ checkbox.
Note that this functionality is only available with the Professional Edition. You can use feature streams in the Standard Edition but merging into the feature stream will have to be a manual process. If you are using the Professional Edition then you need to enable the ‘Professional Policies | General | Merge Path Administration’ and ‘Professional Policies | General | Enable Merge Paths’ policies if you have not already done so.
OK. I know this dialog can look a bit scary. But just go with me and select the checkboxes as shown above. What this mean is that whenever a changeset is submitted in the development stream it will be applied to the feature stream.
Feature Streams in Action
Now the feature streams are all setup, let’s see them in action. In the Repository View delete the old ‘Feature A’ stream (because it was created before we updated the stream folder permissions). Create a ‘Feature B’ stream and rebase your workspace to it.
Now pretend someone else is working on the development stream by creating a workspace for the development stream and submitting a simple changeset. If you now go back to the Feature B workspace you will see that the workspace is out of date and the Submitted Changesets shows the new changeset as outstanding.
Look familiar? The workspace is exactly the same as if you had been working in the development stream. You just need to update your workspace to get the new changes. So as you can see, in the general case where the files you are working on have not been changed by someone else, working in a feature stream is no different to working in the development stream.
Let’s see what happens if another developer changes a file which you have already changed in the feature stream...
Submit a change in the workspace for the feature stream. Remember that the big advantage with feature streams is that the change is not pushed to the server until you say. So this submit could just be a checkpoint of unfinished work.
Now go to the development workspace and submit a change to the same file. You will see that this submit succeeds. This is correct because changes in the feature stream should have no impact on developers working in the development stream.
If you look at the feature stream in the Repository View you will see that it has Pending Merges.
This is telling you that a change was submitted in the development stream which conflicts with changes in the feature stream. Right-click the pending merge changeset and select ‘Merge Change’. This will launch the Resolve Tool – exactly the same as if you had done an update to latest in the development workspace which caused conflicts.
In other words, the only difference between working in the feature stream and working in the development stream is that you need to merge any changesets with conflicts.
You do not even have to go to the Repository View to view your Pending Merges. Within a workspace you can use the menu ‘Workspace | Show Server Files Tab’ to launch a window showing the Pending Merges.
The final piece of the jigsaw is how the submitted changes in the feature stream are pushed to the development stream. Let’s demonstrate this by submitting another changeset in the feature stream workspace. So we now have 2 changes submitted in the feature stream and we want to merge them back to the development stream as a single changeset.
Go back to the Repository View, right-click the development stream and select ‘Merge Changes’. Select the feature stream as the source stream. You will see that only the changesets submitted in the feature stream are listed. Check all of the changesets and press Finish. Don’t choose for PureCM to automatically merge the changesets, because this will merge each changeset individually.
PureCM will then launch the Resolve Tool showing you all of the changes you have made and allowing you to change the description. When you press ‘Save’ the changeset is merged back into the development stream.
So as you can see. The process of pushing the feature stream changes back to the development stream is similar to the process of submitting a changeset. The only difference is that you have the slight overhead of using the Merge Wizard.
Remember that there cannot be conflicts when merging your changes back into the development stream, because you have already merged all the development stream changes into your feature stream. The merge will always be trivial.
Are Feature Streams Worth It?
As a developer, if you value the ability to checkpoint your code often so you can revert back to it, then yes I think the small overhead with feature streams will be well worth while.
If not then you might decide that you are happy working without them and only submitting every week or so. But if the day comes when you end up loosing a week’s work because your laptop breaks or your release is late because a developers had to take emergency leave then you might wish that you had been using feature streams.
PureCM handles features streams well, but there is plenty of room for improvement. Thankfully most (if not all) of these new features will make it into the 2010/1 release (April 2010).
· Simplify pushing the changes back into the development stream. There should be a toolbar button on the workspace which merges all the changes back into the development stream.
· Automatically resolve pending merges when updating the feature stream workspace. This functionality would then be identical to when working on the development stream.
· Distinguish between feature streams and other streams. For example, when displaying the submitted changesets the release streams are very relevant while the feature streams are not.