Upstreaming patches to android-sync for people who like to pretend android-sync doesn’t exist

I find it rather irritating to have to keep manually upstreaming things to android-sync, and nobody seemed to have automated this.

Behold: a magical script for this. Unfortunately it uses mq, but it shouldn’t be a big deal to refactor it for less terrible ways of doing things.

So, you’ve written a patch that touches both Fennec and a-s code. You got it reviewed and now you’ve landed it on fx-team. It’s time to upstream the a-s changes, ideally before someone starts shouting at you for the merge failures you’ve created.

qpush the mixed patch, invoke the script, and copy-paste the pull request url it prints into bugzilla. It automagically sucks the a-s-specific stuff out of your patch, creates a branch named bug-$NUMBER_FROM_COMMIT_MESSAGE-$NAME_OF_PATCH_FILE with it and issues a pull request on a-s (leaving your original patch unchanged).

Prerequisites:

  • hub A wrapper script for Git that makes interacting with GitHub much nicer. If you use GitHub you should already be using this. `git pull-request` becomes a thing.
  • moz-git-tools A bunch of handy scripts for working with Git at Mozilla. All we want from it is hg-patch-to-git-patch. Make sure that script at least it on your path (or update my script to point to it wherever you put it).

Stick the script somewhere handy, make sure you set up the config variables at the top in the obvious way, and have fun.

In the event a patch doesn’t apply cleanly, you’ll have to go and manually fix it up in your local a-s repo using `git am` in the usual way, before continuing. The script pauses after trying to apply the patch so you have a chance to do this before it finishes up and publishes anything.

The script (apparently my blog mangles inline code rather horrifyingly):

https://www.dropbox.com/s/52eanocjrku4nrn/extractSync.sh?dl=0

Standard

Preventing mercurial from eating itself

Mercurial doesn’t seem to handle being interrupted particularly well. That, coupled with my tendency to hit ^C when I do something stupid leads to Mercurial ending up in an inconsistent state about once a week, causing me to manually restore my patch queue state with judicious use of `strip` (or otherwise).

I’ve just about had enough of this. A simple hack (that hopefully others will find useful) is to alias `hg` to a script containing:

hg “$@”&
wait

exit $!

Sort of evil hack, but does the job (provided you don’t kill the terminal you’re typing in: but I’m yet to meet someone who is suffering from reflexively executing `exit`. Now you can ^C Mercurial all you want and it will blithely ignore you. This seems preferable to it half-doing something, throwing a tantrum, and eating itself…

Standard