diff --git a/Default.sublime-commands b/Default.sublime-commands index b822ade2..e0602044 100644 --- a/Default.sublime-commands +++ b/Default.sublime-commands @@ -113,6 +113,14 @@ "caption": "Git: Merge Branch", "command": "git_merge" } + ,{ + "caption": "Git: Merge Abort", + "command": "git_merge_abort" + } + ,{ + "caption": "Git: Merge Tool", + "command": "git_merge_tool" + } ,{ "caption": "Git: Delete Branch", "command": "git_delete_branch" diff --git a/repo.py b/repo.py index 78b5d4bd..5b37b3df 100644 --- a/repo.py +++ b/repo.py @@ -1,7 +1,7 @@ import os import sublime -from .git import GitWindowCommand, git_root_exist +from .git import GitWindowCommand, git_root_exist, git_root class GitInit(object): @@ -59,6 +59,30 @@ class GitMergeCommand(GitBranchCommand): command_to_run_after_branch = ['merge'] extra_flags = ['--no-merge'] + def update_status(self, result): + self.panel(result) + if sublime.load_settings("Git.sublime-settings").get('mergetool_on_conflicts'): + if '\nCONFLICT ' in result: + sublime.status_message("Merge conflict: launching mergetool...") + self.get_window().run_command("git_raw", {"command": "git mergetool -y"}) + global branch + branch = "" + for view in self.window.views(): + view.run_command("git_branch_status") + +class GitMergeToolCommand(GitWindowCommand): + def run(self): + self.get_window().run_command("git_raw", {"command": "git mergetool -y"}) + + def is_enabled(self): + root = git_root(self.get_working_dir()) + return root and os.path.exists(os.path.join(root, ".git/MERGE_HEAD")) + + +class GitMergeAbortCommand(GitMergeToolCommand): + def run(self): + self.get_window().run_command("git_raw", {"command": "git merge --abort"}) + class GitDeleteBranchCommand(GitBranchCommand): command_to_run_after_branch = ['branch', '-d'] @@ -103,7 +127,7 @@ def panel_done(self, picked): return picked_tag = self.results[picked] picked_tag = picked_tag.strip() - if sublime.ok_cancel_dialog("Delete \"%s\" Tag?" % picked_tag, "Delete"): + if sublime.ok_cancel_dialog("Delete \"%s\" Tag?" % picked_tag, "Delete"): self.run_command(['git', 'tag', '-d', picked_tag])