diff --git a/method/hg.py b/method/hg.py index 945b84f..f30c759 100644 --- a/method/hg.py +++ b/method/hg.py @@ -6,7 +6,7 @@ from method import Method, Argument from method.vc import VcBlame try: - from mercurial import hg, ui + from mercurial import hg, ui, node from mercurial import commands as hgc has_hg = True except ImportError: @@ -49,6 +49,23 @@ class HgLog(Method, HgBase): s = ''.join(ui_imp.popbuffer()) w.application.data_buffer('*Log*', s, switch_to=True) +class HgInfo(Method, HgBase): + """Get some basic info from Mercurial about the current buffer""" + def _execute(self, w, **vargs): + if not self._hg_check(w): + return + base = os.path.basename(w.buffer.path) + ui_imp, repo = self._hg_init() + path = w.buffer.path.replace(os.getcwd() + '/', '') + l = repo.file(path) + status = 'Unknown' + rev = l.linkrev(l.rev(l.tip())) + ctx = repo[rev] + changeid = node.hex(ctx.node()[:6]) + user = ui_imp.shortuser(ctx.user()) + msg = '%s %s %s:%s [%s]' % (base, status, rev, changeid, user) + w.set_error(msg) + class HgDiff(Method, HgBase): """Diff the current file with the version in Mercurial""" def _get_revs(self, w, **vargs):