Even easier backouts from the trees

Some time ago I posted a simple shell script to automate trivial backouts, using the method suggested by Ehsan Akhgari and improved by Daniel Holbert.

I used that script multiple times, as well as others, and I got lot of feedback on issues:

  • It was made of 2 separate functions
  • The functions had ugly names, to remember the correct order of arguments
  • Passing bogus changesets could generate empty backout patches
  • the commit message was missing the bug numbers

All of these issues are solvable, and since I'm still a noob at shell scripting, I decided to try again and fix them (as I previously stated, this could be better made as an hg extension).

The new version is a bit larger, so I posted it into my wiki user page for now:

  • it is a single function, called backout. You can pass to it a list of changesets or ranges, as:
    • backout dddddddddddd:bbbbbbbbbbbb aaaaaaaaaaaa (will backout aaaaaaaaaaaa and everything between bbbbbbbbbbbb and dddddddddddd extremes included)
  • The function figures by itself the correct order of the changesets
  • if, by chance, an empty backout is generated, it will bail out and notify you
  • the commit message includes the list of all the changesets and, if a bug number is found, it will be added near its changeset

Finally, something that did not change from previous version:

  • This doesn't merge. Instead it generates a mercurial queue patch, called backout.diff. You can check the contents of the patch before pushing it. Then you can just hg qfin -a && hg push. You can even just qdelete it, if you are not satisfied.
  • it assumes you don't have uncommitted changes in the tree. If you have any, they'll be lost. So be sure you have qref the qtop patch, before proceeding.
  • If it can't solve a conflict (usually with a later conflicting patch) it will bail out. Complicate backouts should still be done manually. Though, in the last 6 months, I only saw a couple of those.
  • It will try to open the editor you set in your hg config, to change the backout message.
  • To use the script, just add it to your .profile. Even on Windows, if you use MozillaBuild, you can add a .profile in C:/Users/your_username (or whatever your profile folder is) and restart the MozillaBuild shell.

Finally, I want to thank Ed Morley, for helping me with testing and feedback. He uses the script almost everyday on Inbound and Central, that's a good testing field!

Now, go grab it if you wish, feedback and suggestions are welcome!

MaK Martedì 22 Novembre 2011 at 4:14 pm | | Mozilla-EN