diff --git a/method/svn.py b/method/svn.py index 631b0bd..c4103f3 100644 --- a/method/svn.py +++ b/method/svn.py @@ -77,6 +77,48 @@ class SvnStatus(Method): raise Exception, '%r %r' % (fields, data[6:]) w.set_error('%s %s %s/%s [%s]' % (filename, status, rrev, lrev, lauthor)) + +class SvnLog(Method): + '''display the SVN log for the current file''' + sep_re = re.compile('^-+$') + # 2007-10-15 14:32:29 -0400 (Mon, 15 Oct 2007) + log_re = re.compile('(.+?) \| (.+?) \| (.{25}) .+? \| (.+)$') + def _build_entry(self, log_line, mesg_lines): + log_data = '[c:d:*]%s [g:d:*]%s [b:d:*]%s [c:d:*]%s' % log_line + mesg_data = '\n'.join(mesg_lines).strip() + if mesg_data: + mesg_data += '\n' + return '[b:d:*]' + log_data + '\n' + mesg_data + def _execute(self, w, **vargs): + cmd = "svn log %r" % w.buffer.path + (status, data) = commands.getstatusoutput(cmd) + + entries = [] + log_line, mesg_lines = None, [] + for line in data.split('\n'): + if self.sep_re.match(line): + if log_line is not None: + entries.append(self._build_entry(log_line, mesg_lines)) + log_line = None + else: + m = self.log_re.match(line) + if m: + log_line = m.groups() + mesg_lines = [] + else: + assert log_line is not None, '%r %r' % (entries, line) + mesg_lines.append(line) + data2 = ''.join(entries) + + if status == 0 and data: + w.application.color_data_buffer("*Log*", data2, switch_to=True) + w.set_error("%s: logfile" % self.name) + elif status == 0: + w.set_error("%s: There was no data" % self.name) + else: + w.set_error("%s: There was an error (%s)" % (self.name, status)) + + class SvnDiff(Method): '''diff the current file with the version in SVN''' def _execute(self, w, **vargs): diff --git a/mode/search.py b/mode/search.py index 66d24ff..42ee8b9 100644 --- a/mode/search.py +++ b/mode/search.py @@ -115,7 +115,7 @@ class InsertSearchString(method.Method): self.name = 'insert-search-string-%s' % (s) self.string = s self.args = [] - self.help = None + self.help = '' def execute(self, w, **vargs): w.insert_string_at_cursor(self.string) s = w.buffer.make_string()