To expand on @gvalkov’s answer, you can make this a real extension by writing a file rheads.py
:
from mercurial import hg, commands, cmdutil, node
cmdtable = {}
command = cmdutil.command(cmdtable)
@command('rheads', commands.remoteopts, 'hg rheads [SOURCE]')
def rheads(ui, repo, source='default', **opts):
"""print (possibly remote) heads
Prints a series of lines consisting of hashes and branch names.
Specify a local or remote repository, defaulting to the configured remote.
"""
other = hg.peer(ui or repo, opts, ui.expandpath(source))
for tag, heads in other.branchmap().iteritems():
for h in heads:
ui.write("%s %s\n" % (node.short(h), tag))
When configured in ~/.hgrc
with
[extensions]
rheads = …/rheads.py
you can run it like:
hg rheads
I tried to make it a command that can be invoked outside any repository, just specifying the URL as an argument, but could not get the syntax to work:
commands.norepo += " rheads"