def add(view): try: from .gutter_handlers import GitGutterHandler, HgGutterHandler, SvnGutterHandler except ValueError: from gutter_handlers import GitGutterHandler, HgGutterHandler, SvnGutterHandler settings = sublime.load_settings('VcsGutter.sublime-settings') vcs_paths = settings.get('vcs_paths', [ ["git", "git"], ["hg", "hg"], ["svn", "svn"] ]) handler = None if GitHelper.is_git_repository(view): handler = GitGutterHandler(view, vcs_paths['git']) elif HgHelper.is_hg_repository(view): handler = HgGutterHandler(view, vcs_paths['hg']) elif SvnHelper.is_svn_repository(view): handler = SvnGutterHandler(view, vcs_paths['svn']) # If no handler found then either the view does not represent a # file on disk (e.g. not yet saved) or the file is not in a supported # VCS repository. if handler is not None: key = ViewCollection.get_key(view) ViewCollection.views[key] = handler ViewCollection.views[key].reset()
def add(view): try: from .gutter_handlers import GitGutterHandler, HgGutterHandler, \ SvnGutterHandler, PerforceGutterHandler except ValueError: from gutter_handlers import GitGutterHandler, HgGutterHandler, \ SvnGutterHandler, PerforceGutterHandler settings = sublime.load_settings('VcsGutter.sublime-settings') vcs_paths = settings.get('vcs_paths', { 'git': 'git', 'hg': 'hg', 'svn': 'svn', 'p4': 'p4', }) PerforceHelper.p4bin = vcs_paths['p4'] key = None if vcs_paths['git'] and GitHelper.is_git_repository(view): key = 'git' klass = GitGutterHandler elif vcs_paths['hg'] and HgHelper.is_hg_repository(view): key = 'hg' klass = HgGutterHandler elif vcs_paths['svn'] and SvnHelper.is_svn_repository(view): key = 'svn' klass = SvnGutterHandle elif vcs_paths['p4'] and PerforceHelper.is_p4_repository(view): key = 'p4' klass = PerforceGutterHandler handler = None if key is not None: try: path = vcs_paths[key] except (KeyError, TypeError): print('Vcs Gutter: Invalid path for %s executable in settings. Using default.' % key) path = key handler = klass(view, path) # If no handler found then either the view does not represent a # file on disk (e.g. not yet saved) or the file is not in a supported # VCS repository. if handler is not None: key = ViewCollection.get_key(view) ViewCollection.views[key] = handler ViewCollection.views[key].reset()
def add(view): from gutter_handlers import GitGutterHandler from gutter_handlers import HgGutterHandler from gutter_handlers import SvnGutterHandler handler = None if GitHelper.is_git_repository(view): handler = GitGutterHandler(view) elif HgHelper.is_hg_repository(view): handler = HgGutterHandler(view) elif SvnHelper.is_svn_repository(view): handler = SvnGutterHandler(view) # If no handler found then either the view does not represent a # file on disk (e.g. not yet saved) or the file is not in a supported # VCS repository. if handler is not None: key = ViewCollection.get_key(view) ViewCollection.views[key] = handler ViewCollection.views[key].reset()