From 9d4dd2c2d861a27fd1d99a84327d9b9358773081 Mon Sep 17 00:00:00 2001 From: Erik Osheim Date: Sun, 10 May 2009 02:01:09 -0400 Subject: [PATCH] fix bugs in vc-blame and create hg-blame --HG-- branch : pmacs2 --- method/hg.py | 17 ++++++++++++----- method/vc.py | 4 +++- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/method/hg.py b/method/hg.py index acab4a1..b4e4478 100644 --- a/method/hg.py +++ b/method/hg.py @@ -1,10 +1,17 @@ -from method import Method, Argument +from subprocess import Popen, PIPE, STDOUT -class HgBlame(Method): +from method import Method, Argument +from method.vc import VcBlame +import re + +class HgBlame(VcBlame): """Show buffer annotated with hg metadata""" - # use hg blame -udq FILE - def _execute(self, w, **vargs): - w.set_error("unimplemented") + 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:*]' + _is_method = True + def _open_pipe(self, w, **vargs): + cmd = ("hg", 'blame', '-nudq', w.buffer.path) + return Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE) class HgLog(Method): """Show hg log for this buffer""" diff --git a/method/vc.py b/method/vc.py index 59dbe2a..7f6609f 100644 --- a/method/vc.py +++ b/method/vc.py @@ -3,6 +3,8 @@ import buffer.color import util import lex +class VcException(Exception): pass + class VcBlame(Method): _is_method = False line_re = None @@ -10,7 +12,7 @@ class VcBlame(Method): def _filter(self, line): m = self.line_re.match(line) if not m: - raise SvnException("couldn't parse %r" % line) + raise VcException("couldn't parse %r" % line) return m.groupdict() def _open_pipe(self, w, **vargs): raise Exception('unimplemented')