##// END OF EJS Templates
Do not try to get revision and branch information for file which are not tracked
"Mathieu Clabaut " -
r2636:733fff9b default
parent child Browse files
Show More
@@ -315,6 +315,7 b' endfunction'
315 315
316 316 function! s:HGGetStatusVars(revisionVar, branchVar, repositoryVar)
317 317 let hgBufferCheck=s:HGCurrentBufferCheck()
318 "echomsg "DBG : in HGGetStatusVars"
318 319 if hgBufferCheck == -1
319 320 return ""
320 321 endif
@@ -326,15 +327,19 b' function! s:HGGetStatusVars(revisionVar,'
326 327 let hgCommand = s:HGGetOption("HGCommandHGExec", "hg") . " root "
327 328 let roottext=system(hgCommand)
328 329 " Suppress ending null char ! Does it work in window ?
329 let roottext=substitute(roottext, '.$', '', "")
330 let roottext=substitute(roottext,'^.*/\([^/\n\r]*\)\n\_.*$','\1','')
330 331 if match(getcwd()."/".fileNameWithoutLink, roottext) == -1
331 332 return ""
332 333 endif
334 let returnExpression = ""
333 335 let hgCommand = s:HGGetOption("HGCommandHGExec", "hg") . " status -mardui " . fileName
334 336 let statustext=system(hgCommand)
335 337 if(v:shell_error)
336 338 return ""
337 339 endif
340 if a:repositoryVar != ""
341 let returnExpression=returnExpression . " | let " . a:repositoryVar . "='" . roottext . "'"
342 endif
338 343 if match(statustext, '^[?I]') >= 0
339 344 let revision="NEW"
340 345 elseif match(statustext, '^[R]') >= 0
@@ -343,32 +348,23 b' function! s:HGGetStatusVars(revisionVar,'
343 348 let revision="DELETED"
344 349 elseif match(statustext, '^[A]') >= 0
345 350 let revision="ADDED"
346 endif
351 else
352 " The file is tracked, we can try to get is revision number
353 let hgCommand = s:HGGetOption("HGCommandHGExec", "hg") . " parents -b "
354 let statustext=system(hgCommand)
355 if(v:shell_error)
356 return ""
357 endif
358 let revision=substitute(statustext, '^changeset:\s*\(\d\+\):.*\_$\_.*$', '\1', "")
347 359
348 let hgCommand = s:HGGetOption("HGCommandHGExec", "hg") . " parents -b "
349 let statustext=system(hgCommand)
350 if(v:shell_error)
351 return ""
352 endif
353 if exists('revision')
354 let returnExpression = "let " . a:revisionVar . "='" . revision . "'"
355 else
356 let revision=substitute(statustext, '^changeset:\s*\(\d\+\):.*\_$\_.*$', '\1', "")
357 let returnExpression = "let " . a:revisionVar . "='" . revision . "'"
360 if a:branchVar != "" && match(statustext, '^\_.*\_^branch:') >= 0
361 let branch=substitute(statustext, '^\_.*\_^branch:\s*\(\S\+\)\n\_.*$', '\1', "")
362 let returnExpression=returnExpression . " | let " . a:branchVar . "='" . branch . "'"
363 endif
358 364 endif
359
360 if a:branchVar != "" && match(statustext, '^\_.*\_^branch:') >= 0
361 let branch=substitute(statustext, '^\_.*\_^branch:\s*\(\S\+\)\n\_.*$', '\1', "")
362 let returnExpression=returnExpression . " | let " . a:branchVar . "='" . branch . "'"
365 if (exists('revision'))
366 let returnExpression = "let " . a:revisionVar . "='" . revision . "' " . returnExpression
363 367 endif
364 if a:repositoryVar != ""
365 let hgCommand = s:HGGetOption("HGCommandHGExec", "hg") . " root "
366 let roottext=system(hgCommand)
367 let repository=substitute(roottext,'^.*/\([^/\n\r]*\)\n\_.*$','\1','')
368 let returnExpression=returnExpression . " | let " . a:repositoryVar . "='" . repository . "'"
369 endif
370
371
372 368
373 369 return returnExpression
374 370 finally
@@ -436,6 +432,11 b' function! s:HGMarkOrigBufferForSetup(hgB'
436 432 if origBuffer != a:hgBuffer
437 433 call setbufvar(origBuffer, "HGBufferSetup", 0)
438 434 endif
435 else
436 "We are presumably in the original buffer
437 let b:HGBufferSetup = 0
438 "We do the setup now as now event will be triggered allowing it later.
439 call s:HGSetupBuffer()
439 440 endif
440 441 return a:hgBuffer
441 442 endfunction
@@ -612,6 +613,7 b' function! HGEnableBufferSetup()'
612 613 augroup HGCommandPlugin
613 614 au!
614 615 au BufEnter * call s:HGSetupBuffer()
616 au BufWritePost * call s:HGSetupBuffer()
615 617 " Force resetting up buffer on external file change (HG update)
616 618 au FileChangedShell * call s:HGSetupBuffer(1)
617 619 augroup END
@@ -758,8 +760,7 b' function! s:HGCommit(...)'
758 760 \ ':call <SID>HGFinishCommit("' . messageFileName . '",' .
759 761 \ '"' . newCwd . '",' .
760 762 \ '"' . realFileName . '",' .
761 \ hgBufferCheck . ')<CR>'.
762 \ ':call <SID>HGBufferSetup(1)<CR>'
763 \ hgBufferCheck . ')<CR>'
763 764
764 765 silent 0put ='HG: ----------------------------------------------------------------------'
765 766 silent put =\"HG: Enter Log. Lines beginning with `HG:' are removed automatically\"
@@ -912,7 +913,6 b' endfunction'
912 913 " Function: s:HGUpdate() {{{2
913 914 function! s:HGUpdate()
914 915 return s:HGMarkOrigBufferForSetup(s:HGDoCommand('update', 'update', ''))
915 call s:HGSetupBuffer(1)
916 916 endfunction
917 917
918 918 " Function: s:HGVimDiff(...) {{{2
General Comments 0
You need to be logged in to leave comments. Login now