Skip to content

Instantly share code, notes, and snippets.

@tahajahangir
Created June 13, 2012 03:10
Show Gist options
  • Save tahajahangir/2921583 to your computer and use it in GitHub Desktop.
Save tahajahangir/2921583 to your computer and use it in GitHub Desktop.
An samll mercurial extension to list lastest revision of each file
"""
To install this hg extenstion:
open /path/to/repo/.hg/hgrc
add this lines:
[extenstions]
lof=install/lof.py
"""
#http://selenic.com/pipermail/mercurial/2010-February/029951.html
#http://mercurial.selenic.com/wiki/MercurialApi
from mercurial import cmdutil, commands
from mercurial.i18n import _
import logging
def lof(ui, repo, node=None, rev=None, *pats, **opts):
if rev and node:
raise util.Abort(_("please specify just one revision"))
rev = node or rev or None # None is working directory
changectx = repo[rev]
try:
manifest = changectx.manifest()
displayer = cmdutil.show_changeset(ui, repo, opts)
for f in manifest:
try:
fctx = repo.filectx(f, fileid=manifest[f])
node = fctx.node()
ui.write('%s: ' % f)
displayer.show(repo[node])
except LookupError: # a modified file when rev=working directory
assert rev is None
except Exception:
logging.exception('Exception on file %s: ' % f)
pass
ext_opts = [('r', 'rev', None, _('revision'), _('REV')),
]
cmdtable = {
'lof': (lof, ext_opts + commands.templateopts, _('hg lof [[-r] rev] [OPTION]...'))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment