parent
c70f3de119
commit
062cc1018d
|
@ -1,7 +1,7 @@
|
||||||
import os, commands, re, sets, tempfile
|
import os, commands, re, sets, tempfile
|
||||||
from subprocess import Popen, PIPE, STDOUT
|
from subprocess import Popen, PIPE, STDOUT
|
||||||
|
|
||||||
import buffer, default, dirutil, regex, util, window
|
import buffer, default, dirutil, lex, regex, util, window
|
||||||
from point import Point
|
from point import Point
|
||||||
|
|
||||||
from method import DATATYPES, Method, Argument, arg
|
from method import DATATYPES, Method, Argument, arg
|
||||||
|
@ -168,8 +168,6 @@ class CvsDiff3(Method):
|
||||||
w.set_error("Could not parse revision2: %r" % rev)
|
w.set_error("Could not parse revision2: %r" % rev)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
cwd = os.getcwd() + os.path.sep
|
cwd = os.getcwd() + os.path.sep
|
||||||
path = w.buffer.path
|
path = w.buffer.path
|
||||||
if path.startswith(cwd):
|
if path.startswith(cwd):
|
||||||
|
@ -184,6 +182,7 @@ class CvsDiff3(Method):
|
||||||
else:
|
else:
|
||||||
w.application.data_buffer("*Diff*", data, switch_to=True, modename='diff')
|
w.application.data_buffer("*Diff*", data, switch_to=True, modename='diff')
|
||||||
w.set_error("Differences were found")
|
w.set_error("Differences were found")
|
||||||
|
|
||||||
class CvsBlame(Method):
|
class CvsBlame(Method):
|
||||||
'''show blame output for the current version in SVN'''
|
'''show blame output for the current version in SVN'''
|
||||||
line_re = re.compile('^([0-9.]+) +\(*([a-zA-Z0-9_]+) +([-0-9A-Za-z]+)\): (.*)$')
|
line_re = re.compile('^([0-9.]+) +\(*([a-zA-Z0-9_]+) +([-0-9A-Za-z]+)\): (.*)$')
|
||||||
|
@ -223,3 +222,60 @@ class CvsBlame(Method):
|
||||||
w.application.data_buffer("*Blame*", data, switch_to=True, modename='blame')
|
w.application.data_buffer("*Blame*", data, switch_to=True, modename='blame')
|
||||||
else:
|
else:
|
||||||
w.set_error("There was an error (%s)" % (status))
|
w.set_error("There was an error (%s)" % (status))
|
||||||
|
class CvsBlame2(Method):
|
||||||
|
'''show blame output for the current version in SVN'''
|
||||||
|
line_re = re.compile('^([0-9.]+) +\(*([a-zA-Z0-9_]+) +([-0-9A-Za-z]+)\): (.*)$')
|
||||||
|
def _execute(self, w, **vargs):
|
||||||
|
if not hasattr(w.buffer, 'path'):
|
||||||
|
w.set_error("Buffer has no corresponding file")
|
||||||
|
return
|
||||||
|
|
||||||
|
cwd = os.getcwd() + os.path.sep
|
||||||
|
path = w.buffer.path
|
||||||
|
if path.startswith(cwd):
|
||||||
|
path = path[len(cwd):]
|
||||||
|
|
||||||
|
cmd = ("/usr/bin/cvs", 'annotate', path)
|
||||||
|
pipe = Popen(cmd, stdout=PIPE, stderr=PIPE)
|
||||||
|
|
||||||
|
linetokens = []
|
||||||
|
max_rev = 0
|
||||||
|
max_user = 0
|
||||||
|
for line in pipe.stdout:
|
||||||
|
m = self.line_re.match(line)
|
||||||
|
if not m:
|
||||||
|
raise Exception, line
|
||||||
|
(rev, user, date, content) = m.groups()
|
||||||
|
max_rev = max(max_rev, len(rev))
|
||||||
|
max_user = max(max_user, len(user))
|
||||||
|
linetokens.append([rev, user, date, content, []])
|
||||||
|
status = pipe.wait() >> 8
|
||||||
|
|
||||||
|
lines = [x[3] for x in linetokens]
|
||||||
|
if w.mode.grammar:
|
||||||
|
lexer = lex.Lexer(w.mode, w.mode.grammar)
|
||||||
|
lextokens = [[] for l in lines]
|
||||||
|
for t in lexer.lex(lines):
|
||||||
|
linetokens[t.y][4].append(t)
|
||||||
|
|
||||||
|
lines = []
|
||||||
|
for linetoken in linetokens:
|
||||||
|
(rev, user, date, content, lextokens) = linetoken
|
||||||
|
prefix = '[b:d:*]%-8s [c:d:*]%-10s [b:d:*]%10s[d:d:*]' % (rev, user, date)
|
||||||
|
if lextokens:
|
||||||
|
suffixes = []
|
||||||
|
for lt in lextokens:
|
||||||
|
s = lt.string.replace('\\', '\\\\')
|
||||||
|
s = s.replace('[', '\\[').replace(']', '\\]')
|
||||||
|
suffixes.append('[%s:%s:*]%s' % (lt.color[0], lt.color[1], s))
|
||||||
|
suffix = ''.join(suffixes)
|
||||||
|
else:
|
||||||
|
suffix = content + '\n'
|
||||||
|
lines.append('%s %s' % (prefix, suffix))
|
||||||
|
data = ''.join(lines)
|
||||||
|
|
||||||
|
status = pipe.wait() >> 8
|
||||||
|
if status == 0:
|
||||||
|
w.application.color_data_buffer("*Blame*", data, switch_to=True)
|
||||||
|
else:
|
||||||
|
w.set_error("There was an error (%s)" % (status))
|
||||||
|
|
|
@ -166,7 +166,7 @@ class SvnBlame(Method):
|
||||||
return
|
return
|
||||||
|
|
||||||
cmd = ("/usr/bin/svn", 'blame', '-v', w.buffer.path)
|
cmd = ("/usr/bin/svn", 'blame', '-v', w.buffer.path)
|
||||||
pipe = Popen(cmd, stdin=PIPE, stdout=PIPE)
|
pipe = Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE)
|
||||||
|
|
||||||
lines = []
|
lines = []
|
||||||
for line in pipe.stdout:
|
for line in pipe.stdout:
|
||||||
|
@ -192,7 +192,7 @@ class SvnBlame2(Method):
|
||||||
return
|
return
|
||||||
|
|
||||||
cmd = ("/usr/bin/svn", 'blame', '-v', w.buffer.path)
|
cmd = ("/usr/bin/svn", 'blame', '-v', w.buffer.path)
|
||||||
pipe = Popen(cmd, stdin=PIPE, stdout=PIPE)
|
pipe = Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE)
|
||||||
|
|
||||||
linetokens = []
|
linetokens = []
|
||||||
for line in pipe.stdout:
|
for line in pipe.stdout:
|
||||||
|
@ -222,7 +222,7 @@ class SvnBlame2(Method):
|
||||||
suffixes.append('[%s:%s:*]%s' % (lt.color[0], lt.color[1], s))
|
suffixes.append('[%s:%s:*]%s' % (lt.color[0], lt.color[1], s))
|
||||||
suffix = ''.join(suffixes)
|
suffix = ''.join(suffixes)
|
||||||
else:
|
else:
|
||||||
suffix = content
|
suffix = content + '\n'
|
||||||
lines.append('%s %s' % (prefix, suffix))
|
lines.append('%s %s' % (prefix, suffix))
|
||||||
data = ''.join(lines)
|
data = ''.join(lines)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue