More stupid mercurial tricks

I think I’m missing something. How do people get those changeset URLs to paste into bugs? Ok, if I’m landing on mozilla-central or a project branch, I just get it from tbpl since I’ll be staring at it anyway. But what about some other repo? Like, say, ssh://hg.mozilla.org/users/mstange_themasta.com/tinderboxpushlog?

As usual, I coded my way around the problem before asking the question, which is stupid and backwards. But just in case there really isn’t a good way, here’s my silly hackaround. Put this in the [alias] section of your ~/.hgrc then, after landing a change, do ‘hg urls -l 3’ or similar. (That’ll give you the latest 3 changesets):

  urls = !$HG log --template='{node|short} {desc|firstline}\n' ${HG_ARGS/urls /} | perl -lpe 'BEGIN { ($url = shift) =~ s/^\w+/http/ }; s!^(?=\w+)!$url/rev/!' `hg path default`

Picking that apart, it removes the misfeature that $HG_ARGS contains the command you’re running, then passes the remaining command line to hg log with a template set to just print out the changeset shorthash and the first line of the commit message. It sends that and the URL of the default upstream repo through a perl command that rewrites the hg log output to “/rev/ “. Oh, it changes the first part of the repo URL to http because my test case is actually an SSH url and there just happens to be an HTTP server at the same url.

A mess, but it works for me.

And yes, I should switch to a blog that isn’t hostile to code. Sorry about that line up there.

Tags: , ,

3 comments

  1. My two usual habits:

    copy/paste from hg.mozilla.org/{repo} or tbpl.

    *or*

    hg out –template=’http://hg.mozilla.org/{repo-manually-typed}/rev/{node|short}’

    and copy/paste that.

    I never include checkin comment in bugs I push, just the link to cset.

  2. I type “mst pu” in the addressbar, which autocompletes to http://hg.mozilla.org/users/mstange_themasta.com/tinderboxpushlog/pushloghtml

    But your method is nice, too 🙂

  3. Colby Russell

    Huh? Besides just going to the tinderboxpushlog repo page and copying the diff link?

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.