Created
June 13, 2012 03:10
-
-
Save tahajahangir/2921583 to your computer and use it in GitHub Desktop.
An samll mercurial extension to list lastest revision of each file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
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