From 45821c8d0c7efddab44587a066590b564e3f4495 Mon Sep 17 00:00:00 2001 From: bordaigorl Date: Thu, 22 Jan 2015 01:40:31 +0000 Subject: [PATCH 1/3] Adding Merge Abort, Tool and launch mergetool on conflict Introduces `mergetool_on_conflicts` settings (default to false) --- Default.sublime-commands | 8 ++++++++ repo.py | 28 ++++++++++++++++++++++++++-- 2 files changed, 34 insertions(+), 2 deletions(-) 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..81d0a94f 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: + 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()) + print(root) + return 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]) From 3969f4a61e25d323ad1e676858319fc6d4541f9b Mon Sep 17 00:00:00 2001 From: bordaigorl Date: Thu, 22 Jan 2015 09:59:31 +0000 Subject: [PATCH 2/3] Check that root exists before checking if in the middle of a merge --- repo.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/repo.py b/repo.py index 81d0a94f..d16a4e7c 100644 --- a/repo.py +++ b/repo.py @@ -75,8 +75,7 @@ def run(self): def is_enabled(self): root = git_root(self.get_working_dir()) - print(root) - return os.path.exists(os.path.join(root, ".git/MERGE_HEAD")) + return root and os.path.exists(os.path.join(root, ".git/MERGE_HEAD")) class GitMergeAbortCommand(GitMergeToolCommand): From c5892c7424b35a3c04716c8eae25aaa0d336adea Mon Sep 17 00:00:00 2001 From: bordaigorl Date: Tue, 8 Dec 2015 19:34:03 +0100 Subject: [PATCH 3/3] Mergetool: warning the user --- repo.py | 1 + 1 file changed, 1 insertion(+) diff --git a/repo.py b/repo.py index d16a4e7c..5b37b3df 100644 --- a/repo.py +++ b/repo.py @@ -63,6 +63,7 @@ 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 = ""