Skip to content

Instantly share code, notes, and snippets.

@jeansch
Created September 18, 2013 20:29
Show Gist options
  • Save jeansch/6615191 to your computer and use it in GitHub Desktop.
Save jeansch/6615191 to your computer and use it in GitHub Desktop.
Display flattened mercurial history.
#!/usr/bin/env python
# Display flattened mercurial history.
from mercurial import hg, ui
from datetime import datetime
uiface = ui.ui()
repo = hg.repository(uiface, '.')
ctxs = []
for r in repo.changelog.revs():
ctx = repo.changectx(r)
(d, unknown) = ctx.date()
ctxs.append((d, ctx))
for d, ctx in sorted(ctxs, key=lambda _ctx: _ctx[0]):
desc = ctx.description().split('\n')[0]
print "T:%s C:%s B:%s: U:%s D:%s" % (
datetime.fromtimestamp(d).ctime(), str(ctx),
ctx.branch(), ctx.user(), desc)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment