From 7c0fc7b783855ac1a5bb67884913374fdac6cb7a Mon Sep 17 00:00:00 2001 From: Erik Osheim Date: Tue, 28 Jul 2009 18:08:45 -0400 Subject: [PATCH] new methods: cvs-rev-view and cvs-date-view --HG-- branch : pmacs2 --- method/cvs.py | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/method/cvs.py b/method/cvs.py index 57060b3..fca3e67 100644 --- a/method/cvs.py +++ b/method/cvs.py @@ -279,3 +279,44 @@ class CvsBlame2(CvsBlame): def _get_cmd(self, w, **vargs): path = self._get_path(w, **vargs) return ("/usr/bin/cvs", 'annotate', '-r', vargs['revision'], path) + +class CvsRevView(Method): + '''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 + + 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) + pipe = Popen(cmd, stdout=PIPE, stderr=PIPE) + name = self._get_name(w, **vargs) + data = pipe.stdout.read() + status = pipe.wait() >> 8 + mname = w.mode.name.lower() + + w.application.data_buffer(name, data, switch_to=True, modename=mname) + +class CvsDateView(CvsRevView): + '''show blame output for the current version in CVS''' + args = [arg("date", t=type(""), p="Date: ", h="date specifier")] + 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'])