diff --git a/application.py b/application.py index 4e8c2c2..a01decf 100755 --- a/application.py +++ b/application.py @@ -98,7 +98,7 @@ class Application(object): 'method', 'method.svn', 'method.cvs', 'method.search', 'method.buffers', 'method.move', 'method.shell', 'method.introspect', 'method.help', 'method.numbers', - 'method.spell', + 'method.spell', 'method.hg', ) for name in names: exec("import %s" % name) diff --git a/method/hg.py b/method/hg.py new file mode 100644 index 0000000..4390081 --- /dev/null +++ b/method/hg.py @@ -0,0 +1,32 @@ +try: + import mercurial + from mercurial import hg + from mercurial import ui + from mercurial import commands as hgc + has_hg = True +except ImportError: + has_hg = False + +import buffer, default, dirutil, lex, regex, util, window +from point import Point + +from method import Method, Argument + +class HgDiff(Method): + """ + + """ + def _execute(self, w, **vargs): + if not has_hg: + w.set_error("Mecurial is not installed") + return + elif not hasattr(w.buffer, 'path'): + w.set_error("Buffer has no corresponding file") + return + ui_imp = ui.ui(verbose=True) + repo = hg.repository(ui=ui_imp, path='.') + ui_imp.pushbuffer() + hgc.diff(ui_imp, repo, w.buffer.path) + data = ui_imp.popbuffer() + w.application.data_buffer("*Diff*", "".join(data), + switch_to=True, modename='diff')