From the beginning, all Open Source Software at JeeLabs has been maintained in a system called Subversion. This is a version control system which makes it easy to manage changes in (large amounts of) source code over (large periods of) time.
There are many such systems, with names like CVS, Subversion, Bazaar, Git, Mercurial, and more. I used CVS in the past, and switched to Subversion many years ago. It suits me well.
If you think that version control is not much more than “making frequent backups in an organized manner”, then you may be in for a surprise. Please keep reading…
All of these systems deal with the same task: managing edits. And all of them have reached a level of functionality and maturity, that frankly, I couldn’t understand how anyone writing software these days could live without…
That’s quite a statement, so let me explain.
Software development is a process. You write code, you fix bugs, you add new features over time – sometimes over a period of years, in fact. Coding is an error-prone activity, from trivial typo’s, to syntax errors, to feature omissions, to design errors… it’s all part of the process.
Suppose someone finds a bug. Wouldn’t it be great if you could go back and see what changes you made, and in what order? Maybe the bug is a new one? Maybe it got introduced by a recent change? Maybe it’s part of a very specific feature?
Here’s an extract of a special “annotated” view of the RF12.h header file. This overview was generated by Redmine, as it is now used for the JeeLabs CafĂ©:
The color-coded areas are “change sets”. The numbers indicate in which “revision” this particular code was added or last changed. The numbers are clickable, so if I click on “5976” for example, to view the last change related to the rf12_sendStart() code, I get this:
This shows exactly which files were changed at the same time, and the comment I added when I made that change, i.e. “more rf12_sendStart() low power modes”. The value is not just this little overview, but the fact that all other files and changes have been omitted. All irrelevant info is gone.
Let’s say I want to find out what was changed in the “radioBlip.pde” sketch at that time. I can click on the “(diff)” link, to get this:
Aha, this is apparently where I added some extra low-power-mode options to the RF12 driver, as I was writing the radioBlip example (red = deleted code, green = added code).
Note how only a small part of the source code is shown. I’m only interested in what changed, so all I get is a “diff” with a few lines of context. I can always go back to my full copy of the source code to see the rest.
This particular change was made 4 months ago. It took me three clicks in the web browser to find out what happened. Not “sort of”, but precisely. I don’t know about you, but to me that is an incredible way to keep track of things. I never have to guess, I can go back in time and zoom in on any specific detail I’m interested in right now.
Let me drive the point home: this isn’t a feature, it’s a necessity. There is no way I could call myself a software developer without tools like these.
All version control systems do this, it doesn’t really matter which one you use. All I can say is: if you haven’t been using any of them, pick one and put your whole (software) life in it. Today. You will have to learn some new conventions and some new habits. You will feel constrained initially. But once that wears off and the new habits kick in, you will wonder how you ever did without.
This doesn’t just apply to “official” software development, btw. Anything that takes more than say a day to work on, will benefit from revision control, IMO. Some people put their entire websites in there. Some people even put their entire home directory in there!
The nice thing about modern revision control systems, is that they are networked. With proper care and authentication, source code can live in a public “repository” accessible to more people. Websites such as http://github.com/ specialize in providing a complete environment for anyone who wishes to manage their source code in public. Completely free. All you need is the proper “client software” for the version control system you’re using, and a server (such as Github) where you get source code and send changes back.
By now, I no longer consider the source code on my hard disk to be crucially important. It’s a copy, “checked out” from my main subversion repository, which lives on an internet-facing server. I can get an up to date copy anywhere, just by checking out a new copy (as long as I remember where the server is, and my personal username/password).
The second killer feature (no less) of a version control system, is that it lets people work together on a single project, no matter where they are. Everyone gets their own locally checked-out copy of the same project, and everyone can make whatever changes they like, and “check-in” the changes whenever they please.
This happens very efficiently, because version control systems are immensely clever about dealing with text changes. They don’t send around complete projects and source files all the time, they quickly send little changes around (called “diffs”). This makes the mechanism 100% scalable. You could be working on a project with millions of lines of source code. Yet when you send in a change, the process is almost as quick as with a tiny project.
When more than one person makes a change to a source file, and sends in that change, three things can happen:
- there is no one else who changed that file, so the change is accepted as is
- someone else changed that file, but not in the same place – again, the change is automatically accepted as is, and “merged” in
- someone else changed one or more of the same lines, in which case the change is flagged as a conflict
The last case is the only one which needs a bit of attention. The changes need to be compared, and someone has to decide what the final version should look like. Usually, the intent is easy to spot, and things can be resolved without any further discussion. In rare cases, the two people involved will have to discuss and resolve the issue between them.
This sounds like a lot of hassle. But it’s in fact one of my favorite features: I can check out someone else’s source code, and use it. But I can also make changes in any way I like, without ever sending them in. IOW, I can tweak any code I have in any way I like. Never will I risk losing those changes, even if I never send them in (often, they are not of general use anyway). And I’ll always be able to go back and see what my own changes were.
So with this guaranteed checking and comparing of source code, it becomes impossibe to lose changes. My own, or anyone else’s. The version control system will flag any potential problem before it actually becomes one.
More tomorrow, as I describe how to get version control going on your own machine, and how to hook up to the source code in the JeeLabs repository.
If you can’t wait and already know how to use Subversion, all the JeeLabs code can be found here:
svn://svn.jeelabs.org/jeelabs/trunk/
If you just want to have a quick look around using the new Redmine web interface: the JeeLabs libraries can be browsed here, while JeeMon has its own repository area, which can be browsed here.
I really like SVN, I’ve used it for quite a while. When used properly it is a wonderful tool, especially for collaborative efforts.
To anyone else who is thinking of using it, do it! Just remember to write something in the description when you check stuff in. It doesn’t have to be much, just say what you were working on, new features you added etc. This is very useful for others, and yourself when you look back at the project 2 months later.
Having SVN and a bug tracking system together is even better. You can quote the bug/feature number your change resolves, and the SVN change reference number on your bug report. All tied together. Lovely.
That’s one of the reasons I picked Redmine. It integrates version control, issue tracking (“bug reports”), wiki pages, and forums. All of them use the same syntax (Markdown), and there are some simple conventions to create cross-links between the different areas.
It looks tremendously powerful. It would be nice to keep track of my little JeeNode sketches as I update them, although it might be overkill for that task… I’m not collaborating with anyone at the moment, so would I have to run the server process myself, as well as a client? I’m on WinXP here and I see from the Apache Subversion website docs there are some issues with running a server on Windows, not to mention the whole set of machinery looks pretty complex.
Two options for you: if your sketches are related to JeeNodes in any way, I’ll be happy to set up write access for you in the JeeLabs subversion repository, as I’ve done for others (email me). Another option, requiring only that your code be open source, is to register and set up an area for yourself at GitHub and use the Git client software.
There has been a lot of discussion on the web (sometimes with more heat than light), about the pros and cons of the different version control systems. As with programming languages, I find such choices mostly unimportant. Whatever you choose, version control is immensely useful, IMO. You’ll see your definition of “overkill” change rapidly, I predict.