Navigation

Introducing guess-renames

Wednesday, September 30th, 2009

Today I’m letting the world know about a little something I’ve been working on. It’s called guess-renames.

guess-renames solves a simple problem: Rename several files, either by hand or with a refactoring tool, and your version control system gets horribly confused and you have to spend 20 minutes running the same commands over and over again.1

No more. Now, just run guess-renames and presto, you’re up to date. No more commands to run, just commit. guess-renames is even smart enough to identify renamed files even if their contents differ slightly.

I’ve written a brief description of the algorithm — originally designed by Aaron Bentley for Bazaar — and I won’t reprint it here, but I do want to note just how smart this thing is: Aaron ran a test on the entire Launchpad source tree. First, he rewound the contents of each file 300 revisions; and then he renamed every single one. Except for empty files2, guess-renames was right 100% of the time. Maybe I’m just a dork, but to me that’s so incredibly huge.

This is seriously really cool stuff. I encourage you to take guess-renames for a spin.


  1. I mean, you’re using a version control system that tracks file renames, right? Right? 

  2. guess-renames works by looking at file contents, so empty files (in this case __init__.py files) don’t factor in to its algorithm. 

Comments

  1. Don Red replied on September 30th, 2009:

    That’s a pretty sick success rate, man. Well done.

  2. Evan replied on September 30th, 2009:

    Now just figure out a way to keep Xcode from freaking out when I reorganize my source files into subdirectories, and you’ll be my hero!

    FWIW, although git doesn’t technically track renames, it automatically detects renames on-the-fly when you blame & annotate (and can optionally do so for log & whatchanged), which are typically the only times I care. And it doesn’t require running a separate tool. ;)

  3. Evan replied on September 30th, 2009:

    (That said, nice work, very cool…)