created svn-log and fixed method help for search-insert-*

--HG--
branch : pmacs2
This commit is contained in:
moculus 2008-04-16 05:27:52 +00:00
parent e9786b09f8
commit 5f4190b69b
2 changed files with 43 additions and 1 deletions

View File

@ -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):

View File

@ -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()