Large merge, tiny automation
Posted by Jeremy Voorhis Tue, 09 Jan 2007 19:30:00 GMT
or, awk’s not dead
At Values of n, we branch our codebase to create a safe environment for experiments or non-trivial changes to Stikkit. After spending a week on the east coast for holidays, I had the cough pleasure of merging over a weeks’ changes into my branch to keep current.
In my first approach, I tried merging everything at once. I ended up catching a multitude of conflicts – some of which made no sense since I was missing a weeks’ worth of context in a fast-paced environment. Clearly that was not the way to go.
My second attempt: divide and conquer. Using our revision history to look up changesets, I merged a day’s worth of changes at a time. Because a small number of issues tend to prevail on any given day, this allowed me to deal wih actual conflicts as they came. Actual, meaningful conflicts as opposed to conflicts in binary files or code I haven’t touched.
For reverting and resolving files I had no interest in, I learned the smallest bit ofawk.
svn st | awk '/^C/ { print "svn revert " $2 | "sh"; print "svn resolved " $2 | "sh" }'
This handy one-liner finds all conflicted files from the output of svn status, reverts them, and resolves them, allowing me to proceed. Other awk invocations resolved conflicts for a particular set of files by copying them from another directory and resolving. Familiarity with tools like lex and racc made awk a cinch to learn and more useful than I would have guessed.
Open question: what small-time automation do you rely on to support regular development?

One that I like to use a lot is:
perl -pi -e 's/\r\n?/\n/g' myfile. That would make Mac line returns behave like unix line returns.isn’t svk supposed to be good for this kind of stuff?
How do you have a revision history if you are only just uploading after a weeks worth of work? Do you know something about SVN that I don’t as that sounds really useful.
Textmate Scratch Macros!
I wouldn’t be able to stand refactoring in Rails projects without fic and ric for project wide find and replace. It’s just faster to do it from the command line than to open a new Textmate window for both the app and test directories.
I use variations on the following on a daily basis:
svn st | grep ? | awk '{print $1}' | xargs svn addBen: You can simply use
svn add --force .and that will add everything for you.awk, man that brings back memories of the good old days of shell scripting.
Hope its not dead, just bought learning bash yesterday