git-svn-id: https://vimsuite.svn.sourceforge.net/svnroot/vimsuite/trunk@215 eb2d0018-73a3-4aeb-bfe9-1def61c9ec69
This commit is contained in:
AlterDepp 2012-04-22 17:19:27 +00:00
parent a515175134
commit f758745d21
16 changed files with 325 additions and 161 deletions

View File

@ -19,19 +19,19 @@ ScriptID SourceID Filename
1046 4249 Lusty Explorer 1046 4249 Lusty Explorer
2043 7805 VimPdb (debugging python) 2043 7805 VimPdb (debugging python)
1776 7902 Vimgrep Replace 1776 7902 Vimgrep Replace
3745 16527 LineDiff 3745 16823 LineDiff
39 8196 matchit.vim 39 8196 matchit.vim
2092 8095 reloaded.vim (matrix colorscheme) 2092 8095 reloaded.vim (matrix colorscheme)
848 14668 SrchRplcHiGrp.vim (Search/Replace on Syntax Group) 848 14668 SrchRplcHiGrp.vim (Search/Replace on Syntax Group)
294 10110 Align.vim 294 10110 Align.vim
479 9276 MultipleSearch.vba 479 9276 MultipleSearch.vba
1066 7618 cecutil.vim 1066 7618 cecutil.vim
1173 15731 tComment.vim 1173 17289 tComment.vim
2701 13194 editsrec 2701 13194 editsrec
3280 14334 Tabbi 3280 14334 Tabbi
642 15781 :AutoInstall: getscript.vim 642 15781 :AutoInstall: getscript.vim
1075 15782 :AutoInstall: netrw.vim 1075 15782 :AutoInstall: netrw.vim
1502 15362 :AutoInstall: vimball.vim 1502 15362 :AutoInstall: vimball.vim
3304 16172 Gundo 3304 17406 Gundo
90 15797 vcscommand 90 17031 vcscommand

View File

@ -553,7 +553,10 @@ def GundoPlayTo():
return None return None
nodes.append(current) nodes.append(current)
return reversed(nodes) if rev else nodes if rev:
return reversed(nodes)
else:
return nodes
branch = _walk_branch(start, end) branch = _walk_branch(start, end)

View File

