2009-04-17 16:51:06 -04:00
|
|
|
from method import Method, Argument
|
|
|
|
|
2009-05-09 19:41:42 -04:00
|
|
|
class HgBlame(Method):
|
|
|
|
"""Show buffer annotated with hg metadata"""
|
2009-05-09 22:57:05 -04:00
|
|
|
# use hg blame -udq FILE
|
|
|
|
def _execute(self, w, **vargs):
|
|
|
|
w.set_error("unimplemented")
|
2009-05-09 19:41:42 -04:00
|
|
|
|
|
|
|
class HgLog(Method):
|
|
|
|
"""Show hg log for this buffer"""
|
2009-05-09 22:57:05 -04:00
|
|
|
def _execute(self, w, **vargs):
|
|
|
|
w.set_error("unimplemented")
|
2009-05-09 19:41:42 -04:00
|
|
|
|
2009-04-17 16:51:06 -04:00
|
|
|
class HgDiff(Method):
|
2009-04-17 22:09:31 -04:00
|
|
|
"""Diff the current file with the version in Mercurial"""
|
2009-04-17 16:51:06 -04:00
|
|
|
def _execute(self, w, **vargs):
|
2009-04-17 22:09:31 -04:00
|
|
|
try:
|
|
|
|
from mercurial import hg, ui
|
|
|
|
from mercurial import commands as hgc
|
|
|
|
except ImportError:
|
2009-04-17 16:51:06 -04:00
|
|
|
w.set_error("Mecurial is not installed")
|
|
|
|
return
|
2009-04-17 22:09:31 -04:00
|
|
|
|
|
|
|
if not hasattr(w.buffer, 'path'):
|
2009-04-17 16:51:06 -04:00
|
|
|
w.set_error("Buffer has no corresponding file")
|
|
|
|
return
|
|
|
|
ui_imp = ui.ui(verbose=True)
|
|
|
|
ui_imp.pushbuffer()
|
2009-04-17 22:09:31 -04:00
|
|
|
repo = hg.repository(ui=ui_imp, path='.')
|
2009-04-17 16:51:06 -04:00
|
|
|
hgc.diff(ui_imp, repo, w.buffer.path)
|
2009-04-17 22:09:31 -04:00
|
|
|
s = ''.join(ui_imp.popbuffer())
|
|
|
|
w.application.data_buffer("*Diff*", s, switch_to=True, modename='diff')
|