dan's mercurial stuff

--HG--
branch : pmacs2
This commit is contained in:
moculus 2009-04-17 20:51:06 +00:00
parent 35e4611dd0
commit 757d6e7dca
2 changed files with 33 additions and 1 deletions

View File

@ -98,7 +98,7 @@ class Application(object):
'method', 'method.svn', 'method.cvs', 'method.search', 'method', 'method.svn', 'method.cvs', 'method.search',
'method.buffers', 'method.move', 'method.shell', 'method.buffers', 'method.move', 'method.shell',
'method.introspect', 'method.help', 'method.numbers', 'method.introspect', 'method.help', 'method.numbers',
'method.spell', 'method.spell', 'method.hg',
) )
for name in names: for name in names:
exec("import %s" % name) exec("import %s" % name)

32
method/hg.py Normal file
View File

@ -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')