From bf8beb2c1257d1c6cc9ae2d5f98aace9eba9b3d8 Mon Sep 17 00:00:00 2001 From: Erik Osheim Date: Mon, 18 May 2009 00:12:10 -0400 Subject: [PATCH] hg-diff2 and hg-diff3 added --HG-- branch : pmacs2 --- method/hg.py | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/method/hg.py b/method/hg.py index 17e56ea..945b84f 100644 --- a/method/hg.py +++ b/method/hg.py @@ -51,10 +51,30 @@ class HgLog(Method, HgBase): class HgDiff(Method, HgBase): """Diff the current file with the version in Mercurial""" + def _get_revs(self, w, **vargs): + return [] def _execute(self, w, **vargs): if not self._hg_check(w): return ui_imp, repo = self._hg_init() - hgc.diff(ui_imp, repo, w.buffer.path) + revs = self._get_revs(w, **vargs) + try: + hgc.diff(ui_imp, repo, w.buffer.path, rev=revs) + except Exception, e: + w.set_error(str(e)) + return s = ''.join(ui_imp.popbuffer()) w.application.data_buffer("*Diff*", s, switch_to=True, modename='diff') + +class HgDiff2(HgDiff): + """Diff the current file with a specific revision in Mercurial""" + args = [Argument("revision", type=type(""), prompt="Revision: ")] + def _get_revs(self, w, **vargs): + return [vargs['revision']] + +class HgDiff3(HgDiff): + """Diff the current file with a specific revision in Mercurial""" + args = [Argument("revision1", type=type(""), prompt="First Revision: "), + Argument("revision2", type=type(""), prompt="Second Revision: ")] + def _get_revs(self, w, **vargs): + return [vargs['revision1'], vargs['revision2']]