324 let oldCwd=s:HGChangeToCurrentFileDir(fileName) |
325 let oldCwd=s:HGChangeToCurrentFileDir(fileName) |
325 try |
326 try |
326 let hgCommand = s:HGGetOption("HGCommandHGExec", "hg") . " root " |
327 let hgCommand = s:HGGetOption("HGCommandHGExec", "hg") . " root " |
327 let roottext=system(hgCommand) |
328 let roottext=system(hgCommand) |
328 " Suppress ending null char ! Does it work in window ? |
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 if match(getcwd()."/".fileNameWithoutLink, roottext) == -1 |
331 if match(getcwd()."/".fileNameWithoutLink, roottext) == -1 |
331 return "" |
332 return "" |
332 endif |
333 endif |
|
334 let returnExpression = "" |
333 let hgCommand = s:HGGetOption("HGCommandHGExec", "hg") . " status -mardui " . fileName |
335 let hgCommand = s:HGGetOption("HGCommandHGExec", "hg") . " status -mardui " . fileName |
334 let statustext=system(hgCommand) |
336 let statustext=system(hgCommand) |
335 if(v:shell_error) |
337 if(v:shell_error) |
336 return "" |
338 return "" |
|
339 endif |
|
340 if a:repositoryVar != "" |
|
341 let returnExpression=returnExpression . " | let " . a:repositoryVar . "='" . roottext . "'" |
337 endif |
342 endif |
338 if match(statustext, '^[?I]') >= 0 |
343 if match(statustext, '^[?I]') >= 0 |
339 let revision="NEW" |
344 let revision="NEW" |
340 elseif match(statustext, '^[R]') >= 0 |
345 elseif match(statustext, '^[R]') >= 0 |
341 let revision="REMOVED" |
346 let revision="REMOVED" |
342 elseif match(statustext, '^[D]') >= 0 |
347 elseif match(statustext, '^[D]') >= 0 |
343 let revision="DELETED" |
348 let revision="DELETED" |
344 elseif match(statustext, '^[A]') >= 0 |
349 elseif match(statustext, '^[A]') >= 0 |
345 let revision="ADDED" |
350 let revision="ADDED" |
346 endif |
|
347 |
|
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 |
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 |
356 let revision=substitute(statustext, '^changeset:\s*\(\d\+\):.*\_$\_.*$', '\1', "") |
358 let revision=substitute(statustext, '^changeset:\s*\(\d\+\):.*\_$\_.*$', '\1', "") |
357 let returnExpression = "let " . a:revisionVar . "='" . revision . "'" |
359 |
358 endif |
360 if a:branchVar != "" && match(statustext, '^\_.*\_^branch:') >= 0 |
359 |
361 let branch=substitute(statustext, '^\_.*\_^branch:\s*\(\S\+\)\n\_.*$', '\1', "") |
360 if a:branchVar != "" && match(statustext, '^\_.*\_^branch:') >= 0 |
362 let returnExpression=returnExpression . " | let " . a:branchVar . "='" . branch . "'" |
361 let branch=substitute(statustext, '^\_.*\_^branch:\s*\(\S\+\)\n\_.*$', '\1', "") |
363 endif |
362 let returnExpression=returnExpression . " | let " . a:branchVar . "='" . branch . "'" |
364 endif |
363 endif |
365 if (exists('revision')) |
364 if a:repositoryVar != "" |
366 let returnExpression = "let " . a:revisionVar . "='" . revision . "' " . returnExpression |
365 let hgCommand = s:HGGetOption("HGCommandHGExec", "hg") . " root " |
367 endif |
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 return returnExpression |
369 return returnExpression |
374 finally |
370 finally |
375 execute 'cd' escape(oldCwd, ' ') |
371 execute 'cd' escape(oldCwd, ' ') |
376 endtry |
372 endtry |
434 let origBuffer = s:HGBufferCheck(a:hgBuffer) |
430 let origBuffer = s:HGBufferCheck(a:hgBuffer) |
435 "This should never not work, but I'm paranoid |
431 "This should never not work, but I'm paranoid |
436 if origBuffer != a:hgBuffer |
432 if origBuffer != a:hgBuffer |
437 call setbufvar(origBuffer, "HGBufferSetup", 0) |
433 call setbufvar(origBuffer, "HGBufferSetup", 0) |
438 endif |
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 endif |
440 endif |
440 return a:hgBuffer |
441 return a:hgBuffer |
441 endfunction |
442 endfunction |
442 |
443 |
443 " Function: s:HGOverrideOption(option, [value]) {{{2 |
444 " Function: s:HGOverrideOption(option, [value]) {{{2 |
756 \ ':g/^HG:/d<CR>'. |
758 \ ':g/^HG:/d<CR>'. |
757 \ ':update<CR>'. |
759 \ ':update<CR>'. |
758 \ ':call <SID>HGFinishCommit("' . messageFileName . '",' . |
760 \ ':call <SID>HGFinishCommit("' . messageFileName . '",' . |
759 \ '"' . newCwd . '",' . |
761 \ '"' . newCwd . '",' . |
760 \ '"' . realFileName . '",' . |
762 \ '"' . realFileName . '",' . |
761 \ hgBufferCheck . ')<CR>'. |
763 \ hgBufferCheck . ')<CR>' |
762 \ ':call <SID>HGBufferSetup(1)<CR>' |
|
763 |
764 |
764 silent 0put ='HG: ----------------------------------------------------------------------' |
765 silent 0put ='HG: ----------------------------------------------------------------------' |
765 silent put =\"HG: Enter Log. Lines beginning with `HG:' are removed automatically\" |
766 silent put =\"HG: Enter Log. Lines beginning with `HG:' are removed automatically\" |
766 silent put ='HG: Type <leader>cc (or your own <Plug>HGCommit mapping)' |
767 silent put ='HG: Type <leader>cc (or your own <Plug>HGCommit mapping)' |
767 |
768 |