Link changeset hashes to main repo webpage

Issue #3373 resolved
Martin Geisler
created an issue

We use Bitbucket for code review where I work. So I very often go from a changeset in TortoiseHg to the changeset in Bitbucket to add a comment on it. It would be convenient if there was a link for this in TortoiseHg.

The feature is not tied to Bitbucket: just like you define URLs for arbitrary bug trackers, I'm imagining that one could define the target for changeset hashes.

I think a changeset hash in a commit message should keep linking internally in TortoiseHg. But when I am at a given changeset, the line with

Changeset: <revision number> (<hash>) <description>

could make the hash into a link to the main repository.

Comments (8)

  1. Martin Geisler reporter

    Turns out that it was easy enough to do for a single repository:

    diff --git a/tortoisehg/hgqt/ b/tortoisehg/hgqt/
    --- a/tortoisehg/hgqt/
    +++ b/tortoisehg/hgqt/
    @@ -111,8 +111,9 @@
         def link_markup(revnum, revid, enable=True):
             mrevid = revid_markup('%s (%s)' % (revnum, revid))
             if not enable:
    -            return mrevid
    -        link = 'cset:%s' % revid
    +            link = '' % revid
    +        else:
    +            link = 'cset:%s' % revid
             return '<a href="%s">%s</a>' % (link, mrevid)
         def revline_markup(revnum, revid, summary, highlight=None,
                            branch=None, link=True):

    Now I wonder how I could make this configurable... :-)

  2. Angel Ezquerra

    revpanel: add config to customize the target of cset links (fixes #3373)

    Issue #3373 suggests that it would be nice to be able to customize the changeset link on the revpanel so that it takes you go a web page for example.

    In order to do so, we introduce a tortoisehg/ config setting, which is a "template string" that serves as a template to generate the actual link URL.

    The template uses a mercurial "template like" syntax that currently accepts two template expressions: {node|short}, which is replaced by the 12 digit revision id, and {rev} which is the revision number. Note that {node}, by itself is NOT supported.

    For example:

    [tortoisehg] ={node|short}

    can be used to link cset links to their corresponding bitbucket commit page.

    Currently there is no GUI for this configuration option.

    → <<cset 05fa0020a921>>

  3. Log in to comment