Skip to content
Browse files

Added a menu entry for Blame, fixed a couple of PEP8 warnings

  • Loading branch information...
1 parent 17b390d commit faba798e6489efb6425093609ad344f0b41d759b @wbond committed Aug 27, 2011
Showing with 45 additions and 6 deletions.
  1. +1 −0 .gitignore
  2. +2 −1 Context.sublime-menu
  3. +1 −0 Default (Windows).sublime-keymap
  4. +1 −0 Side Bar.sublime-menu
  5. +40 −5 Tortoise.py
View
1 .gitignore
@@ -1,2 +1,3 @@
*.pyc
*.sublime-project
+*.sublime-workspace
View
3 Context.sublime-menu
@@ -1,9 +1,10 @@
[
{ "caption": "-" },
{ "command": "tortoise_log", "args": {"paths": true}, "caption": "Tortoise Log…" },
+ { "command": "tortoise_blame", "args": {"paths": true}, "caption": "Tortoise Blame…" },
{ "command": "tortoise_diff", "args": {"paths": true}, "caption": "Tortoise Diff…" },
{ "command": "tortoise_add", "args": {"paths": true}, "caption": "Tortoise Add…" },
{ "command": "tortoise_revert", "args": {"paths": true}, "caption": "Tortoise Revert…" },
{ "command": "tortoise_remove", "args": {"paths": true}, "caption": "Tortoise Remove…" },
{ "caption": "-", "id": "end" }
-]
+]
View
1 Default (Windows).sublime-keymap
@@ -6,6 +6,7 @@
{ "keys": ["ctrl+alt+v","ctrl+alt+l"], "command": "tortoise_log" },
{ "keys": ["ctrl+alt+v","ctrl+alt+f"], "command": "tortoise_diff", "args": {"paths": true} },
{ "keys": ["ctrl+alt+v","ctrl+alt+g"], "command": "tortoise_log", "args": {"paths": true} },
+ { "keys": ["ctrl+alt+v","ctrl+alt+m"], "command": "tortoise_blame", "args": {"paths": true} },
{ "keys": ["ctrl+alt+v","ctrl+alt+x"], "command": "tortoise_explore", "args": {"paths": true} },
{ "keys": ["ctrl+alt+v","ctrl+alt+a"], "command": "tortoise_add", "args": {"paths": true} },
{ "keys": ["ctrl+alt+v","ctrl+alt+r"], "command": "tortoise_remove", "args": {"paths": true} },
View
1 Side Bar.sublime-menu
@@ -2,6 +2,7 @@
{ "caption": "-" },
{ "caption": "Tortoise Status…", "command": "tortoise_status", "args": {"paths": []} },
{ "caption": "Tortoise Log…", "command": "tortoise_log", "args": {"paths": []} },
+ { "caption": "Tortoise Blame…", "command": "tortoise_blame", "args": {"paths": []} },
{ "caption": "Tortoise Sync…", "command": "tortoise_sync", "args": {"paths": []} },
{ "caption": "Tortoise Commit…", "command": "tortoise_commit", "args": {"paths": []} },
{ "caption": "Tortoise Diff…", "command": "tortoise_diff", "args": {"paths": []} },
View
45 Tortoise.py
@@ -32,17 +32,17 @@ def get_vcs(self, path):
try:
vcs = TortoiseSVN(settings.get('svn_tortoiseproc_path'), path)
- except (RepositoryNotFoundError) as (exception):
+ except (RepositoryNotFoundError):
pass
try:
vcs = TortoiseGit(settings.get('git_tortoiseproc_path'), path)
- except (RepositoryNotFoundError) as (exception):
+ except (RepositoryNotFoundError):
pass
try:
vcs = TortoiseHg(settings.get('hg_hgtk_path'), path)
- except (RepositoryNotFoundError) as (exception):
+ except (RepositoryNotFoundError):
pass
if vcs == None:
@@ -72,7 +72,7 @@ def handler(self, *args, **kwargs):
if res != None:
return res
return True
- except (NotFoundError) as (exception):
+ except (NotFoundError):
return False
return handler
@@ -160,6 +160,30 @@ def is_enabled(self, paths=None):
return path and self.get_vcs(path).get_status(path) in \
['', 'M', 'R', 'C', 'U']
+class TortoiseBlameCommand(sublime_plugin.WindowCommand, TortoiseCommand):
+ @handles_not_found
+ def run(self, paths=None):
+ path = self.get_path(paths)
+ self.get_vcs(path).blame(path if paths else None)
+
+ @invisible_when_not_found
+ def is_visible(self, paths=None):
+ if not self.menus_enabled():
+ return False
+ path = self.get_path(paths)
+ if os.path.isdir(path):
+ return False
+ vcs = self.get_vcs(path)
+ return path and vcs.get_status(path) in \
+ ['A', '', 'M', 'R', 'C', 'U']
+
+ @invisible_when_not_found
+ def is_enabled(self, paths=None):
+ path = self.get_path(paths)
+ if os.path.isdir(path):
+ return False
+ return path and self.get_vcs(path).get_status(path) in \
+ ['A', '', 'M', 'R', 'C', 'U']
class TortoiseDiffCommand(sublime_plugin.WindowCommand, TortoiseCommand):
@handles_not_found
@@ -251,7 +275,7 @@ def is_enabled(self, paths=None):
class ForkGui():
def __init__(self, cmd, cwd):
- proc = subprocess.Popen(cmd, stdin=subprocess.PIPE,
+ subprocess.Popen(cmd, stdin=subprocess.PIPE,
stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
cwd=cwd)
@@ -355,6 +379,12 @@ def log(self, path=None):
ForkGui('"' + self.path + '" /command:log /path:"%s"' % path,
self.root_dir)
+ def blame(self, path=None):
+ path = self.root_dir if path == None else path
+ path = os.path.relpath(path, self.root_dir)
+ ForkGui('"' + self.path + '" /command:blame /path:"%s"' % path,
+ self.root_dir)
+
def diff(self, path):
path = os.path.relpath(path, self.root_dir)
ForkGui('"' + self.path + '" /command:diff /path:"%s"' % path,
@@ -450,6 +480,11 @@ def log(self, path=None):
args = [self.path, 'log', '--nofork', path]
ForkGui(args, self.root_dir)
+ def blame(self, path=None):
+ path = os.path.relpath(path, self.root_dir)
+ args = [self.path, 'blame', '--nofork', path]
+ ForkGui(args, self.root_dir)
+
def diff(self, path):
path = os.path.relpath(path, self.root_dir)
args = [self.path, 'vdiff', '--nofork', path]

0 comments on commit faba798

Please sign in to comment.
Something went wrong with that request. Please try again.