diff --git a/method/hg.py b/method/hg.py index 0399c2f..17e56ea 100644 --- a/method/hg.py +++ b/method/hg.py @@ -1,7 +1,9 @@ +import os +import re from subprocess import Popen, PIPE, STDOUT + from method import Method, Argument from method.vc import VcBlame -import re try: from mercurial import hg, ui @@ -20,31 +22,23 @@ class HgBase(object): return False else: return True - def _hg_init(self): - ui_imp = ui.ui(verbose=True) + def _hg_init(self, **kwargs): + ui_imp = ui.ui(**kwargs) ui_imp.pushbuffer() repo = hg.repository(ui=ui_imp, path='.') return ui_imp, repo class HgBlame(VcBlame, HgBase): """Show buffer annotated with hg metadata""" - line_re = re.compile(r'^ *(?P[^ ]+) (?P\d+) (?P\d{4}-\d{2}-\d{2}): (?P.*)\n$') - prefix_fmt = '[b:d:*]%(rev)-5s [c:d:*]%(user)-10s [b:d:*]%(date)10s[d:d:*]' + num_fields = 3 + # user, rev, [changeset], date, content + line_re = re.compile(r'^ *([^ ]+) +(\d+) +[^ ]+ +(\d{4}-\d{2}-\d{2}): (.*)\n$') + prefix_fmt = '[g:d:*]%*s [c:d:*]%*s [b:d:*]%*s[d:d:*]' _is_method = True def _open_pipe(self, w, **vargs): - cmd = ("hg", 'blame', '-nudq', w.buffer.path) + cmd = ("hg", 'blame', '-cnudq', w.buffer.path) return Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE) -class HgBlame2(Method, HgBase): - def _execute(self, w, **vargs): - if not self._hg_check(w): - return - ui_imp, repo = self._hg_init() - hgc.identify(ui_imp, repo, w.buffer.path) - hgc.annotate(ui_imp, repo, w.buffer.path, user=None, date=None, rev=None) - s = ''.join(ui_imp.popbuffer()) - w.application.data_buffer('*Blame*', s, switch_to=True) - class HgLog(Method, HgBase): """Show hg log for this buffer""" def _execute(self, w, **vargs): diff --git a/method/svn.py b/method/svn.py index 88f7cce..402ec59 100644 --- a/method/svn.py +++ b/method/svn.py @@ -264,10 +264,12 @@ class SvnDiff3(Method): class SvnBlame(VcBlame): '''show blame output for the current version in SVN''' - line_re = re.compile('^ *(?P\d+) *(?P[a-zA-Z0-9_]+) *(?P[-0-9]+) *(?P