From 3133fce524b2bce7ef5d1a5b2460235e22e1619b Mon Sep 17 00:00:00 2001 From: Bailey Ling Date: Wed, 11 Sep 2013 21:13:51 +0000 Subject: [PATCH 1/2] Improve detection performance (#67) --- autoload/sy/repo.vim | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/autoload/sy/repo.vim b/autoload/sy/repo.vim index 43b7a6b..12853f7 100644 --- a/autoload/sy/repo.vim +++ b/autoload/sy/repo.vim @@ -18,9 +18,23 @@ endif let s:diffoptions = get(g:, 'signify_diffoptions', {}) +let s:vcs_list = get(g:, 'signify_vcs_list', []) +if empty(s:vcs_list) + if executable('git') | call add(s:vcs_list, 'git') | endif + if executable('hg') | call add(s:vcs_list, 'hg') | endif + if executable('svn') | call add(s:vcs_list, 'svn') | endif + if executable('darcs') | call add(s:vcs_list, 'darcs') | endif + if executable('bzr') | call add(s:vcs_list, 'bzr') | endif + if executable('fossil') | call add(s:vcs_list, 'fossil') | endif + if executable('cvs') | call add(s:vcs_list, 'cvs') | endif + if executable('rcsdiff') | call add(s:vcs_list, 'rcs') | endif + if executable('accurev') | call add(s:vcs_list, 'accurev') | endif + if executable('p4') | call add(s:vcs_list, 'perforce') | endif +endif + " Function: #detect {{{1 function! sy#repo#detect(path) abort - for type in get(g:, 'signify_vcs_list', [ 'git', 'hg', 'svn', 'darcs', 'bzr', 'fossil', 'cvs', 'rcs', 'accurev', 'perforce' ]) + for type in s:vcs_list let diff = sy#repo#get_diff_{type}(a:path) if !empty(diff) return [ diff, type ] From a2b96beff77a10e73c76c83870bc766b7eae0297 Mon Sep 17 00:00:00 2001 From: Marco Hinz Date: Thu, 12 Sep 2013 00:16:09 +0200 Subject: [PATCH 2/2] Refactor VCS detection --- autoload/sy/repo.vim | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/autoload/sy/repo.vim b/autoload/sy/repo.vim index 12853f7..d7a9c98 100644 --- a/autoload/sy/repo.vim +++ b/autoload/sy/repo.vim @@ -6,6 +6,8 @@ endif let b:autoloaded_sy_repo = 1 " Init: values {{{1 +let s:diffoptions = get(g:, 'signify_diffoptions', {}) + if !empty(get(g:, 'signify_difftool')) let s:difftool = g:signify_difftool else @@ -16,21 +18,20 @@ else let s:difftool = 'diff' endif -let s:diffoptions = get(g:, 'signify_diffoptions', {}) +let s:vcs_dict = { + \ 'git': 'git', + \ 'hg': 'hg', + \ 'svn': 'svn', + \ 'darcs': 'darcs', + \ 'bzr': 'bzr', + \ 'fossil': 'fossil', + \ 'cvs': 'cvs', + \ 'rcs': 'rcsdiff', + \ 'accurev': 'accurev', + \ 'perforce': 'p4' + \ } -let s:vcs_list = get(g:, 'signify_vcs_list', []) -if empty(s:vcs_list) - if executable('git') | call add(s:vcs_list, 'git') | endif - if executable('hg') | call add(s:vcs_list, 'hg') | endif - if executable('svn') | call add(s:vcs_list, 'svn') | endif - if executable('darcs') | call add(s:vcs_list, 'darcs') | endif - if executable('bzr') | call add(s:vcs_list, 'bzr') | endif - if executable('fossil') | call add(s:vcs_list, 'fossil') | endif - if executable('cvs') | call add(s:vcs_list, 'cvs') | endif - if executable('rcsdiff') | call add(s:vcs_list, 'rcs') | endif - if executable('accurev') | call add(s:vcs_list, 'accurev') | endif - if executable('p4') | call add(s:vcs_list, 'perforce') | endif -endif +let s:vcs_list = values(filter(s:vcs_dict, 'executable(v:key)')) " Function: #detect {{{1 function! sy#repo#detect(path) abort