Created
September 1, 2010 21:39
-
-
Save rgieseke/561418 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module('_m.common.vc', package.seeall) | |
function hg_status() | |
local path = buffer.filename:match('(.+)/') | |
local command = 'cd '..path..'; hg root 2>&1' | |
local f = io.popen(command) | |
local ans = f:read("*a") | |
f:close() | |
if ans:match(".hg not found") then | |
_m.textadept.snapopen.open({path}) | |
else | |
local hg_root = ans:sub(1,-2) | |
command = 'cd '..path..'; hg st -amdcu 2>&1' | |
f = io.popen(command) | |
local status = f:read("*a") | |
f:close() | |
local items = {} | |
local fstatus, fname | |
for fstatus, fname in string.gmatch(status, "([AMDC\?])%s([%w\.]+)[\n]") do | |
items[#items+1] = fname | |
items[#items+1] = fstatus | |
end | |
local out = | |
gui.dialog('filteredlist', | |
'--title', 'hg ('..hg_root..')', | |
'--button1', 'gtk-ok', | |
'--button2', 'gtk-cancel', | |
'--no-newline', | |
'--string-output', | |
'--columns', 'File', 'Status', | |
'--items', unpack(items)) | |
local response, file = out:match('([^\n]+)\n([^\n]+)$') | |
if response and response ~= 'gtk-cancel' then | |
io.open_file(hg_root..'/'..file) | |
end | |
end | |
end | |
keys.cap = { function() | |
if buffer.filename then _m.common.vc.hg_status( ) end | |
end} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment