Mercurial Extension for Gecko Development

July 22, 2013 at 10:27 AM | categories: Mercurial, Mozilla

My weekend was spent hacking on Mercurial extensions. First, I worked on porting the pushlog extension off SQLite. This will eventually enable Mozilla to move Mercurial hosting off NFS and should make hg.mozilla.org much faster as a result!

But the main purpose of this blog post is to introduce a new Mercurial extension I wrote this weekend!

Gecko developers perform a number of common tasks with Mercurial, so I thought it would be handy to package them up in an extension.

To install the extension:

hg clone https://hg.mozilla.org/hgcustom/version-control-tools

Then add this extension to your hgrc file (either the global or per-repository will suffice):

[extensions]
mozext = /path/to/version-control-tools/hgext/mozext

Since I believe tools should be self-documenting, run the following for usage info:

$ hg help mozext

Here are some examples:

# Clone mozilla-central into the mc directory.
hg clone central mc
hg clone mc mc

# Create a unified Mercurial repository containing changesets
# from all the release repositories.
hg cloneunified gecko

# Pull changes from the central and inbound repositories.
hg pull central
hg pull inbound

# Update the working tree to the tip of inbound.
hg up inbound/default

# View the tree open/closed status.
hg treestatus

# Show a list of all known trees and their aliases.
hg moztrees

# Open TBPL for the push containing a changeset.
hg tbpl inbound 821e984ef423
hg tbpl inbound inbound/default

# Push the tip of inbound to mozilla-central
hg pushtree -r inbound/default central

I've only tested this extension with Mercurial 2.6 (which every Mozilla developer should be running). I'm not willing to support older versions. Upgrade already!

There are a number of features I'd like to implement:

  • hg importtry - Automatically import changesets for a Try push into the repository.
  • hg land - Automatically land patches on an integration tree (like inbound). Will handle rebasing automatically.
  • hg critic - Perform stlye checking and other analysis on a changeset or group of changesets.
  • Ability to integrate build status into changeset info. This will allow things such as pull only the last green changeset. I'd also like a build status field to appear in the log output. Unfortunately, I believe the latency of the build lookup API is prohibitively high to perform the kind of tight integration I'd like.
  • Move mozautomation Python package into a standalone package or integrate already existing code (did I reinvent the wheel?).
  • Log fetching. Specify a changeset and fetch build/test logs.
  • Possibly move code into mozilla-central.
  • Possibly add mach commands for some of this functionality.

There's no bug component for this extension (yet). If you find any issues or wish to add a feature, just email a patch to me at gps@mozilla.com.

Please let me know if you find this useful or if you have any questions.