From 6a5220d83855a19cbaf36dddd00559b124f27076 Mon Sep 17 00:00:00 2001 From: moculus Date: Sun, 16 Mar 2008 23:42:16 +0000 Subject: [PATCH] --HG-- branch : pmacs2 --- method/__init__.py | 63 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 62 insertions(+), 1 deletion(-) diff --git a/method/__init__.py b/method/__init__.py index 20de4d8..6116055 100644 --- a/method/__init__.py +++ b/method/__init__.py @@ -1176,7 +1176,6 @@ class SvnStatus(Method): 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): @@ -1195,6 +1194,68 @@ class SvnDiff(Method): 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}) *\(([^\)]+)\) (.*)$')