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 of awk.

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?

Comments

  1. Pope said about 2 hours later:

    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.

  2. Joe said about 4 hours later:

    isn’t svk supposed to be good for this kind of stuff?

  3. Alex said about 8 hours later:

    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.

  4. Ryan Allen said about 8 hours later:

    Textmate Scratch Macros!

  5. Chris Anderson said about 8 hours later:

    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.

  6. Ben Askins said about 8 hours later:
    I use variations on the following on a daily basis:
    svn st | grep ? | awk '{print $1}' | xargs svn add
    
  7. Pope said about 19 hours later:

    Ben: You can simply use svn add --force . and that will add everything for you.

  8. Mark Carey said 1 day later:

    awk, man that brings back memories of the good old days of shell scripting.

  9. jake said 9 days later:

    Hope its not dead, just bought learning bash yesterday

(leave url/email »)