parent
6a5220d838
commit
7543e3f19e
|
@ -118,10 +118,13 @@ class Application(object):
|
||||||
|
|
||||||
# initialize our methods
|
# initialize our methods
|
||||||
self.methods = {}
|
self.methods = {}
|
||||||
for name in dir(method):
|
for name in ('method', 'method.svn', 'method.cvs'):
|
||||||
cls = eval("method.%s" % name)
|
exec("import %s" % name)
|
||||||
if hasattr(cls, '_is_method') and cls._is_method:
|
mod = eval(name)
|
||||||
self.methods[cls._name()] = cls()
|
for mname in dir(mod):
|
||||||
|
cls = eval("%s.%s" % (name, mname))
|
||||||
|
if hasattr(cls, '_is_method') and cls._is_method:
|
||||||
|
self.methods[cls._name()] = cls()
|
||||||
|
|
||||||
# create all the insert methods for the character ranges we like
|
# create all the insert methods for the character ranges we like
|
||||||
for c in string.letters + string.digits + string.punctuation:
|
for c in string.letters + string.digits + string.punctuation:
|
||||||
|
|
|
@ -1105,399 +1105,6 @@ class FileDiff(Method):
|
||||||
w.application.data_buffer("*Diff*", errdata, switch_to=True)
|
w.application.data_buffer("*Diff*", errdata, switch_to=True)
|
||||||
w.set_error("There was an error: %d exited with status %s" % (pid, status))
|
w.set_error("There was an error: %d exited with status %s" % (pid, status))
|
||||||
|
|
||||||
class SvnCommit(Method):
|
|
||||||
'''diff the current file with the version in SVN'''
|
|
||||||
args = [Argument("msg", type=type(""), prompt="Commit Message: ")]
|
|
||||||
regex = re.compile(r'^Committed revision ([0-9]+)\.$')
|
|
||||||
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 = "svn ci -m %r %r" % (vargs['msg'], path)
|
|
||||||
(status, data) = commands.getstatusoutput(cmd)
|
|
||||||
status = status >> 8
|
|
||||||
lines = data.split('\n')
|
|
||||||
|
|
||||||
if status == 0:
|
|
||||||
try:
|
|
||||||
for line in lines:
|
|
||||||
m = self.regex.match(line)
|
|
||||||
if m:
|
|
||||||
w.set_error("Committed [%s]" % (m.group(1)))
|
|
||||||
return
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
w.set_error("Problems with SVN commit: %d" % status)
|
|
||||||
w.application.data_buffer("*Commit*", repr(lines), switch_to=True)
|
|
||||||
|
|
||||||
class SvnStatus(Method):
|
|
||||||
column = {
|
|
||||||
' ': 'Unmodified',
|
|
||||||
'A': 'Added',
|
|
||||||
'C': 'Conflicted',
|
|
||||||
'D': 'Deleted',
|
|
||||||
'I': 'Ignored',
|
|
||||||
'M': 'Modified',
|
|
||||||
'R': 'Replaced',
|
|
||||||
'X': 'External',
|
|
||||||
'?': 'Unknown',
|
|
||||||
'!': 'Missing',
|
|
||||||
'~': 'Obstructed',
|
|
||||||
}
|
|
||||||
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 = "svn status -v %r" % path
|
|
||||||
(status, data) = commands.getstatusoutput(cmd)
|
|
||||||
status = status >> 8
|
|
||||||
|
|
||||||
if status != 0:
|
|
||||||
w.set_error("Problems with 'svn status': %d" % status)
|
|
||||||
return
|
|
||||||
|
|
||||||
c = data[0]
|
|
||||||
status = self.column.get(c, 'Error (%s)' % c)
|
|
||||||
fields = data[6:].split()
|
|
||||||
try:
|
|
||||||
(rrev, lrev, lauthor, filename) = fields
|
|
||||||
except:
|
|
||||||
raise Exception, '%r %r' % (fields, data[6:])
|
|
||||||
|
|
||||||
w.set_error('%s %s %s/%s [%s]' % (filename, status, rrev, lrev, lauthor))
|
|
||||||
class SvnDiff(Method):
|
|
||||||
'''diff the current file with the version in SVN'''
|
|
||||||
def _execute(self, w, **vargs):
|
|
||||||
if not hasattr(w.buffer, 'path'):
|
|
||||||
w.set_error("Buffer has no corresponding file")
|
|
||||||
return
|
|
||||||
|
|
||||||
cmd = "svn diff %r" % w.buffer.path
|
|
||||||
(status, data) = commands.getstatusoutput(cmd)
|
|
||||||
|
|
||||||
if status == 0:
|
|
||||||
if data:
|
|
||||||
w.application.data_buffer("*Diff*", data, switch_to=True, modename='diff')
|
|
||||||
w.set_error("Differences were found")
|
|
||||||
else:
|
|
||||||
w.set_error("No difference found")
|
|
||||||
else:
|
|
||||||
w.set_error("There was an error (%s)" % (status))
|
|
||||||
class SvnDiff2(Method):
|
|
||||||
'''diff the current file with the version in SVN'''
|
|
||||||
rev_regex = re.compile('^[0-9]+$')
|
|
||||||
args = [Argument("revision", type=type(""), prompt="Old Revision: ")]
|
|
||||||
def _execute(self, w, **vargs):
|
|
||||||
if not hasattr(w.buffer, 'path'):
|
|
||||||
w.set_error("Buffer has no corresponding file")
|
|
||||||
return
|
|
||||||
|
|
||||||
rev = vargs['revision']
|
|
||||||
if not self.rev_regex.match(rev):
|
|
||||||
w.set_error("Could not parse revision: %r" % rev)
|
|
||||||
return
|
|
||||||
|
|
||||||
cwd = os.getcwd() + os.path.sep
|
|
||||||
path = w.buffer.path
|
|
||||||
if path.startswith(cwd):
|
|
||||||
path = path[len(cwd):]
|
|
||||||
|
|
||||||
cmd = "svn diff -r %s %r" % (rev, path)
|
|
||||||
(status, data) = commands.getstatusoutput(cmd)
|
|
||||||
status = status >> 8
|
|
||||||
|
|
||||||
if data:
|
|
||||||
w.application.data_buffer("*Diff*", data, switch_to=True, modename='diff')
|
|
||||||
w.set_error("Differences were found")
|
|
||||||
else:
|
|
||||||
w.set_error("No difference found")
|
|
||||||
class SvnDiff3(Method):
|
|
||||||
'''diff the current file with the version in SVN'''
|
|
||||||
rev_regex = re.compile('^[0-9]+$')
|
|
||||||
args = [Argument("revision1", type=type(""), prompt="Old Revision: "),
|
|
||||||
Argument("revision2", type=type(""), prompt="New Revision: ")]
|
|
||||||
def _execute(self, w, **vargs):
|
|
||||||
if not hasattr(w.buffer, 'path'):
|
|
||||||
w.set_error("Buffer has no corresponding file")
|
|
||||||
return
|
|
||||||
|
|
||||||
rev1 = vargs['revision1']
|
|
||||||
if not self.rev_regex.match(rev1):
|
|
||||||
w.set_error("Could not parse revision1: %r" % rev)
|
|
||||||
return
|
|
||||||
|
|
||||||
rev2 = vargs['revision2']
|
|
||||||
if not self.rev_regex.match(rev2):
|
|
||||||
w.set_error("Could not parse revision2: %r" % rev)
|
|
||||||
return
|
|
||||||
|
|
||||||
cwd = os.getcwd() + os.path.sep
|
|
||||||
path = w.buffer.path
|
|
||||||
if path.startswith(cwd):
|
|
||||||
path = path[len(cwd):]
|
|
||||||
|
|
||||||
cmd = "svn diff -r %s -r %s %r" % (rev1, rev2, path)
|
|
||||||
(status, data) = commands.getstatusoutput(cmd)
|
|
||||||
status = status >> 8
|
|
||||||
|
|
||||||
if data:
|
|
||||||
w.application.data_buffer("*Diff*", data, switch_to=True, modename='diff')
|
|
||||||
w.set_error("Differences were found")
|
|
||||||
else:
|
|
||||||
w.set_error("No difference found")
|
|
||||||
class SvnBlame(Method):
|
|
||||||
'''show blame output for the current version in SVN'''
|
|
||||||
line_re = re.compile('^ *(\d+) *([a-zA-Z0-9_]+) *([-0-9]+) *([:0-9]+) *(-\d{4}) *\(([^\)]+)\) (.*)$')
|
|
||||||
def _execute(self, w, **vargs):
|
|
||||||
if not hasattr(w.buffer, 'path'):
|
|
||||||
w.set_error("Buffer has no corresponding file")
|
|
||||||
return
|
|
||||||
|
|
||||||
cmd = ("/usr/bin/svn", 'blame', '-v', w.buffer.path)
|
|
||||||
pipe = Popen(cmd, stdin=PIPE, stdout=PIPE)
|
|
||||||
|
|
||||||
lines = []
|
|
||||||
for line in pipe.stdout:
|
|
||||||
m = self.line_re.match(line)
|
|
||||||
if not m:
|
|
||||||
raise Exception, line
|
|
||||||
(rev, user, date, t, tz, vdate, content) = m.groups()
|
|
||||||
lines.append("%-4s %-10s %10s %s\n" % (rev, user, date, content))
|
|
||||||
data = ''.join(lines)
|
|
||||||
|
|
||||||
status = pipe.wait() >> 8
|
|
||||||
if status == 0:
|
|
||||||
w.application.data_buffer("*Blame*", data, switch_to=True, modename='blame')
|
|
||||||
else:
|
|
||||||
w.set_error("There was an error (%s)" % (status))
|
|
||||||
|
|
||||||
class CvsCommit(Method):
|
|
||||||
'''diff the current file with the version in CVS'''
|
|
||||||
args = [Argument("msg", type=type(""), prompt="Commit Message: ")]
|
|
||||||
regex = re.compile('^new revision: ([0-9.]+); previous revision: ([0-9.]+)$')
|
|
||||||
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 = "cvs ci -m %r %r" % (vargs['msg'], path)
|
|
||||||
(status, data) = commands.getstatusoutput(cmd)
|
|
||||||
status = status >> 8
|
|
||||||
lines = data.split('\n')
|
|
||||||
|
|
||||||
if status == 0:
|
|
||||||
for line in lines:
|
|
||||||
m = self.regex.match(line)
|
|
||||||
if m:
|
|
||||||
w.set_error("Committed [%s -> %s]" % (m.group(2), m.group(1)))
|
|
||||||
return
|
|
||||||
w.set_error("Up-to-date")
|
|
||||||
else:
|
|
||||||
w.set_error("Problems with CVS commit: %d" % status)
|
|
||||||
w.application.data_buffer("*Commit*", data, switch_to=True)
|
|
||||||
|
|
||||||
class CvsStatus(Method):
|
|
||||||
regex1 = re.compile('^File: (.+?) *\tStatus: (.*?)$')
|
|
||||||
regex2 = re.compile('^ Working revision:\t([0-9\.]+)$')
|
|
||||||
regex3 = re.compile('^ Repository revision:\t([0-9\.]+)\t(.*)$')
|
|
||||||
regex4 = re.compile('^ Sticky Tag:\t\t\((.*)\)$')
|
|
||||||
regex5 = re.compile('^ Sticky Date:\t\t\((.*)\)$')
|
|
||||||
regex6 = re.compile('^ Sticky Options:\t\((.*)\)$')
|
|
||||||
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 = "cvs status %r" % path
|
|
||||||
(status, data) = commands.getstatusoutput(cmd)
|
|
||||||
status = status >> 8
|
|
||||||
|
|
||||||
if status != 0:
|
|
||||||
w.set_error("Problems with CVS status: %d" % status)
|
|
||||||
return
|
|
||||||
|
|
||||||
lines = data.split('\n')
|
|
||||||
|
|
||||||
if lines[0].startswith('cvs status: nothing known about '):
|
|
||||||
w.set_error('File is not under CVS control')
|
|
||||||
return
|
|
||||||
|
|
||||||
m = self.regex1.match(lines[1])
|
|
||||||
assert m, "regex1 %r" % lines[1]
|
|
||||||
ffile = m.group(1)
|
|
||||||
fstatus = m.group(2)
|
|
||||||
|
|
||||||
m = self.regex2.match(lines[3])
|
|
||||||
assert m, "regex2 %r" % lines[3]
|
|
||||||
wrev = m.group(1)
|
|
||||||
|
|
||||||
m = self.regex3.match(lines[4])
|
|
||||||
assert m, "regex3 %r" % lines[4]
|
|
||||||
rrev = m.group(1)
|
|
||||||
rpath = m.group(2)
|
|
||||||
|
|
||||||
m = self.regex4.match(lines[5])
|
|
||||||
assert m, "regex4 %r" % lines[5]
|
|
||||||
stag = m.group(1)
|
|
||||||
|
|
||||||
m = self.regex5.match(lines[6])
|
|
||||||
assert m, "regex5 %r" % lines[6]
|
|
||||||
sdate = m.group(1)
|
|
||||||
|
|
||||||
m = self.regex6.match(lines[7])
|
|
||||||
assert m, "regex6 %r" % lines[7]
|
|
||||||
soptions = m.group(1)
|
|
||||||
|
|
||||||
w.set_error('%s %s %s/%s [%s|%s|%s]' % (ffile, fstatus,
|
|
||||||
wrev, rrev, stag,
|
|
||||||
sdate, soptions))
|
|
||||||
|
|
||||||
class CvsDiff(Method):
|
|
||||||
'''diff the current file with the version in CVS'''
|
|
||||||
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 = "cvs diff -u %r" % path
|
|
||||||
(status, data) = commands.getstatusoutput(cmd)
|
|
||||||
status = status >> 8
|
|
||||||
|
|
||||||
if status == 0:
|
|
||||||
w.set_error("No difference found")
|
|
||||||
else:
|
|
||||||
w.application.data_buffer("*Diff*", data, switch_to=True, modename='diff')
|
|
||||||
w.set_error("Differences were found")
|
|
||||||
class CvsDiff2(Method):
|
|
||||||
'''diff the current file with the version in CVS'''
|
|
||||||
rev_regex = re.compile('^[0-9]+\.[0-9]+$')
|
|
||||||
args = [Argument("revision", type=type(""), prompt="Old Revision: ")]
|
|
||||||
def _execute(self, w, **vargs):
|
|
||||||
if not hasattr(w.buffer, 'path'):
|
|
||||||
w.set_error("Buffer has no corresponding file")
|
|
||||||
return
|
|
||||||
|
|
||||||
rev = vargs['revision']
|
|
||||||
if not self.rev_regex.match(rev):
|
|
||||||
w.set_error("Could not parse revision: %r" % rev)
|
|
||||||
return
|
|
||||||
|
|
||||||
cwd = os.getcwd() + os.path.sep
|
|
||||||
path = w.buffer.path
|
|
||||||
if path.startswith(cwd):
|
|
||||||
path = path[len(cwd):]
|
|
||||||
|
|
||||||
cmd = "cvs diff -r %s -u %r" % (rev, path)
|
|
||||||
(status, data) = commands.getstatusoutput(cmd)
|
|
||||||
status = status >> 8
|
|
||||||
|
|
||||||
if status == 0:
|
|
||||||
w.set_error("No difference found")
|
|
||||||
else:
|
|
||||||
w.application.data_buffer("*Diff*", data, switch_to=True, modename='diff')
|
|
||||||
w.set_error("Differences were found")
|
|
||||||
class CvsDiff3(Method):
|
|
||||||
'''diff the current file with the version in CVS'''
|
|
||||||
rev_regex = re.compile('^[0-9]+\.[0-9]+$')
|
|
||||||
args = [Argument("revision1", type=type(""), prompt="Old Revision: "),
|
|
||||||
Argument("revision2", type=type(""), prompt="New Revision: ")]
|
|
||||||
def _execute(self, w, **vargs):
|
|
||||||
if not hasattr(w.buffer, 'path'):
|
|
||||||
w.set_error("Buffer has no corresponding file")
|
|
||||||
return
|
|
||||||
|
|
||||||
rev1 = vargs['revision1']
|
|
||||||
if not self.rev_regex.match(rev1):
|
|
||||||
w.set_error("Could not parse revision1: %r" % rev)
|
|
||||||
return
|
|
||||||
|
|
||||||
rev2 = vargs['revision2']
|
|
||||||
if not self.rev_regex.match(rev2):
|
|
||||||
w.set_error("Could not parse revision2: %r" % rev)
|
|
||||||
return
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
cwd = os.getcwd() + os.path.sep
|
|
||||||
path = w.buffer.path
|
|
||||||
if path.startswith(cwd):
|
|
||||||
path = path[len(cwd):]
|
|
||||||
|
|
||||||
cmd = "cvs diff -r %s -r %s -u %r" % (rev1, rev2, path)
|
|
||||||
(status, data) = commands.getstatusoutput(cmd)
|
|
||||||
status = status >> 8
|
|
||||||
|
|
||||||
if status == 0:
|
|
||||||
w.set_error("No difference found")
|
|
||||||
else:
|
|
||||||
w.application.data_buffer("*Diff*", data, switch_to=True, modename='diff')
|
|
||||||
w.set_error("Differences were found")
|
|
||||||
class CvsBlame(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)
|
|
||||||
|
|
||||||
tokens = []
|
|
||||||
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))
|
|
||||||
tokens.append((rev, user, date, content))
|
|
||||||
|
|
||||||
lines = []
|
|
||||||
fmt = "%%-%ds %%-%ds %%9s %%s\n" % (max_rev, max_user)
|
|
||||||
for (rev, user, date, content) in tokens:
|
|
||||||
lines.append(fmt % (rev, user, date, content))
|
|
||||||
data = ''.join(lines)
|
|
||||||
|
|
||||||
status = pipe.wait() >> 8
|
|
||||||
if status == 0:
|
|
||||||
w.application.data_buffer("*Blame*", data, switch_to=True, modename='blame')
|
|
||||||
else:
|
|
||||||
w.set_error("There was an error (%s)" % (status))
|
|
||||||
|
|
||||||
class ShowBindingsBuffer(Method):
|
class ShowBindingsBuffer(Method):
|
||||||
'''Dump all keybindings for current mode into a new buffer'''
|
'''Dump all keybindings for current mode into a new buffer'''
|
||||||
def _execute(self, w, **vargs):
|
def _execute(self, w, **vargs):
|
||||||
|
|
|
@ -0,0 +1,223 @@
|
||||||
|
import os, commands, re, sets, tempfile
|
||||||
|
from subprocess import Popen, PIPE, STDOUT
|
||||||
|
|
||||||
|
import buffer, default, dirutil, regex, util, window
|
||||||
|
from point import Point
|
||||||
|
|
||||||
|
from method import DATATYPES, Method, Argument
|
||||||
|
|
||||||
|
class CvsCommit(Method):
|
||||||
|
'''diff the current file with the version in CVS'''
|
||||||
|
args = [Argument("msg", type=type(""), prompt="Commit Message: ")]
|
||||||
|
regex = re.compile('^new revision: ([0-9.]+); previous revision: ([0-9.]+)$')
|
||||||
|
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 = "cvs ci -m %r %r" % (vargs['msg'], path)
|
||||||
|
(status, data) = commands.getstatusoutput(cmd)
|
||||||
|
status = status >> 8
|
||||||
|
lines = data.split('\n')
|
||||||
|
|
||||||
|
if status == 0:
|
||||||
|
for line in lines:
|
||||||
|
m = self.regex.match(line)
|
||||||
|
if m:
|
||||||
|
w.set_error("Committed [%s -> %s]" % (m.group(2), m.group(1)))
|
||||||
|
return
|
||||||
|
w.set_error("Up-to-date")
|
||||||
|
else:
|
||||||
|
w.set_error("Problems with CVS commit: %d" % status)
|
||||||
|
w.application.data_buffer("*Commit*", data, switch_to=True)
|
||||||
|
|
||||||
|
class CvsStatus(Method):
|
||||||
|
regex1 = re.compile('^File: (.+?) *\tStatus: (.*?)$')
|
||||||
|
regex2 = re.compile('^ Working revision:\t([0-9\.]+)$')
|
||||||
|
regex3 = re.compile('^ Repository revision:\t([0-9\.]+)\t(.*)$')
|
||||||
|
regex4 = re.compile('^ Sticky Tag:\t\t\((.*)\)$')
|
||||||
|
regex5 = re.compile('^ Sticky Date:\t\t\((.*)\)$')
|
||||||
|
regex6 = re.compile('^ Sticky Options:\t\((.*)\)$')
|
||||||
|
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 = "cvs status %r" % path
|
||||||
|
(status, data) = commands.getstatusoutput(cmd)
|
||||||
|
status = status >> 8
|
||||||
|
|
||||||
|
if status != 0:
|
||||||
|
w.set_error("Problems with CVS status: %d" % status)
|
||||||
|
return
|
||||||
|
|
||||||
|
lines = data.split('\n')
|
||||||
|
|
||||||
|
if lines[0].startswith('cvs status: nothing known about '):
|
||||||
|
w.set_error('File is not under CVS control')
|
||||||
|
return
|
||||||
|
|
||||||
|
m = self.regex1.match(lines[1])
|
||||||
|
assert m, "regex1 %r" % lines[1]
|
||||||
|
ffile = m.group(1)
|
||||||
|
fstatus = m.group(2)
|
||||||
|
|
||||||
|
m = self.regex2.match(lines[3])
|
||||||
|
assert m, "regex2 %r" % lines[3]
|
||||||
|
wrev = m.group(1)
|
||||||
|
|
||||||
|
m = self.regex3.match(lines[4])
|
||||||
|
assert m, "regex3 %r" % lines[4]
|
||||||
|
rrev = m.group(1)
|
||||||
|
rpath = m.group(2)
|
||||||
|
|
||||||
|
m = self.regex4.match(lines[5])
|
||||||
|
assert m, "regex4 %r" % lines[5]
|
||||||
|
stag = m.group(1)
|
||||||
|
|
||||||
|
m = self.regex5.match(lines[6])
|
||||||
|
assert m, "regex5 %r" % lines[6]
|
||||||
|
sdate = m.group(1)
|
||||||
|
|
||||||
|
m = self.regex6.match(lines[7])
|
||||||
|
assert m, "regex6 %r" % lines[7]
|
||||||
|
soptions = m.group(1)
|
||||||
|
|
||||||
|
w.set_error('%s %s %s/%s [%s|%s|%s]' % (ffile, fstatus,
|
||||||
|
wrev, rrev, stag,
|
||||||
|
sdate, soptions))
|
||||||
|
|
||||||
|
class CvsDiff(Method):
|
||||||
|
'''diff the current file with the version in CVS'''
|
||||||
|
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 = "cvs diff -u %r" % path
|
||||||
|
(status, data) = commands.getstatusoutput(cmd)
|
||||||
|
status = status >> 8
|
||||||
|
|
||||||
|
if status == 0:
|
||||||
|
w.set_error("No difference found")
|
||||||
|
else:
|
||||||
|
w.application.data_buffer("*Diff*", data, switch_to=True, modename='diff')
|
||||||
|
w.set_error("Differences were found")
|
||||||
|
class CvsDiff2(Method):
|
||||||
|
'''diff the current file with the version in CVS'''
|
||||||
|
rev_regex = re.compile('^[0-9]+\.[0-9]+$')
|
||||||
|
args = [Argument("revision", type=type(""), prompt="Old Revision: ")]
|
||||||
|
def _execute(self, w, **vargs):
|
||||||
|
if not hasattr(w.buffer, 'path'):
|
||||||
|
w.set_error("Buffer has no corresponding file")
|
||||||
|
return
|
||||||
|
|
||||||
|
rev = vargs['revision']
|
||||||
|
if not self.rev_regex.match(rev):
|
||||||
|
w.set_error("Could not parse revision: %r" % rev)
|
||||||
|
return
|
||||||
|
|
||||||
|
cwd = os.getcwd() + os.path.sep
|
||||||
|
path = w.buffer.path
|
||||||
|
if path.startswith(cwd):
|
||||||
|
path = path[len(cwd):]
|
||||||
|
|
||||||
|
cmd = "cvs diff -r %s -u %r" % (rev, path)
|
||||||
|
(status, data) = commands.getstatusoutput(cmd)
|
||||||
|
status = status >> 8
|
||||||
|
|
||||||
|
if status == 0:
|
||||||
|
w.set_error("No difference found")
|
||||||
|
else:
|
||||||
|
w.application.data_buffer("*Diff*", data, switch_to=True, modename='diff')
|
||||||
|
w.set_error("Differences were found")
|
||||||
|
class CvsDiff3(Method):
|
||||||
|
'''diff the current file with the version in CVS'''
|
||||||
|
rev_regex = re.compile('^[0-9]+\.[0-9]+$')
|
||||||
|
args = [Argument("revision1", type=type(""), prompt="Old Revision: "),
|
||||||
|
Argument("revision2", type=type(""), prompt="New Revision: ")]
|
||||||
|
def _execute(self, w, **vargs):
|
||||||
|
if not hasattr(w.buffer, 'path'):
|
||||||
|
w.set_error("Buffer has no corresponding file")
|
||||||
|
return
|
||||||
|
|
||||||
|
rev1 = vargs['revision1']
|
||||||
|
if not self.rev_regex.match(rev1):
|
||||||
|
w.set_error("Could not parse revision1: %r" % rev)
|
||||||
|
return
|
||||||
|
|
||||||
|
rev2 = vargs['revision2']
|
||||||
|
if not self.rev_regex.match(rev2):
|
||||||
|
w.set_error("Could not parse revision2: %r" % rev)
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
cwd = os.getcwd() + os.path.sep
|
||||||
|
path = w.buffer.path
|
||||||
|
if path.startswith(cwd):
|
||||||
|
path = path[len(cwd):]
|
||||||
|
|
||||||
|
cmd = "cvs diff -r %s -r %s -u %r" % (rev1, rev2, path)
|
||||||
|
(status, data) = commands.getstatusoutput(cmd)
|
||||||
|
status = status >> 8
|
||||||
|
|
||||||
|
if status == 0:
|
||||||
|
w.set_error("No difference found")
|
||||||
|
else:
|
||||||
|
w.application.data_buffer("*Diff*", data, switch_to=True, modename='diff')
|
||||||
|
w.set_error("Differences were found")
|
||||||
|
class CvsBlame(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)
|
||||||
|
|
||||||
|
tokens = []
|
||||||
|
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))
|
||||||
|
tokens.append((rev, user, date, content))
|
||||||
|
|
||||||
|
lines = []
|
||||||
|
fmt = "%%-%ds %%-%ds %%9s %%s\n" % (max_rev, max_user)
|
||||||
|
for (rev, user, date, content) in tokens:
|
||||||
|
lines.append(fmt % (rev, user, date, content))
|
||||||
|
data = ''.join(lines)
|
||||||
|
|
||||||
|
status = pipe.wait() >> 8
|
||||||
|
if status == 0:
|
||||||
|
w.application.data_buffer("*Blame*", data, switch_to=True, modename='blame')
|
||||||
|
else:
|
||||||
|
w.set_error("There was an error (%s)" % (status))
|
|
@ -0,0 +1,184 @@
|
||||||
|
import os, commands, re, sets, tempfile
|
||||||
|
from subprocess import Popen, PIPE, STDOUT
|
||||||
|
|
||||||
|
import buffer, default, dirutil, regex, util, window
|
||||||
|
from point import Point
|
||||||
|
|
||||||
|
from method import DATATYPES, Method, Argument
|
||||||
|
|
||||||
|
class SvnCommit(Method):
|
||||||
|
'''diff the current file with the version in SVN'''
|
||||||
|
args = [Argument("msg", type=type(""), prompt="Commit Message: ")]
|
||||||
|
regex = re.compile(r'^Committed revision ([0-9]+)\.$')
|
||||||
|
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 = "svn ci -m %r %r" % (vargs['msg'], path)
|
||||||
|
(status, data) = commands.getstatusoutput(cmd)
|
||||||
|
status = status >> 8
|
||||||
|
lines = data.split('\n')
|
||||||
|
|
||||||
|
if status == 0:
|
||||||
|
try:
|
||||||
|
for line in lines:
|
||||||
|
m = self.regex.match(line)
|
||||||
|
if m:
|
||||||
|
w.set_error("Committed [%s]" % (m.group(1)))
|
||||||
|
return
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
w.set_error("Problems with SVN commit: %d" % status)
|
||||||
|
w.application.data_buffer("*Commit*", repr(lines), switch_to=True)
|
||||||
|
|
||||||
|
class SvnStatus(Method):
|
||||||
|
column = {
|
||||||
|
' ': 'Unmodified',
|
||||||
|
'A': 'Added',
|
||||||
|
'C': 'Conflicted',
|
||||||
|
'D': 'Deleted',
|
||||||
|
'I': 'Ignored',
|
||||||
|
'M': 'Modified',
|
||||||
|
'R': 'Replaced',
|
||||||
|
'X': 'External',
|
||||||
|
'?': 'Unknown',
|
||||||
|
'!': 'Missing',
|
||||||
|
'~': 'Obstructed',
|
||||||
|
}
|
||||||
|
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 = "svn status -v %r" % path
|
||||||
|
(status, data) = commands.getstatusoutput(cmd)
|
||||||
|
status = status >> 8
|
||||||
|
|
||||||
|
if status != 0:
|
||||||
|
w.set_error("Problems with 'svn status': %d" % status)
|
||||||
|
return
|
||||||
|
|
||||||
|
c = data[0]
|
||||||
|
status = self.column.get(c, 'Error (%s)' % c)
|
||||||
|
fields = data[6:].split()
|
||||||
|
try:
|
||||||
|
(rrev, lrev, lauthor, filename) = fields
|
||||||
|
except:
|
||||||
|
raise Exception, '%r %r' % (fields, data[6:])
|
||||||
|
|
||||||
|
w.set_error('%s %s %s/%s [%s]' % (filename, status, rrev, lrev, lauthor))
|
||||||
|
class SvnDiff(Method):
|
||||||
|
'''diff the current file with the version in SVN'''
|
||||||
|
def _execute(self, w, **vargs):
|
||||||
|
if not hasattr(w.buffer, 'path'):
|
||||||
|
w.set_error("Buffer has no corresponding file")
|
||||||
|
return
|
||||||
|
|
||||||
|
cmd = "svn diff %r" % w.buffer.path
|
||||||
|
(status, data) = commands.getstatusoutput(cmd)
|
||||||
|
|
||||||
|
if status == 0:
|
||||||
|
if data:
|
||||||
|
w.application.data_buffer("*Diff*", data, switch_to=True, modename='diff')
|
||||||
|
w.set_error("Differences were found")
|
||||||
|
else:
|
||||||
|
w.set_error("No difference found")
|
||||||
|
else:
|
||||||
|
w.set_error("There was an error (%s)" % (status))
|
||||||
|
class SvnDiff2(Method):
|
||||||
|
'''diff the current file with the version in SVN'''
|
||||||
|
rev_regex = re.compile('^[0-9]+$')
|
||||||
|
args = [Argument("revision", type=type(""), prompt="Old Revision: ")]
|
||||||
|
def _execute(self, w, **vargs):
|
||||||
|
if not hasattr(w.buffer, 'path'):
|
||||||
|
w.set_error("Buffer has no corresponding file")
|
||||||
|
return
|
||||||
|
|
||||||
|
rev = vargs['revision']
|
||||||
|
if not self.rev_regex.match(rev):
|
||||||
|
w.set_error("Could not parse revision: %r" % rev)
|
||||||
|
return
|
||||||
|
|
||||||
|
cwd = os.getcwd() + os.path.sep
|
||||||
|
path = w.buffer.path
|
||||||
|
if path.startswith(cwd):
|
||||||
|
path = path[len(cwd):]
|
||||||
|
|
||||||
|
cmd = "svn diff -r %s %r" % (rev, path)
|
||||||
|
(status, data) = commands.getstatusoutput(cmd)
|
||||||
|
status = status >> 8
|
||||||
|
|
||||||
|
if data:
|
||||||
|
w.application.data_buffer("*Diff*", data, switch_to=True, modename='diff')
|
||||||
|
w.set_error("Differences were found")
|
||||||
|
else:
|
||||||
|
w.set_error("No difference found")
|
||||||
|
class SvnDiff3(Method):
|
||||||
|
'''diff the current file with the version in SVN'''
|
||||||
|
rev_regex = re.compile('^[0-9]+$')
|
||||||
|
args = [Argument("revision1", type=type(""), prompt="Old Revision: "),
|
||||||
|
Argument("revision2", type=type(""), prompt="New Revision: ")]
|
||||||
|
def _execute(self, w, **vargs):
|
||||||
|
if not hasattr(w.buffer, 'path'):
|
||||||
|
w.set_error("Buffer has no corresponding file")
|
||||||
|
return
|
||||||
|
|
||||||
|
rev1 = vargs['revision1']
|
||||||
|
if not self.rev_regex.match(rev1):
|
||||||
|
w.set_error("Could not parse revision1: %r" % rev)
|
||||||
|
return
|
||||||
|
|
||||||
|
rev2 = vargs['revision2']
|
||||||
|
if not self.rev_regex.match(rev2):
|
||||||
|
w.set_error("Could not parse revision2: %r" % rev)
|
||||||
|
return
|
||||||
|
|
||||||
|
cwd = os.getcwd() + os.path.sep
|
||||||
|
path = w.buffer.path
|
||||||
|
if path.startswith(cwd):
|
||||||
|
path = path[len(cwd):]
|
||||||
|
|
||||||
|
cmd = "svn diff -r %s -r %s %r" % (rev1, rev2, path)
|
||||||
|
(status, data) = commands.getstatusoutput(cmd)
|
||||||
|
status = status >> 8
|
||||||
|
|
||||||
|
if data:
|
||||||
|
w.application.data_buffer("*Diff*", data, switch_to=True, modename='diff')
|
||||||
|
w.set_error("Differences were found")
|
||||||
|
else:
|
||||||
|
w.set_error("No difference found")
|
||||||
|
class SvnBlame(Method):
|
||||||
|
'''show blame output for the current version in SVN'''
|
||||||
|
line_re = re.compile('^ *(\d+) *([a-zA-Z0-9_]+) *([-0-9]+) *([:0-9]+) *(-\d{4}) *\(([^\)]+)\) (.*)$')
|
||||||
|
def _execute(self, w, **vargs):
|
||||||
|
if not hasattr(w.buffer, 'path'):
|
||||||
|
w.set_error("Buffer has no corresponding file")
|
||||||
|
return
|
||||||
|
|
||||||
|
cmd = ("/usr/bin/svn", 'blame', '-v', w.buffer.path)
|
||||||
|
pipe = Popen(cmd, stdin=PIPE, stdout=PIPE)
|
||||||
|
|
||||||
|
lines = []
|
||||||
|
for line in pipe.stdout:
|
||||||
|
m = self.line_re.match(line)
|
||||||
|
if not m:
|
||||||
|
raise Exception, line
|
||||||
|
(rev, user, date, t, tz, vdate, content) = m.groups()
|
||||||
|
lines.append("%-4s %-10s %10s %s\n" % (rev, user, date, content))
|
||||||
|
data = ''.join(lines)
|
||||||
|
|
||||||
|
status = pipe.wait() >> 8
|
||||||
|
if status == 0:
|
||||||
|
w.application.data_buffer("*Blame*", data, switch_to=True, modename='blame')
|
||||||
|
else:
|
||||||
|
w.set_error("There was an error (%s)" % (status))
|
Loading…
Reference in New Issue