Tuesday, August 9, 2011

Editor for mercurial

Last evening one of  my co-worker was sitting beside me, as I was pushing in some changes into the  project repository. And as I hit the "hg commit" command my "gvim" editor popes up for writing the commit message, and this buddy of mine sitting besides me asks me how did do you do that, howcome your gvim pops up whereas on my computer the same command opens a vi editor in the same terminal. I was like its easy,  I set the editor up in the Mercurial config file the famous ".hgrc" file.
Then he goes no, thats not the case because I have copied over your ".hgrc" file long back and if it was that file, then it would have been happening for me as well. I was like hmm let me see what I did. Then I realized that I have the UBUNTU environment variable EDITOR set for me to "/usr/bin/gvim  -f" ......that explains everything.


For making proper sense out of what I mean by above incidence, read the following explanation :

Mercurial tries to pick which program to call to edit a commit message by trying the following (in order):
  1. HGEDITOR environment variable
  2. editor configuration option in [ui] section (in hgrc or passed with --config ui.editor command-line option).
  3. VISUAL environment variable
  4. EDITOR environment variable
  5. vi, if none of the above is set

    So the above explanation suggests that I was actually using option 4 above, but I thought I was using option 2 while I explained to the co-worker 
    and on the hind side now its clear that my co-worker was using was option 5.  

No comments:

Post a Comment