Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Merge Abort, Tool and launch mergetool on conflict #389

Open
wants to merge 3 commits into
base: python3
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Default.sublime-commands
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
28 changes: 26 additions & 2 deletions repo.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down Expand Up @@ -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']
Expand Down Expand Up @@ -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])


Expand Down