Keeping track of MQ patchsets…

Hey Everyone!

First some brief Background, Mozilla Releng has our code in a *lot* of repos, most being in Mercurial (a few other needs are in git or svn, but those are very rare relatively). I also do work for SeaMonkey which has needs with m-c, m-i, m-*, c-c, c-* etc. And needs with l10n

I personally manage all my patches with MQ. Which presents a problem for me, “keeping track of it all”. I used to try keeping open bugs, but thats hard with releng because while a bug may be open, we tend to have a good handful of patches attached to it, for various repos, and they need to land in certain orders sometimes.

Other ways I’ve tried to cope have been with landing as soon as the review comes in and avoiding writing patches for parts that need to land later until the first parts are landed/deployed. I found that method encompasses unneeded end-to-end times on bugs, and unnecessary context-switching.

To curb that I wrote a mozilla-build (bash) script [in ~/.bash_profile ] that sets an alias `patchset` that I run, and it works!

It especially works because I keep my code in /c/Sources/hg/* some repos are multi-levels deep, so this code could/should be improved or at least edited for your uses, but without further ado, this is how I manage my patchset (again note, all my work is in Mercurial, I do convert my stuff over to git/etc as needed though):

EDIT: I forgot to give credit for my normalize_path() implemented I stole Borrowed from http://www.linuxjournal.com/content/normalizing-path-names-bash

Provided as-is, without alteration (again cleanups likely):

function normalize_path()
{
    # Remove all /./ sequences.
    local   path=${1//\/.\//\/}

    # Remove first dir/.. sequence.
    local   npath=$(echo $path | sed -e 's;[^/][^/]*/\.\./;;')

    # Remove remaining dir/.. sequence.
    while [[ $npath != $path ]]
    do
        path=$npath
        npath=$(echo $path | sed -e 's;[^/][^/]*/\.\./;;')
    done
    path=$npath
    npath=$(echo $path | sed -e 's;[^/][^/]*/\.\.$;;')
    echo $npath
}

function patchset() {
    pushd /c/Sources/hg >/dev/null
    for i in `find . -maxdepth 2 ! \( -name l10n -prune \) -a -name .hg`;
      do
        pushd $i/.. >/dev/null;
        if [ `hg --config color.mode=auto qseries | wc -l` != 0 ]; then
            echo -n "======= "; echo -n $(normalize_path $i/..); echo " =====";
            hg qseries;
        fi
        popd >/dev/null;
    done
    for i in `find ./users -maxdepth 3 -name .hg`;
      do
        pushd $i/.. >/dev/null;
        if [ `hg --config color.mode=auto qseries | wc -l` != 0 ]; then
            echo -n "======= "; echo -n $(normalize_path $i/..); echo " =====";
            hg qseries;
        fi
        popd >/dev/null;
    done
    for i in `find ./l10n -maxdepth 3 -name .hg`;
      do
        pushd $i/.. >/dev/null;
        if [ `hg --config color.mode=auto qseries | wc -l` != 0 ]; then
            echo -n "======= "; echo -n $(normalize_path $i/..); echo " =====";
            hg qseries;
        fi
        popd >/dev/null;
    done
    popd >/dev/null
}

And the output of that, as it stands for me _today_:

Justin@AQUARIUS /c/Sources/hg/mozharness
$ patchset
======= ./braindump/ =====
seamonkey-bouncer
======= ./buildbot-configs/ =====
ionmonkey
======= ./buildbotcustom/ =====
ionmonkey
======= ./mozharness/ =====
ionmonkey
======= ./slaveapi/ =====
timestamp
docs

Lastly my qty of repos:

$ pushd /c/Sources/hg
/c/Sources/hg /c/Sources/hg/mozharness

Justin@AQUARIUS /c/Sources/hg
$ find . -maxdepth 2 ! \( -name l10n -prune \) -a -name .hg | wc -l
17

Justin@AQUARIUS /c/Sources/hg
$ find ./users -maxdepth 3 -name .hg | wc -l
19

Justin@AQUARIUS /c/Sources/hg
$ find ./l10n -maxdepth 3 -name .hg | wc -l
52

Hope this helps!

This entry was posted in Mozilla. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>