@ -19,22 +19,6 @@ if v:version < '703'"{{{
finish finish
endif"}}} endif"}}}
if has('python')"{{{
let s:has_supported_python = 1
else
let s:has_supported_python = 0
endif
if !s:has_supported_python
function! s:GundoDidNotLoad()
echohl WarningMsg|echomsg "Gundo requires Vim to be compiled with Python 2.4+"|echohl None
endfunction
command! -nargs=0 GundoToggle call s:GundoDidNotLoad()
finish
endif"}}}
let s:plugin_path = escape(expand('<sfile>:p:h'), '\')
if !exists('g:gundo_width')"{{{ if !exists('g:gundo_width')"{{{
let g:gundo_width = 45 let g:gundo_width = 45
endif"}}} endif"}}}
@ -59,7 +43,26 @@ endif"}}}
if !exists("g:gundo_close_on_revert")"{{{ if !exists("g:gundo_close_on_revert")"{{{
let g:gundo_close_on_revert = 0 let g:gundo_close_on_revert = 0
endif"}}} endif"}}}
if !exists("g:gundo_prefer_python3")"{{{
let g:gundo_prefer_python3 = 0
endif"}}}
let s:has_supported_python = 0
if g:gundo_prefer_python3 && has('python3')"{{{
let s:has_supported_python = 2
elseif has('python')"
let s:has_supported_python = 1
endif
if !s:has_supported_python
function! s:GundoDidNotLoad()
echohl WarningMsg|echomsg "Gundo requires Vim to be compiled with Python 2.4+"|echohl None
endfunction
command! -nargs=0 GundoToggle call s:GundoDidNotLoad()
finish
endif"}}}
let s:plugin_path = escape(expand('<sfile>:p:h'), '\')
"}}} "}}}
"{{{ Gundo utility functions "{{{ Gundo utility functions
@ -213,6 +216,9 @@ function! s:GundoOpenGraph()"{{{
call s:GundoResizeBuffers(winnr()) call s:GundoResizeBuffers(winnr())
endif endif
endif endif
if exists("g:gundo_tree_statusline")
let &l:statusline = g:gundo_tree_statusline
endif
endfunction"}}} endfunction"}}}
function! s:GundoOpenPreview()"{{{ function! s:GundoOpenPreview()"{{{
@ -247,6 +253,9 @@ function! s:GundoOpenPreview()"{{{
endif endif
endif endif
endif endif
if exists("g:gundo_preview_statusline")
let &l:statusline = g:gundo_preview_statusline
endif
endfunction"}}} endfunction"}}}
function! s:GundoClose()"{{{ function! s:GundoClose()"{{{
@ -263,8 +272,13 @@ endfunction"}}}
function! s:GundoOpen()"{{{ function! s:GundoOpen()"{{{
if !exists('g:gundo_py_loaded') if !exists('g:gundo_py_loaded')
if s:has_supported_python == 2 && g:gundo_prefer_python3
exe 'py3file ' . s:plugin_path . '/gundo.py'
python3 initPythonModule()
else
exe 'pyfile ' . s:plugin_path . '/gundo.py' exe 'pyfile ' . s:plugin_path . '/gundo.py'
python initPythonModule() python initPythonModule()
endif
if !s:has_supported_python if !s:has_supported_python
function! s:GundoDidNotLoad() function! s:GundoDidNotLoad()
@ -303,6 +317,14 @@ function! s:GundoToggle()"{{{
endif endif
endfunction"}}} endfunction"}}}
function! s:GundoShow()"{{{
call s:GundoOpen()
endfunction"}}}
function! s:GundoHide()"{{{
call s:GundoClose()
endfunction"}}}
"}}} "}}}
"{{{ Gundo mouse handling "{{{ Gundo mouse handling
@ -363,15 +385,27 @@ endfunction"}}}
"{{{ Gundo rendering "{{{ Gundo rendering
function! s:GundoRenderGraph()"{{{ function! s:GundoRenderGraph()"{{{
if s:has_supported_python == 2 && g:gundo_prefer_python3
python3 GundoRenderGraph()
else
python GundoRenderGraph() python GundoRenderGraph()
endif
endfunction"}}} endfunction"}}}
function! s:GundoRenderPreview()"{{{ function! s:GundoRenderPreview()"{{{
if s:has_supported_python == 2 && g:gundo_prefer_python3
python3 GundoRenderPreview()
else
python GundoRenderPreview() python GundoRenderPreview()
endif
endfunction"}}} endfunction"}}}
function! s:GundoRenderChangePreview()"{{{ function! s:GundoRenderChangePreview()"{{{
if s:has_supported_python == 2 && g:gundo_prefer_python3
python3 GundoRenderChangePreview()
else
python GundoRenderChangePreview() python GundoRenderChangePreview()
endif
endfunction"}}} endfunction"}}}
"}}} "}}}
@ -379,11 +413,19 @@ endfunction"}}}
"{{{ Gundo undo/redo "{{{ Gundo undo/redo
function! s:GundoRevert()"{{{ function! s:GundoRevert()"{{{
if s:has_supported_python == 2 && g:gundo_prefer_python3
python3 GundoRevert()
else
python GundoRevert() python GundoRevert()
endif
endfunction"}}} endfunction"}}}
function! s:GundoPlayTo()"{{{ function! s:GundoPlayTo()"{{{
if s:has_supported_python == 2 && g:gundo_prefer_python3
python3 GundoPlayTo()
else
python GundoPlayTo() python GundoPlayTo()
endif
endfunction"}}} endfunction"}}}
"}}} "}}}

View File

@ -98,10 +98,10 @@ function! linediff#differ#SetupDiffBuffer() dict
let b:differ = self let b:differ = self
let statusline = printf('[%s:%%{b:differ.from}-%%{b:differ.to}]', bufname(self.original_buffer)) let statusline = printf('[%s:%%{b:differ.from}-%%{b:differ.to}]', bufname(self.original_buffer))
if &statusline =~ '%f' if &statusline =~ '%[fF]'
let statusline = substitute(&statusline, '%f', statusline, '') let statusline = substitute(&statusline, '%[fF]', statusline, '')
endif endif
exe "setlocal statusline=" . escape(statusline, ' ') exe "setlocal statusline=" . escape(statusline, ' |')
exe "set filetype=" . self.filetype exe "set filetype=" . self.filetype
setlocal bufhidden=hide setlocal bufhidden=hide
@ -109,7 +109,9 @@ function! linediff#differ#SetupDiffBuffer() dict
endfunction endfunction
function! linediff#differ#CloseDiffBuffer() dict function! linediff#differ#CloseDiffBuffer() dict
if bufexists(self.diff_buffer)
exe "bdelete ".self.diff_buffer exe "bdelete ".self.diff_buffer
endif
endfunction endfunction
function! linediff#differ#SetupSigns() dict function! linediff#differ#SetupSigns() dict

View File

@ -17,6 +17,8 @@ CONTENTS *Gundo-contents*
3.7 gundo_map_move_older ...... |gundo_map_move_older| 3.7 gundo_map_move_older ...... |gundo_map_move_older|
gundo_map_move_newer ...... |gundo_map_move_newer| gundo_map_move_newer ...... |gundo_map_move_newer|
3.8 gundo_close_on_revert ..... |gundo_close_on_revert| 3.8 gundo_close_on_revert ..... |gundo_close_on_revert|
3.9 gundo_preview_statusline .. |gundo_preview_statusline|
gundo_tree_statusline ..... |gundo_tree_statusline|
4. License ........................ |GundoLicense| 4. License ........................ |GundoLicense|
5. Bugs ........................... |GundoBugs| 5. Bugs ........................... |GundoBugs|
6. Contributing ................... |GundoContributing| 6. Contributing ................... |GundoContributing|
@ -196,6 +198,14 @@ Set this to 1 to automatically close the Gundo windows when reverting.
Default: 0 (windows do not automatically close) Default: 0 (windows do not automatically close)
------------------------------------------------------------------------------
3.9 g:gundo_preview_statusline *gundo_preview_statusline*
g:gundo_tree_statusline *gundo_tree_statusline*
Set these to a string to display it as the status line for each Gundo window.
Default: unset (windows use the default statusline)
============================================================================== ==============================================================================
4. License *GundoLicense* 4. License *GundoLicense*
@ -219,6 +229,8 @@ GitHub: http://github.com/sjl/gundo.vim/
============================================================================== ==============================================================================
7. Changelog *GundoChangelog* 7. Changelog *GundoChangelog*
v2.3.0
* Add statusline configuration.
v2.2.2 v2.2.2
* More performance improvements. * More performance improvements.
v2.2.1 v2.2.1

View File

@ -133,6 +133,7 @@ VCSCommandSVNDiffOpt vcscommand.txt /*VCSCommandSVNDiffOpt*
VCSCommandSVNExec vcscommand.txt /*VCSCommandSVNExec* VCSCommandSVNExec vcscommand.txt /*VCSCommandSVNExec*
VCSCommandSplit vcscommand.txt /*VCSCommandSplit* VCSCommandSplit vcscommand.txt /*VCSCommandSplit*
VCSCommandVCSTypeOverride vcscommand.txt /*VCSCommandVCSTypeOverride* VCSCommandVCSTypeOverride vcscommand.txt /*VCSCommandVCSTypeOverride*
VCSCommandVCSTypePreference vcscommand.txt /*VCSCommandVCSTypePreference*
VimPdb.txt VimPdb.txt /*VimPdb.txt* VimPdb.txt VimPdb.txt /*VimPdb.txt*
Vimball-copyright pi_vimball.txt /*Vimball-copyright* Vimball-copyright pi_vimball.txt /*Vimball-copyright*
[% matchit.txt /*[%* [% matchit.txt /*[%*
@ -1629,7 +1630,9 @@ gundo_map_move_newer gundo.txt /*gundo_map_move_newer*
gundo_map_move_older gundo.txt /*gundo_map_move_older* gundo_map_move_older gundo.txt /*gundo_map_move_older*
gundo_preview_bottom gundo.txt /*gundo_preview_bottom* gundo_preview_bottom gundo.txt /*gundo_preview_bottom*
gundo_preview_height gundo.txt /*gundo_preview_height* gundo_preview_height gundo.txt /*gundo_preview_height*
gundo_preview_statusline gundo.txt /*gundo_preview_statusline*
gundo_right gundo.txt /*gundo_right* gundo_right gundo.txt /*gundo_right*
gundo_tree_statusline gundo.txt /*gundo_tree_statusline*
gundo_width gundo.txt /*gundo_width* gundo_width gundo.txt /*gundo_width*
http pi_netrw.txt /*http* http pi_netrw.txt /*http*
linediff linediff.txt /*linediff* linediff linediff.txt /*linediff*

View File

@ -447,6 +447,7 @@ The following variables are available:
|VCSCommandSVNDiffOpt| |VCSCommandSVNDiffOpt|
|VCSCommandSVNExec| |VCSCommandSVNExec|
|VCSCommandVCSTypeOverride| |VCSCommandVCSTypeOverride|
|VCSCommandVCSTypePreference|
VCSCommandCommitOnWrite *VCSCommandCommitOnWrite* VCSCommandCommitOnWrite *VCSCommandCommitOnWrite*
@ -593,6 +594,13 @@ element is a regular expression that will be matched against the full file
name of a given buffer. If it matches, the second element will be used as the name of a given buffer. If it matches, the second element will be used as the
VCS type. VCS type.
VCSCommandVCSTypePreference *VCSCommandVCSTypePreference*
This variable allows the VCS type detection to be weighted towards a specific
VCS, in case more than one potential VCS is detected as useable. The format
of the variable is either a list or a space-separated string containing the
ordered-by-preference abbreviations of the preferred VCS types.
5.2 VCSCommand events *vcscommand-events* 5.2 VCSCommand events *vcscommand-events*
For additional customization, vcscommand can trigger user-defined events. For additional customization, vcscommand can trigger user-defined events.

View File

@ -18,5 +18,7 @@ let loaded_gundo = 1"}}}
"{{{ Misc "{{{ Misc
command! -nargs=0 GundoToggle call gundo#GundoToggle() command! -nargs=0 GundoToggle call gundo#GundoToggle()
command! -nargs=0 GundoShow call gundo#GundoShow()
command! -nargs=0 GundoHide call gundo#GundoHide()
command! -nargs=0 GundoRenderGraph call gundo#GundoRenderGraph() command! -nargs=0 GundoRenderGraph call gundo#GundoRenderGraph()
"}}} "}}}

View File

@ -2,15 +2,12 @@ if exists("g:loaded_linediff") || &cp
finish finish
endif endif
let g:loaded_linediff = '0.1.0' " version number let g:loaded_linediff = '0.1.1' " version number
let s:keepcpo = &cpo let s:keepcpo = &cpo
set cpo&vim set cpo&vim
" Initialized lazily to avoid executing the autoload file before it's really " Initialized lazily to avoid executing the autoload file before it's really
" needed. " needed.
"
" TODO Experiment to see if this matters at all.
"
function! s:Init() function! s:Init()
if !exists('s:differ_one') if !exists('s:differ_one')
let s:differ_one = linediff#differ#New('linediff_one', 1) let s:differ_one = linediff#differ#New('linediff_one', 1)

View File

@ -43,7 +43,9 @@ if v:version < 700
finish finish
endif endif
if !exists('g:loaded_VCSCommand')
runtime plugin/vcscommand.vim runtime plugin/vcscommand.vim
endif
if !executable(VCSCommandGetOption('VCSCommandBZRExec', 'bzr')) if !executable(VCSCommandGetOption('VCSCommandBZRExec', 'bzr'))
" BZR is not installed " BZR is not installed
@ -105,7 +107,7 @@ endfunction
" Function: s:bzrFunctions.Annotate(argList) {{{2 " Function: s:bzrFunctions.Annotate(argList) {{{2
function! s:bzrFunctions.Annotate(argList) function! s:bzrFunctions.Annotate(argList)
if len(a:argList) == 0 if len(a:argList) == 0
if &filetype == 'BZRannotate' if &filetype ==? 'bzrannotate'
" Perform annotation of the version indicated by the current line. " Perform annotation of the version indicated by the current line.
let caption = matchstr(getline('.'),'\v^\s+\zs\d+') let caption = matchstr(getline('.'),'\v^\s+\zs\d+')
let options = ' -r' . caption let options = ' -r' . caption

View File

@ -272,6 +272,13 @@
" full file name of a given buffer. If it matches, the second element will " full file name of a given buffer. If it matches, the second element will
" be used as the VCS type. " be used as the VCS type.
" "
" VCSCommandVCSTypePreference
" This variable allows the VCS type detection to be weighted towards a
" specific VCS, in case more than one potential VCS is detected as useable.
" The format of the variable is either a list or a space-separated string
" containing the ordered-by-preference abbreviations of the preferred VCS
" types.
"
" Event documentation {{{2 " Event documentation {{{2
" For additional customization, VCSCommand.vim uses User event autocommand " For additional customization, VCSCommand.vim uses User event autocommand
" hooks. Each event is in the VCSCommand group, and different patterns " hooks. Each event is in the VCSCommand group, and different patterns
@ -350,8 +357,8 @@ let s:VCSCommandUtility = {}
" plugin-specific information: {vcs -> [script, {command -> function}, {key -> mapping}]} " plugin-specific information: {vcs -> [script, {command -> function}, {key -> mapping}]}
let s:plugins = {} let s:plugins = {}
" temporary values of overridden configuration variables " Stack of dictionaries representing nested options
let s:optionOverrides = {} let s:executionContext = []
" state flag used to vary behavior of certain automated actions " state flag used to vary behavior of certain automated actions
let s:isEditFileRunning = 0 let s:isEditFileRunning = 0
@ -376,15 +383,27 @@ function! s:VCSCommandUtility.system(...)
set sxq=\" set sxq=\"
endif endif
try try
if exists('*iconv') let output = call('system', a:000)
return iconv(call('system', a:000), &tenc, &enc) if exists('*iconv') && has('multi_byte')
if(strlen(&tenc) && &tenc != &enc)
let output = iconv(output, &tenc, &enc)
else
let originalBuffer = VCSCommandGetOriginalBuffer(VCSCommandGetOption('VCSCommandEncodeAsFile', 0))
if originalBuffer
let fenc = getbufvar(originalBuffer, '&fenc')
if fenc != &enc
let output = iconv(output, fenc, &enc)
endif
endif
endif
endif endif
return call('system', a:000)
finally finally
if exists("save_sxq") if exists("save_sxq")
let &sxq = save_sxq let &sxq = save_sxq
endif endif
endtry endtry
return output
endfunction endfunction
" Function: s:VCSCommandUtility.addMenuItem(shortcut, command) {{{2 " Function: s:VCSCommandUtility.addMenuItem(shortcut, command) {{{2
@ -396,6 +415,20 @@ function! s:VCSCommandUtility.addMenuItem(shortcut, command)
endif endif
endfunction endfunction
" Function: s:VCSCommandUtility.pushContext(context) {{{2
" Adds a dictionary containing current options to the stack.
function! s:VCSCommandUtility.pushContext(context)
call insert(s:executionContext, a:context)
endfunction
" Function: s:VCSCommandUtility.popContext() {{{2
" Removes a dictionary containing current options from the stack.
function! s:VCSCommandUtility.popContext()
call remove(s:executionContext, 0)
endfunction
" Function: s:ClearMenu() {{{2 " Function: s:ClearMenu() {{{2
" Removes all VCSCommand menu items " Removes all VCSCommand menu items
function! s:ClearMenu() function! s:ClearMenu()
@ -545,6 +578,64 @@ function! s:EditFile(command, originalBuffer, statusText)
endtry endtry
endfunction endfunction
" Function: s:IdentifyVCSType() {{{2
" This function implements the non-cached identification strategy for
" VcsCommandGetVCSType().
"
" Returns: VCS type name identified for the given buffer; an exception is
" thrown in case no type can be identified.
function! s:IdentifyVCSType(buffer)
if exists("g:VCSCommandVCSTypeOverride")
let fullpath = fnamemodify(bufname(a:buffer), ':p')
for [path, vcsType] in g:VCSCommandVCSTypeOverride
if match(fullpath, path) > -1
return vcsType
endif
endfor
endif
let matches = []
let exactMatch = ''
let exactMatchCount = 0
for vcsType in keys(s:plugins)
let identified = s:plugins[vcsType][1].Identify(a:buffer)
if identified
if identified == g:VCSCOMMAND_IDENTIFY_EXACT
let exactMatch = vcsType
let exactMatchCount += 1
endif
call add(matches, [vcsType, identified])
endif
endfor
if len(matches) == 1
return matches[0][0]
elseif len(matches) == 0
throw 'No suitable plugin'
else
let preferences = VCSCommandGetOption("VCSCommandVCSTypePreference", [])
if len(preferences) > 0
if type(preferences) == 1
let listPreferences = split(preferences, '\W\+')
unlet preferences
let preferences = listPreferences
endif
for preferred in preferences
for [vcsType, identified] in matches
if vcsType ==? preferred
return vcsType
endif
endfor
endfor
endif
if exactMatchCount == 1
return exactMatch
endif
throw 'can''t identify VCS type for current buffer due to too many matching VCS: ' . join(map(matches, 'v:val[0]'))
endif
endfunction
" Function: s:SetupScratchBuffer(command, vcsType, originalBuffer, statusText) {{{2 " Function: s:SetupScratchBuffer(command, vcsType, originalBuffer, statusText) {{{2
" Creates convenience buffer variables and the name of a vcscommand result " Creates convenience buffer variables and the name of a vcscommand result
" buffer. " buffer.
@ -625,21 +716,6 @@ function! s:MarkOrigBufferForSetup(buffer)
return a:buffer return a:buffer
endfunction endfunction
" Function: s:OverrideOption(option, [value]) {{{2
" Provides a temporary override for the given VCS option. If no value is
" passed, the override is disabled.
function! s:OverrideOption(option, ...)
if a:0 == 0
call remove(s:optionOverrides[a:option], -1)
else
if !has_key(s:optionOverrides, a:option)
let s:optionOverrides[a:option] = []
endif
call add(s:optionOverrides[a:option], a:1)
endif
endfunction
" Function: s:WipeoutCommandBuffers() {{{2 " Function: s:WipeoutCommandBuffers() {{{2
" Clears all current VCS output buffers of the specified type for a given source. " Clears all current VCS output buffers of the specified type for a given source.
@ -721,6 +797,7 @@ endfunction
" Function: s:VCSAnnotate(...) {{{2 " Function: s:VCSAnnotate(...) {{{2
function! s:VCSAnnotate(bang, ...) function! s:VCSAnnotate(bang, ...)
call s:VCSCommandUtility.pushContext({'VCSCommandEncodeAsFile': bufnr('%')})
try try
let line = line('.') let line = line('.')
let currentBuffer = bufnr('%') let currentBuffer = bufnr('%')
@ -741,9 +818,18 @@ function! s:VCSAnnotate(bang, ...)
if splitRegex == '' if splitRegex == ''
return annotateBuffer return annotateBuffer
endif endif
wincmd J
let originalFileType = getbufvar(originalBuffer, '&ft') let originalFileType = getbufvar(originalBuffer, '&ft')
let annotateFileType = getbufvar(annotateBuffer, '&ft') let annotateFileType = getbufvar(annotateBuffer, '&ft')
let saveselection = &selection
set selection=inclusive
try
execute "normal! 0zR\<c-v>G/" . splitRegex . "/e\<cr>d" execute "normal! 0zR\<c-v>G/" . splitRegex . "/e\<cr>d"
finally
let &selection = saveselection
endtry
call setbufvar('%', '&filetype', getbufvar(originalBuffer, '&filetype')) call setbufvar('%', '&filetype', getbufvar(originalBuffer, '&filetype'))
set scrollbind set scrollbind
leftabove vert new leftabove vert new
@ -774,6 +860,8 @@ function! s:VCSAnnotate(bang, ...)
catch catch
call s:ReportError(v:exception) call s:ReportError(v:exception)
return -1 return -1
finally
call s:VCSCommandUtility.popContext()
endtry endtry
endfunction endfunction
@ -841,6 +929,11 @@ endfunction
" Function: s:VCSFinishCommit(logMessageList, originalBuffer) {{{2 " Function: s:VCSFinishCommit(logMessageList, originalBuffer) {{{2
function! s:VCSFinishCommit(logMessageList, originalBuffer) function! s:VCSFinishCommit(logMessageList, originalBuffer)
let messageFileName = tempname() let messageFileName = tempname()
if exists('*iconv') && has('multi_byte')
if(strlen(&tenc) && &tenc != &enc)
call map(a:logMessageList, 'iconv(v:val, &enc, &tenc)')
endif
endif
call writefile(a:logMessageList, messageFileName) call writefile(a:logMessageList, messageFileName)
try try
let resultBuffer = s:ExecuteVCSCommand('Commit', [messageFileName]) let resultBuffer = s:ExecuteVCSCommand('Commit', [messageFileName])
@ -877,6 +970,8 @@ function! s:VCSGotoOriginal(bang)
endfunction endfunction
function! s:VCSDiff(...) "{{{2 function! s:VCSDiff(...) "{{{2
call s:VCSCommandUtility.pushContext({'VCSCommandEncodeAsFile': bufnr('%')})
try
let resultBuffer = s:ExecuteVCSCommand('Diff', a:000) let resultBuffer = s:ExecuteVCSCommand('Diff', a:000)
if resultBuffer > 0 if resultBuffer > 0
let &filetype = 'diff' let &filetype = 'diff'
@ -884,14 +979,22 @@ function! s:VCSDiff(...) "{{{2
echomsg 'No differences found' echomsg 'No differences found'
endif endif
return resultBuffer return resultBuffer
finally
call s:VCSCommandUtility.popContext()
endtry
endfunction endfunction
function! s:VCSReview(...) "{{{2 function! s:VCSReview(...) "{{{2
call s:VCSCommandUtility.pushContext({'VCSCommandEncodeAsFile': bufnr('%')})
try
let resultBuffer = s:ExecuteVCSCommand('Review', a:000) let resultBuffer = s:ExecuteVCSCommand('Review', a:000)
if resultBuffer > 0 if resultBuffer > 0
let &filetype = getbufvar(b:VCSCommandOriginalBuffer, '&filetype') let &filetype = getbufvar(b:VCSCommandOriginalBuffer, '&filetype')
endif endif
return resultBuffer return resultBuffer
finally
call s:VCSCommandUtility.popContext()
endtry
endfunction endfunction
" Function: s:VCSVimDiff(...) {{{2 " Function: s:VCSVimDiff(...) {{{2
@ -931,11 +1034,11 @@ function! s:VCSVimDiff(...)
diffthis diffthis
let t:vcsCommandVimDiffScratchList = [resultBuffer] let t:vcsCommandVimDiffScratchList = [resultBuffer]
" If no split method is defined, cheat, and set it to vertical. " If no split method is defined, cheat, and set it to vertical.
call s:VCSCommandUtility.pushContext({'VCSCommandSplit': orientation})
try try
call s:OverrideOption('VCSCommandSplit', orientation)
let resultBuffer = s:VCSReview(a:2) let resultBuffer = s:VCSReview(a:2)
finally finally
call s:OverrideOption('VCSCommandSplit') call s:VCSCommandUtility.popContext()
endtry endtry
if resultBuffer < 0 if resultBuffer < 0
echomsg 'Can''t open revision ' . a:1 echomsg 'Can''t open revision ' . a:1
@ -945,11 +1048,8 @@ function! s:VCSVimDiff(...)
diffthis diffthis
let t:vcsCommandVimDiffScratchList += [resultBuffer] let t:vcsCommandVimDiffScratchList += [resultBuffer]
else else
" Add new buffer " Add new buffer. Force splitting behavior, otherwise why use vimdiff?
call s:OverrideOption('VCSCommandEdit', 'split') call s:VCSCommandUtility.pushContext({'VCSCommandEdit': 'split', 'VCSCommandSplit': orientation})
try
" Force splitting behavior, otherwise why use vimdiff?
call s:OverrideOption('VCSCommandSplit', orientation)
try try
if(a:0 == 0) if(a:0 == 0)
let resultBuffer = s:VCSReview() let resultBuffer = s:VCSReview()
@ -957,10 +1057,7 @@ function! s:VCSVimDiff(...)
let resultBuffer = s:VCSReview(a:1) let resultBuffer = s:VCSReview(a:1)
endif endif
finally finally
call s:OverrideOption('VCSCommandSplit') call s:VCSCommandUtility.popContext()
endtry
finally
call s:OverrideOption('VCSCommandEdit')
endtry endtry
if resultBuffer < 0 if resultBuffer < 0
echomsg 'Can''t open current revision' echomsg 'Can''t open current revision'
@ -985,9 +1082,11 @@ function! s:VCSVimDiff(...)
\ . '|call setbufvar('.originalBuffer.', ''&foldmethod'', '''.getbufvar(originalBuffer, '&foldmethod').''')' \ . '|call setbufvar('.originalBuffer.', ''&foldmethod'', '''.getbufvar(originalBuffer, '&foldmethod').''')'
\ . '|call setbufvar('.originalBuffer.', ''&foldlevel'', '''.getbufvar(originalBuffer, '&foldlevel').''')' \ . '|call setbufvar('.originalBuffer.', ''&foldlevel'', '''.getbufvar(originalBuffer, '&foldlevel').''')'
\ . '|call setbufvar('.originalBuffer.', ''&scrollbind'', '.getbufvar(originalBuffer, '&scrollbind').')' \ . '|call setbufvar('.originalBuffer.', ''&scrollbind'', '.getbufvar(originalBuffer, '&scrollbind').')'
\ . '|call setbufvar('.originalBuffer.', ''&cursorbind'', '.getbufvar(originalBuffer, '&cursorbind').')'
\ . '|call setbufvar('.originalBuffer.', ''&wrap'', '.getbufvar(originalBuffer, '&wrap').')' \ . '|call setbufvar('.originalBuffer.', ''&wrap'', '.getbufvar(originalBuffer, '&wrap').')'
\ . '|if &foldmethod==''manual''|execute ''normal! zE''|endif' if has('cursorbind')
let t:vcsCommandVimDiffRestoreCmd .= '|call setbufvar('.originalBuffer.', ''&cursorbind'', '.getbufvar(originalBuffer, '&cursorbind').')'
endif
let t:vcsCommandVimDiffRestoreCmd .= '|if &foldmethod==''manual''|execute ''normal! zE''|endif'
diffthis diffthis
wincmd w wincmd w
else else
@ -1021,49 +1120,31 @@ endfunction
" Section: Public functions {{{1 " Section: Public functions {{{1
" Function: VCSCommandGetVCSType() {{{2 " Function: VCSCommandGetVCSType() {{{2
" Sets the b:VCSCommandVCSType variable in the given buffer to the " This function sets the b:VCSCommandVCSType variable in the given buffer to the
" appropriate source control system name. " appropriate source control system name and returns the same name.
" "
" This uses the Identify extension function to test the buffer. If the " Returns: VCS type name identified for the given buffer. An exception is
" Identify function returns VCSCOMMAND_IDENTIFY_EXACT, the match is considered " thrown if no type can be identified.
" exact. If the Identify function returns VCSCOMMAND_IDENTIFY_INEXACT, the "
" match is considered inexact, and is only applied if no exact match is found. " Rules for determining type:
" Multiple inexact matches is currently considered an error. " 1. use previously-cached value
" 2. use value from 'VCSCommandVCSTypeOverride'
" 3. use single match
" 4. use first matching value from 'VCSCommandTypePreference'
" 5. use single exact match
" 6. error if multiple matching types
" 7. error if no matching types
function! VCSCommandGetVCSType(buffer) function! VCSCommandGetVCSType(buffer)
let vcsType = VCSCommandGetOption('VCSCommandVCSTypeExplicitOverride', '')
if len(vcsType) == 0
let vcsType = getbufvar(a:buffer, 'VCSCommandVCSType') let vcsType = getbufvar(a:buffer, 'VCSCommandVCSType')
if strlen(vcsType) > 0 if strlen(vcsType) == 0
return vcsType let vcsType = s:IdentifyVCSType(a:buffer)
endif
if exists("g:VCSCommandVCSTypeOverride")
let fullpath = fnamemodify(bufname(a:buffer), ':p')
for [path, vcsType] in g:VCSCommandVCSTypeOverride
if match(fullpath, path) > -1
call setbufvar(a:buffer, 'VCSCommandVCSType', vcsType) call setbufvar(a:buffer, 'VCSCommandVCSType', vcsType)
endif
endif
return vcsType return vcsType
endif
endfor
endif
let matches = []
for vcsType in keys(s:plugins)
let identified = s:plugins[vcsType][1].Identify(a:buffer)
if identified
if identified == g:VCSCOMMAND_IDENTIFY_EXACT
let matches = [vcsType]
break
else
let matches += [vcsType]
endif
endif
endfor
if len(matches) == 1
call setbufvar(a:buffer, 'VCSCommandVCSType', matches[0])
return matches[0]
elseif len(matches) == 0
throw 'No suitable plugin'
else
throw 'Too many matching VCS: ' . join(matches)
endif
endfunction endfunction
" Function: VCSCommandChdir(directory) {{{2 " Function: VCSCommandChdir(directory) {{{2
@ -1074,7 +1155,11 @@ function! VCSCommandChdir(directory)
if exists("*haslocaldir") && haslocaldir() if exists("*haslocaldir") && haslocaldir()
let command = 'lcd' let command = 'lcd'
endif endif
if exists("*fnameescape")
execute command fnameescape(a:directory) execute command fnameescape(a:directory)
else
execute command escape(a:directory, ' ')
endif
endfunction endfunction
" Function: VCSCommandChangeToCurrentFileDir() {{{2 " Function: VCSCommandChangeToCurrentFileDir() {{{2
@ -1226,9 +1311,12 @@ endfunction
" searched in the window, buffer, then global spaces. " searched in the window, buffer, then global spaces.
function! VCSCommandGetOption(name, default) function! VCSCommandGetOption(name, default)
if has_key(s:optionOverrides, a:name) && len(s:optionOverrides[a:name]) > 0 for context in s:executionContext
return s:optionOverrides[a:name][-1] if has_key(context, a:name)
elseif exists('w:' . a:name) return context[a:name]
endif
endfor
if exists('w:' . a:name)
return w:{a:name} return w:{a:name}
elseif exists('b:' . a:name) elseif exists('b:' . a:name)
return b:{a:name} return b:{a:name}

View File

@ -89,7 +89,9 @@ if v:version < 700
finish finish
endif endif
if !exists('g:loaded_VCSCommand')
runtime plugin/vcscommand.vim runtime plugin/vcscommand.vim
endif
if !executable(VCSCommandGetOption('VCSCommandCVSExec', 'cvs')) if !executable(VCSCommandGetOption('VCSCommandCVSExec', 'cvs'))
" CVS is not installed " CVS is not installed
@ -180,7 +182,7 @@ endfunction
" Function: s:cvsFunctions.Annotate(argList) {{{2 " Function: s:cvsFunctions.Annotate(argList) {{{2
function! s:cvsFunctions.Annotate(argList) function! s:cvsFunctions.Annotate(argList)
if len(a:argList) == 0 if len(a:argList) == 0
if &filetype == 'CVSannotate' if &filetype ==? 'cvsannotate'
" This is a CVSAnnotate buffer. Perform annotation of the version " This is a CVSAnnotate buffer. Perform annotation of the version
" indicated by the current line. " indicated by the current line.
let caption = matchstr(getline('.'),'\v^[0-9.]+') let caption = matchstr(getline('.'),'\v^[0-9.]+')

View File

@ -48,7 +48,9 @@ if v:version < 700
finish finish
endif endif
if !exists('g:loaded_VCSCommand')
runtime plugin/vcscommand.vim runtime plugin/vcscommand.vim
endif
if !executable(VCSCommandGetOption('VCSCommandGitExec', 'git')) if !executable(VCSCommandGetOption('VCSCommandGitExec', 'git'))
" git is not installed " git is not installed

View File

@ -50,7 +50,9 @@ if v:version < 700
finish finish
endif endif
if !exists('g:loaded_VCSCommand')
runtime plugin/vcscommand.vim runtime plugin/vcscommand.vim
endif
if !executable(VCSCommandGetOption('VCSCommandHGExec', 'hg')) if !executable(VCSCommandGetOption('VCSCommandHGExec', 'hg'))
" HG is not installed " HG is not installed
@ -110,10 +112,10 @@ endfunction
" Function: s:hgFunctions.Annotate(argList) {{{2 " Function: s:hgFunctions.Annotate(argList) {{{2
function! s:hgFunctions.Annotate(argList) function! s:hgFunctions.Annotate(argList)
if len(a:argList) == 0 if len(a:argList) == 0
if &filetype == 'HGannotate' if &filetype ==? 'hgannotate'
" Perform annotation of the version indicated by the current line. " Perform annotation of the version indicated by the current line.
let caption = matchstr(getline('.'),'\v^\s+\zs\d+') let caption = matchstr(getline('.'),'\v^\s*\w+\s+\zs\d+')
let options = ' -r' . caption let options = ' -un -r' . caption
else else
let caption = '' let caption = ''
let options = ' -un' let options = ' -un'

View File

@ -43,7 +43,9 @@ if v:version < 700
finish finish
endif endif
if !exists('g:loaded_VCSCommand')
runtime plugin/vcscommand.vim runtime plugin/vcscommand.vim
endif
if !executable(VCSCommandGetOption('VCSCommandSVKExec', 'svk')) if !executable(VCSCommandGetOption('VCSCommandSVKExec', 'svk'))
" SVK is not installed " SVK is not installed
@ -104,7 +106,7 @@ endfunction
" Function: s:svkFunctions.Annotate(argList) {{{2 " Function: s:svkFunctions.Annotate(argList) {{{2
function! s:svkFunctions.Annotate(argList) function! s:svkFunctions.Annotate(argList)
if len(a:argList) == 0 if len(a:argList) == 0
if &filetype == 'SVKannotate' if &filetype ==? 'svkannotate'
" Perform annotation of the version indicated by the current line. " Perform annotation of the version indicated by the current line.
let caption = matchstr(getline('.'),'\v^\s+\zs\d+') let caption = matchstr(getline('.'),'\v^\s+\zs\d+')
let options = ' -r' . caption let options = ' -r' . caption

View File

@ -50,7 +50,9 @@ if v:version < 700
finish finish
endif endif
if !exists('g:loaded_VCSCommand')
runtime plugin/vcscommand.vim runtime plugin/vcscommand.vim
endif
if !executable(VCSCommandGetOption('VCSCommandSVNExec', 'svn')) if !executable(VCSCommandGetOption('VCSCommandSVNExec', 'svn'))
" SVN is not installed " SVN is not installed
@ -89,22 +91,17 @@ endfunction
" Function: s:svnFunctions.Identify(buffer) {{{2 " Function: s:svnFunctions.Identify(buffer) {{{2
function! s:svnFunctions.Identify(buffer) function! s:svnFunctions.Identify(buffer)
let fileName = resolve(bufname(a:buffer)) let oldCwd = VCSCommandChangeToCurrentFileDir(resolve(bufname(a:buffer)))
if isdirectory(fileName) try
let directoryName = fileName call s:VCSCommandUtility.system(s:Executable() . ' info .')
else if(v:shell_error)
let directoryName = fnamemodify(fileName, ':h')
endif
if strlen(directoryName) > 0
let svnDir = directoryName . '/.svn'
else
let svnDir = '.svn'
endif
if isdirectory(svnDir)
return 1
else
return 0 return 0
else
return g:VCSCOMMAND_IDENTIFY_EXACT
endif endif
finally
call VCSCommandChdir(oldCwd)
endtry
endfunction endfunction
" Function: s:svnFunctions.Add() {{{2 " Function: s:svnFunctions.Add() {{{2
@ -115,7 +112,7 @@ endfunction
" Function: s:svnFunctions.Annotate(argList) {{{2 " Function: s:svnFunctions.Annotate(argList) {{{2
function! s:svnFunctions.Annotate(argList) function! s:svnFunctions.Annotate(argList)
if len(a:argList) == 0 if len(a:argList) == 0
if &filetype == 'SVNannotate' if &filetype ==? 'svnannotate'
" Perform annotation of the version indicated by the current line. " Perform annotation of the version indicated by the current line.
let caption = matchstr(getline('.'),'\v^\s+\zs\d+') let caption = matchstr(getline('.'),'\v^\s+\zs\d+')
let options = ' -r' . caption let options = ' -r' . caption
@ -187,7 +184,7 @@ endfunction
function! s:svnFunctions.GetBufferInfo() function! s:svnFunctions.GetBufferInfo()
let originalBuffer = VCSCommandGetOriginalBuffer(bufnr('%')) let originalBuffer = VCSCommandGetOriginalBuffer(bufnr('%'))
let fileName = bufname(originalBuffer) let fileName = bufname(originalBuffer)
let statusText = s:VCSCommandUtility.system(s:Executable() . ' status --non-interactive -vu -- "' . fileName . '"') let statusText = s:VCSCommandUtility.system(s:Executable() . ' status --non-interactive -v -- "' . fileName . '"')
if(v:shell_error) if(v:shell_error)
return [] return []
endif endif