contrib/vim/hgcommand.vim
changeset 2634 105708ba518f
parent 2607 070736e20dfd
child 2635 37bcccf8a683
--- a/contrib/vim/hgcommand.vim	Sat Jul 15 13:09:46 2006 +0200
+++ b/contrib/vim/hgcommand.vim	Tue Jul 18 18:35:47 2006 +0200
@@ -171,7 +171,7 @@
   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'
@@ -319,13 +319,17 @@
     return ""
   endif
   let fileName=bufname(hgBufferCheck)
-  let realFileName = fnamemodify(s:HGResolveLink(fileName), ':t')
+  let fileNameWithoutLink=s:HGResolveLink(fileName)
+  let realFileName = fnamemodify(fileNameWithoutLink, ':t')
   let oldCwd=s:HGChangeToCurrentFileDir(fileName)
   try
-     ""TODO
-    "if !filereadable('HG/Root')
-      "return ""
-    "endif
+    let hgCommand = s:HGGetOption("HGCommandHGExec", "hg") . " root  " 
+    let roottext=system(hgCommand)
+    " Suppress ending null char ! Does it work in window ?
+    let roottext=substitute(roottext, '.$', '', "")
+    if match(getcwd()."/".fileNameWithoutLink, roottext) == -1
+      return ""
+    endif
     let hgCommand = s:HGGetOption("HGCommandHGExec", "hg") . " status -mardui " . fileName
     let statustext=system(hgCommand)
     if(v:shell_error)
@@ -686,7 +690,7 @@
   endif
 
   let resultBuffer=s:HGDoCommand('annotate -ndu -r ' . revision, 'hgannotate', revision) 
-  echomsg "DBG: ".resultBuffer
+  "echomsg "DBG: ".resultBuffer
   if resultBuffer !=  -1
     set filetype=HGAnnotate
   endif