Mercurial > hg > mercurial-crew-with-dirclash
changeset 2638:8dadff054acf
merge
author | Vadim Gelfer <vadim.gelfer@gmail.com> |
---|---|
date | Wed, 19 Jul 2006 07:51:56 -0700 |
parents | fcfd46c4a27a (diff) b1436559f1e9 (current diff) |
children | 001703ec311d |
files | contrib/vim/hgcommand.vim |
diffstat | 1 files changed, 44 insertions(+), 35 deletions(-) [+] |
line wrap: on
line diff
--- a/contrib/vim/hgcommand.vim +++ b/contrib/vim/hgcommand.vim @@ -171,7 +171,7 @@ function! s:HGCreateCommandBuffer(cmd, c endif let hgCommand = s:HGGetOption("HGCommandHGExec", "hg") . " " . a:cmd - echomsg "DBG :".hgCommand + "echomsg "DBG :".hgCommand let hgOut = system(hgCommand) " HACK: diff command does not return proper error codes if v:shell_error && a:cmdName != 'hgdiff' @@ -315,18 +315,27 @@ endfunction function! s:HGGetStatusVars(revisionVar, branchVar, repositoryVar) let hgBufferCheck=s:HGCurrentBufferCheck() + "echomsg "DBG : in HGGetStatusVars" if hgBufferCheck == -1 return "" endif let fileName=bufname(hgBufferCheck) - let realFileName = fnamemodify(s:HGResolveLink(fileName), ':t') - let oldCwd=s:HGChangeToCurrentFileDir(fileName) + let fileNameWithoutLink=s:HGResolveLink(fileName) + let realFileName = fnamemodify(fileNameWithoutLink, ':t') + let oldCwd=s:HGChangeToCurrentFileDir(realFileName) try - ""TODO - "if !filereadable('HG/Root') - "return "" - "endif - let hgCommand = s:HGGetOption("HGCommandHGExec", "hg") . " status -mardui " . fileName + let hgCommand = s:HGGetOption("HGCommandHGExec", "hg") . " root " + let roottext=system(hgCommand) + " Suppress ending null char ! Does it work in window ? + let roottext=substitute(roottext,'^.*/\([^/\n\r]*\)\n\_.*$','\1','') + if match(getcwd()."/".fileNameWithoutLink, roottext) == -1 + return "" + endif + let returnExpression = "" + if a:repositoryVar != "" + let returnExpression=returnExpression . " | let " . a:repositoryVar . "='" . roottext . "'" + endif + let hgCommand = s:HGGetOption("HGCommandHGExec", "hg") . " status -mardui " . realFileName let statustext=system(hgCommand) if(v:shell_error) return "" @@ -339,32 +348,23 @@ function! s:HGGetStatusVars(revisionVar, let revision="DELETED" elseif match(statustext, '^[A]') >= 0 let revision="ADDED" - endif + else + " The file is tracked, we can try to get is revision number + let hgCommand = s:HGGetOption("HGCommandHGExec", "hg") . " parents -b " + let statustext=system(hgCommand) + if(v:shell_error) + return "" + endif + let revision=substitute(statustext, '^changeset:\s*\(\d\+\):.*\_$\_.*$', '\1', "") - let hgCommand = s:HGGetOption("HGCommandHGExec", "hg") . " parents -b " - let statustext=system(hgCommand) - if(v:shell_error) - return "" - endif - if exists('revision') - let returnExpression = "let " . a:revisionVar . "='" . revision . "'" - else - let revision=substitute(statustext, '^changeset:\s*\(\d\+\):.*\_$\_.*$', '\1', "") - let returnExpression = "let " . a:revisionVar . "='" . revision . "'" + if a:branchVar != "" && match(statustext, '^\_.*\_^branch:') >= 0 + let branch=substitute(statustext, '^\_.*\_^branch:\s*\(\S\+\)\n\_.*$', '\1', "") + let returnExpression=returnExpression . " | let " . a:branchVar . "='" . branch . "'" + endif endif - - if a:branchVar != "" && match(statustext, '^\_.*\_^branch:') >= 0 - let branch=substitute(statustext, '^\_.*\_^branch:\s*\(\S\+\)\n\_.*$', '\1', "") - let returnExpression=returnExpression . " | let " . a:branchVar . "='" . branch . "'" + if (exists('revision')) + let returnExpression = "let " . a:revisionVar . "='" . revision . "' " . returnExpression endif - if a:repositoryVar != "" - let hgCommand = s:HGGetOption("HGCommandHGExec", "hg") . " root " - let roottext=system(hgCommand) - let repository=substitute(roottext,'^.*/\([^/\n\r]*\)\n\_.*$','\1','') - let returnExpression=returnExpression . " | let " . a:repositoryVar . "='" . repository . "'" - endif - - return returnExpression finally @@ -432,6 +432,11 @@ function! s:HGMarkOrigBufferForSetup(hgB if origBuffer != a:hgBuffer call setbufvar(origBuffer, "HGBufferSetup", 0) endif + else + "We are presumably in the original buffer + let b:HGBufferSetup = 0 + "We do the setup now as now event will be triggered allowing it later. + call s:HGSetupBuffer() endif return a:hgBuffer endfunction @@ -608,6 +613,7 @@ function! HGEnableBufferSetup() augroup HGCommandPlugin au! au BufEnter * call s:HGSetupBuffer() + au BufWritePost * call s:HGSetupBuffer() " Force resetting up buffer on external file change (HG update) au FileChangedShell * call s:HGSetupBuffer(1) augroup END @@ -686,7 +692,7 @@ function! s:HGAnnotate(...) endif let resultBuffer=s:HGDoCommand('annotate -ndu -r ' . revision, 'hgannotate', revision) - echomsg "DBG: ".resultBuffer + "echomsg "DBG: ".resultBuffer if resultBuffer != -1 set filetype=HGAnnotate endif @@ -754,8 +760,7 @@ function! s:HGCommit(...) \ ':call <SID>HGFinishCommit("' . messageFileName . '",' . \ '"' . newCwd . '",' . \ '"' . realFileName . '",' . - \ hgBufferCheck . ')<CR>'. - \ ':call <SID>HGBufferSetup(1)<CR>' + \ hgBufferCheck . ')<CR>' silent 0put ='HG: ----------------------------------------------------------------------' silent put =\"HG: Enter Log. Lines beginning with `HG:' are removed automatically\" @@ -908,7 +913,6 @@ endfunction " Function: s:HGUpdate() {{{2 function! s:HGUpdate() return s:HGMarkOrigBufferForSetup(s:HGDoCommand('update', 'update', '')) - call s:HGSetupBuffer(1) endfunction " Function: s:HGVimDiff(...) {{{2 @@ -1673,6 +1677,11 @@ 8. Known bugs *hgcommand-bugs may still be bugs in here, depending on many configuration details. ============================================================================== + +9. TODO *hgcommand-todo* + + Integrate symlink tracking once HG will support them. +============================================================================== === END_DOC """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " v im:tw=78:ts=8:ft=help:norl: