January 6, 2012

How I Use Surround SCM: Working Directory Differences (New for 2012)

Surround SCM
When I'm writing code I do two things quite often.
  1. I refactor and try to get rid of as much code as possible. The less code I write means the less bugs I can write. (Awesome.)
  2. I nearly always forget to add new files I've created to Surround SCM. (Not awesome.)
At best item #2 means the continuous integration server yells at me. At worst it means one of the other developers yells at me and I need to buy donuts for breaking the build. And I don't even like donuts. Some enhancements that are coming in Surround SCM 2012 are tailor-made to help with these two things. First, let's take a look at what happens when I've edited a couple of existing source files and added a new one to the project. I generally do a recursive filter like this before I check in: This is where I usually get into trouble by forgetting to add new source files. The two files I edited are shown because they're already in Surround SCM. But I haven't added the new file yet, so it isn't listed at all. A better way to see what has changed is to select a parent repository that I am working from and click Differences. This brings up the Working Directory Differences dialog and, as you can see, not only are my two edited files shown but my brand new file is highlighted in green. Somewhere a donut baker is weeping into his batter at all the lost profits. All those buttons on the right side of the dialog show actions I can perform. First things first, I can add the new file with the Add button. All the usual goodness is there, I can add as part of a changelist (which as I've written before I always do) and I can attach to TestTrack in case this is all part of bug fix. Same thing applies for checking in the changes to my two edited files with the Check In button. So that's all awesome and my coworkers and continuous integration server will be much happier with me. Now, let's take a quick look at another option on this dialog that helps when refactoring. Let's say in this case, along with the other changes we've talked about before, I've renamed a file on my local machine. Surround SCM is tracking that file and has its complete history, but it is tracking it by its old name. In this example I've renamed qttextcode_symbian.cpp to qttextcodec_symbian_deprecated.cpp. My recursive filter, knowing only about the original name and not the new _deprecated name, shows the original file as missing. The Working Directory Differences dialog, however, shows a different story. You can see that Surround SCM shows that my originally named file is missing locally on my hard drive and my renamed file is missing on the server. If I select both files, the Resolve Missing button becomes active and allows me to choose to either rename the file in Surround SCM or rename it locally on my computer. I choose Rename Server... because I want to rename the file that Surround SCM is tracking. The Rename File dialog opens, so I can rename the file to its newly refactored name. As always, this is changelist enabled so I can do it all in one big atomic shot. So pretty cool stuff, but I do a feel a little bad for the local Mason, Ohio economy because of this feature. If you are driving through hit up one of our bakeries and buy a dozen or so donuts. Tell them I sent you and that I'm sorry I haven't been in lately.