Writing Mercurial plugins
Getting my feet wet with writing some Mercurial plugins... First glance is that the API is very low-level, but I guess that makes sense since HG (and its plugins) have to be low-level to perform well.
Part of me just wants to scrape the text of the different subcommands.
#!/usr/bin/env python from mercurial import hg from binascii import hexlify from mercurial import util def interact(ui, repo, **opts): """poke around the mercurial API for this repo in a python interpreter""" print "Locals are:", dir() import code; code.interact(local=locals()) def short_incoming(ui, repo, **opts): """Shows a shortened form of 'hg incoming'""" default = hg.repository(ui, ui.expandpath('default')) inc = repo.findincoming(default) nodes = default.changelog.nodesbetween(inc, None)[0] for node in nodes: cs = default.changelog.read(node) print hexlify(cs[0])[:6], '|', cs[1], '|', util.datestr(cs[2]), \ '|', len(cs[3]), 'files', '|', cs[5], '|', cs[4] cmdtable = { "interact": ( interact, [], interact.__doc__ ), "short": ( short_incoming, [], short_incoming.__doc__ ), }