[PATCH] hgcommnd.vim had conflicts with !sudo tee

Ali Vakilzade ali.vakilzade at gmail.com
Sat May 3 09:58:31 CDT 2014


this command is generally used in vim to write current file as root: 
!sudo tee % >/dev/null

when I execute this command these error messages popup in vim

Error detected while processing function 
<SNR>17_HGSetupBuffer..<SNR>17_HGGetSta
tusVars..<SNR>17_HGChangeToCurrentFileDir:
line    5:
E811: Not allowed to change buffer information now
Error detected while processing function 
<SNR>17_HGSetupBuffer..<SNR>17_HGGetSta
tusVars:
line   55:
E811: Not allowed to change buffer information now

I have added try/catch to those lines of vim plugin to avoid these 
errors messages:

# HG changeset patch
# User Ali Vakilzade <ali.vakilzade at gmail.com>
# Date 1399128111 -16200
#      Sat May 03 19:11:51 2014 +0430
# Branch stable
# Node ID ebee81f0b3b9b9d5b90cdda01acfc948fa4f7c24
# Parent  cadad384c97c7956c98f3c9b92d8cc40fa16d93b
use try catch in vim plugin to avoid conflicts

diff -r cadad384c97c -r ebee81f0b3b9 contrib/vim/hgcommand.vim
--- a/contrib/vim/hgcommand.vim    Thu May 01 17:48:02 2014 -0500
+++ b/contrib/vim/hgcommand.vim    Sat May 03 19:11:51 2014 +0430
@@ -105,7 +105,7 @@
    let fileName=<SID>HGResolveLink(a:fileName)
    let newCwd=fnamemodify(fileName, ':h')
    if strlen(newCwd) > 0
-    execute 'cd' escape(newCwd, ' ')
+    try | execute 'cd' escape(newCwd, ' ') | catch | | endtry
    endif
    return oldCwd
  endfunction
@@ -396,7 +396,7 @@

      return returnExpression
    finally
-    execute 'cd' escape(oldCwd, ' ')
+    try | execute 'cd' escape(oldCwd, ' ') | catch | | endtry
    endtry
  endfunction




More information about the Mercurial-devel mailing list