33 lines
919 B
Python
33 lines
919 B
Python
|
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')
|