ported functionality from method.cvs to method.vc and method.svn

--HG--
branch : pmacs2
This commit is contained in:
Erik Osheim 2010-04-20 01:18:25 -04:00
parent 20c095b6c6
commit e5e4e28dbf
4 changed files with 66 additions and 33 deletions

View File

@ -5,6 +5,7 @@ import buffer, default, dirutil, lex, regex, util, window
from point import Point
from method import Method, Argument, arg
from method.vc import VcBlame, VcRevView, VcDateView
class CvsCommit(Method):
'''diff the current file with the version in CVS'''
@ -273,48 +274,27 @@ class CvsBlame(Method):
w.set_error("There was an error (%s)" % (status))
class CvsBlame2(CvsBlame):
'''show blame output for the current version in CVS'''
'''show blame output for the given version in CVS'''
args = [arg("revision", t=type(""), p="Revision: ", h="revision number")]
line_re = re.compile('^([0-9.]+) +\(*([a-zA-Z0-9_]+) +([-0-9A-Za-z]+)\): (.*)$')
def _get_cmd(self, w, **vargs):
path = self._get_path(w, **vargs)
return ("/usr/bin/cvs", 'annotate', '-r', vargs['revision'], path)
class CvsRevView(Method):
class CvsRevView(VcRevView):
'''show blame output for the current version in CVS'''
args = [arg("revision", t=type(""), p="Revision: ", h="revision number")]
def _get_path(self, w, **vargs):
cwd = os.getcwd() + os.path.sep
path = w.buffer.path
if path.startswith(cwd):
path = path[len(cwd):]
return path
args = [arg("revision", t=type(""), p="Revision: ", h="revision number")]
namebase = 'CVS'
_is_method = True
def _get_cmd(self, w, **vargs):
path = self._get_path(w, **vargs)
return ("/usr/bin/cvs", 'up', '-p', '-r', vargs['revision'], path)
def _get_name(self, w, **vargs):
return '*CVS:%s-%s' % (w.buffer.name(), vargs['revision'])
def _execute(self, w, **vargs):
if not hasattr(w.buffer, 'path'):
w.set_error("Buffer has no corresponding file")
return
cmd = self._get_cmd(w, **vargs)
name = self._get_name(w, **vargs)
mname = w.mode.name.lower()
status, out, err = util.communicate(cmd)
w.application.data_buffer(name, out, switch_to=True, modename=mname)
class CvsDateView(CvsRevView):
class CvsDateView(VcDateView):
'''show blame output for the current version in CVS'''
args = [arg("date", t=type(""), p="Date: ", h="date specifier")]
args = [arg("date", t=type(""), p="Date: ", h="date specifier")]
namebase = 'CVS'
_is_method = True
def _get_cmd(self, w, **vargs):
path = self._get_path(w, **vargs)
return ("/usr/bin/cvs", 'up', '-p', '-D', vargs['date'], path)
def _get_name(self, w, **vargs):
return '*CVS:%s-%s' % (w.buffer.name(), vargs['date'])

View File

@ -4,9 +4,9 @@ from subprocess import Popen, PIPE, STDOUT
import buffer, default, dirutil, lex, regex, util, window
from point import Point
import buffer.colors
from method.vc import VcBlame
from method.vc import VcBlame, VcRevView
from method import Method, Argument
from method import Method, Argument, arg
if os.system('which svn >/dev/null 2>/dev/null') == 0:
has_svn = True
@ -275,3 +275,19 @@ class SvnBlame(VcBlame):
def _open_pipe(self, w, **vargs):
cmd = ("svn", 'blame', '-v', w.buffer.path)
return Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE)
class SvnBlame2(SvnBlame):
'''show file contents in SVN at revision'''
args = [arg("revision", t=type(""), p="Revision: ", h="revision number")]
def _open_pipe(self, w, **vargs):
cmd = ("svn", 'blame', '-v', '-r', vargs['revision'], w.buffer.path)
return Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE)
class SvnRevView(VcRevView):
'''show file contents in SVN at date'''
args = [arg("revision", t=type(""), p="Revision: ", h="revision number")]
namebase = 'SVN'
_is_method = True
def _get_cmd(self, w, **vargs):
path = self._get_path(w, **vargs)
return ("svn", 'cat', '-r', vargs['revision'], path)

View File

@ -1,3 +1,4 @@
import os
from method import Method
import buffer.colors
import util
@ -68,3 +69,39 @@ class VcBlame(Method):
data = ''.join(self._build_lines(groups, gsizes, w, **vargs))
w.application.color_data_buffer("*Blame*", data, switch_to=True)
class VcRevView(Method):
'''show file contents at revision'''
_is_method = False
namebase = 'VC'
def _get_path(self, w, **vargs):
cwd = os.getcwd() + os.path.sep
path = w.buffer.path
if path.startswith(cwd):
path = path[len(cwd):]
return path
def _get_cmd(self, w, **vargs):
path = self._get_path(w, **vargs)
raise Exception("unimplemented")
def _get_name(self, w, **vargs):
return '*%s:%s-%s' % (self.namebase, w.buffer.name(), vargs['revision'])
def _execute(self, w, **vargs):
if not hasattr(w.buffer, 'path'):
w.set_error("Buffer has no corresponding file")
return
cmd = self._get_cmd(w, **vargs)
name = self._get_name(w, **vargs)
mname = w.mode.name.lower()
status, out, err = util.communicate(cmd)
w.application.data_buffer(name, out, switch_to=True, modename=mname)
class VcDateView(VcRevView):
'''show file contents at date'''
args = [arg("date", t=type(""), p="Date: ", h="date specifier")]
def _get_name(self, w, **vargs):
return '*%s:%s-%s' % (self.namebase, w.buffer.name(), vargs['date'])

View File

@ -213,7 +213,7 @@ class C(Fundamental):
closetokens = ('delimiter',)
closetags = {')': '(', ']': '[', '}': '{'}
actions = [CCheckSyntax, CMake]
format = "%(flag)s %(bname)s (%(mname)s) %(indent)s %(cursor)s %(perc)s [%(func)s]"
format = "%(flag)s %(bname)s (%(mname)s) %(indent)s %(cursor)s %(perc)s [%(func)s] %(vc-info)s"
commentc = '//'
colors = {