Update the vcscommand stuff
git-svn-id: http://photonzero.com/dotfiles/trunk@35 23f722f6-122a-0410-8cef-c75bd312dd78
This commit is contained in:
parent
038c882603
commit
10c20eeb99
17 changed files with 459 additions and 393 deletions
|
|
@ -67,12 +67,19 @@ let s:hgFunctions = {}
|
|||
|
||||
" Section: Utility functions {{{1
|
||||
|
||||
" Function: s:Executable() {{{2
|
||||
" Returns the executable used to invoke hg suitable for use in a shell
|
||||
" command.
|
||||
function! s:Executable()
|
||||
return shellescape(VCSCommandGetOption('VCSCommandHGExec', 'hg'))
|
||||
endfunction
|
||||
|
||||
" Function: s:DoCommand(cmd, cmdName, statusText, options) {{{2
|
||||
" Wrapper to VCSCommandDoCommand to add the name of the HG executable to the
|
||||
" command argument.
|
||||
function! s:DoCommand(cmd, cmdName, statusText, options)
|
||||
if VCSCommandGetVCSType(expand('%')) == 'HG'
|
||||
let fullCmd = VCSCommandGetOption('VCSCommandHGExec', 'hg') . ' ' . a:cmd
|
||||
let fullCmd = s:Executable() . ' ' . a:cmd
|
||||
return VCSCommandDoCommand(fullCmd, a:cmdName, a:statusText, a:options)
|
||||
else
|
||||
throw 'HG VCSCommand plugin called on non-HG item.'
|
||||
|
|
@ -83,12 +90,17 @@ endfunction
|
|||
|
||||
" Function: s:hgFunctions.Identify(buffer) {{{2
|
||||
function! s:hgFunctions.Identify(buffer)
|
||||
call system(VCSCommandGetOption('VCSCommandHGExec', 'hg') . ' root')
|
||||
if(v:shell_error)
|
||||
return 0
|
||||
else
|
||||
return g:VCSCOMMAND_IDENTIFY_INEXACT
|
||||
endif
|
||||
let oldCwd = VCSCommandChangeToCurrentFileDir(resolve(bufname(a:buffer)))
|
||||
try
|
||||
call s:VCSCommandUtility.system(s:Executable() . ' root')
|
||||
if(v:shell_error)
|
||||
return 0
|
||||
else
|
||||
return g:VCSCOMMAND_IDENTIFY_INEXACT
|
||||
endif
|
||||
finally
|
||||
call VCSCommandChdir(oldCwd)
|
||||
endtry
|
||||
endfunction
|
||||
|
||||
" Function: s:hgFunctions.Add() {{{2
|
||||
|
|
@ -99,27 +111,23 @@ endfunction
|
|||
" Function: s:hgFunctions.Annotate(argList) {{{2
|
||||
function! s:hgFunctions.Annotate(argList)
|
||||
if len(a:argList) == 0
|
||||
if &filetype == 'HGAnnotate'
|
||||
if &filetype == 'HGannotate'
|
||||
" Perform annotation of the version indicated by the current line.
|
||||
let caption = matchstr(getline('.'),'\v^\s+\zs\d+')
|
||||
let options = ' -r' . caption
|
||||
else
|
||||
let caption = ''
|
||||
let options = ''
|
||||
let options = ' -un'
|
||||
endif
|
||||
elseif len(a:argList) == 1 && a:argList[0] !~ '^-'
|
||||
let caption = a:argList[0]
|
||||
let options = ' -r' . caption
|
||||
let options = ' -un -r' . caption
|
||||
else
|
||||
let caption = join(a:argList, ' ')
|
||||
let options = ' ' . caption
|
||||
endif
|
||||
|
||||
let resultBuffer = s:DoCommand('blame' . options, 'annotate', caption, {})
|
||||
if resultBuffer > 0
|
||||
set filetype=HGAnnotate
|
||||
endif
|
||||
return resultBuffer
|
||||
return s:DoCommand('blame' . options, 'annotate', caption, {})
|
||||
endfunction
|
||||
|
||||
" Function: s:hgFunctions.Commit(argList) {{{2
|
||||
|
|
@ -163,15 +171,7 @@ function! s:hgFunctions.Diff(argList)
|
|||
let diffOptions = ['-x -' . hgDiffOpt]
|
||||
endif
|
||||
|
||||
let resultBuffer = s:DoCommand(join(['diff'] + diffExt + diffOptions + revOptions), 'diff', caption, {})
|
||||
if resultBuffer > 0
|
||||
set filetype=diff
|
||||
else
|
||||
if hgDiffExt == ''
|
||||
echomsg 'No differences found'
|
||||
endif
|
||||
endif
|
||||
return resultBuffer
|
||||
return s:DoCommand(join(['diff'] + diffExt + diffOptions + revOptions), 'diff', caption, {})
|
||||
endfunction
|
||||
|
||||
" Function: s:hgFunctions.Info(argList) {{{2
|
||||
|
|
@ -188,7 +188,7 @@ endfunction
|
|||
function! s:hgFunctions.GetBufferInfo()
|
||||
let originalBuffer = VCSCommandGetOriginalBuffer(bufnr('%'))
|
||||
let fileName = bufname(originalBuffer)
|
||||
let statusText = system(VCSCommandGetOption('VCSCommandHGExec', 'hg') . ' status "' . fileName . '"')
|
||||
let statusText = s:VCSCommandUtility.system(s:Executable() . ' status -- "' . fileName . '"')
|
||||
if(v:shell_error)
|
||||
return []
|
||||
endif
|
||||
|
|
@ -198,11 +198,11 @@ function! s:hgFunctions.GetBufferInfo()
|
|||
return ['Unknown']
|
||||
endif
|
||||
|
||||
let parentsText = system(VCSCommandGetOption('VCSCommandHGExec', 'hg') . ' parents "' . fileName . '"')
|
||||
let [revision] = matchlist(parentsText, '^changeset:\s\+\(\S\+\)\n')[1]
|
||||
let parentsText = s:VCSCommandUtility.system(s:Executable() . ' parents -- "' . fileName . '"')
|
||||
let revision = matchlist(parentsText, '^changeset:\s\+\(\S\+\)\n')[1]
|
||||
|
||||
let logText = system(VCSCommandGetOption('VCSCommandHGExec', 'hg') . ' log "' . fileName . '"')
|
||||
let [repository] = matchlist(logText, '^changeset:\s\+\(\S\+\)\n')[1]
|
||||
let logText = s:VCSCommandUtility.system(s:Executable() . ' log -- "' . fileName . '"')
|
||||
let repository = matchlist(logText, '^changeset:\s\+\(\S\+\)\n')[1]
|
||||
|
||||
if revision == ''
|
||||
" Error
|
||||
|
|
@ -247,12 +247,7 @@ function! s:hgFunctions.Review(argList)
|
|||
let versionOption = ' -r ' . versiontag . ' '
|
||||
endif
|
||||
|
||||
" let resultBuffer = s:DoCommand('cat --non-interactive' . versionOption, 'review', versiontag, {})
|
||||
let resultBuffer = s:DoCommand('cat' . versionOption, 'review', versiontag, {})
|
||||
if resultBuffer > 0
|
||||
let &filetype = getbufvar(b:VCSCommandOriginalBuffer, '&filetype')
|
||||
endif
|
||||
return resultBuffer
|
||||
return s:DoCommand('cat' . versionOption, 'review', versiontag, {})
|
||||
endfunction
|
||||
|
||||
" Function: s:hgFunctions.Status(argList) {{{2
|
||||
|
|
@ -269,7 +264,10 @@ function! s:hgFunctions.Update(argList)
|
|||
return s:DoCommand('update', 'update', '', {})
|
||||
endfunction
|
||||
|
||||
" Annotate setting {{{2
|
||||
let s:hgFunctions.AnnotateSplitRegex = '\d\+: '
|
||||
|
||||
" Section: Plugin Registration {{{1
|
||||
call VCSCommandRegisterModule('HG', expand('<sfile>'), s:hgFunctions, [])
|
||||
let s:VCSCommandUtility = VCSCommandRegisterModule('HG', expand('<sfile>'), s:hgFunctions, [])
|
||||
|
||||
let &cpo = s:save_cpo
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue