Patchwork hgcommnd.vim had conflicts with !sudo tee

login
register
mail settings
Submitter Ali Vakilzade
Date May 3, 2014, 2:58 p.m.
Message ID <53650417.9070304@gmail.com>
Download mbox | patch
Permalink /patch/4585/
State Accepted
Headers show

Comments

Ali Vakilzade - May 3, 2014, 2:58 p.m.
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@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
Matt Mackall - May 29, 2014, 10:24 p.m.
On Sat, 2014-05-03 at 19:28 +0430, Ali Vakilzade wrote:
> 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@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

I've queued this after fixing various whitespace mangling from your
email client making the summary line conform to our standards, thanks.
Please take a closer look at ContributingChanges on the wiki and your
patches will get handled more quickly.

Patch

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