You are viewing a read-only archive of the Blogs.Harvard network. Learn more.
Skip to content

Getting Mercurial Win32 to use SSH and vim right

I’ve been playing with Mercurial a bit recently as I wanted to get the hang of a Distributed Source Code Management (DSCM) tool better. I’ll save my reasoning for choosing Mercurial for another time. Let’s get to the troubleshooting part.

Mercurial provides a Windows version and some instructions on getting it running for basic cases however what I found I needed were:

  • Repository syncing via SSH
  • Getting vim to fire up as my default editor when I made commits

After a little bit of head-scratching I finally figured out these are the steps you need to get those working:

  1. Install Mercurial Win32
  2. Install cygwin and make sure to also choose openssh from the packages you install with cygwin. If you like some other ssh client from the command line you can use that but I couldn’t get plink to work properly but cygwin worked fine for me
  3. Install the Windows version of vim and make sure that vim is added to your PATH (I believe you have to check this setting during install)
  4. Ensure vim works from the command line and you can use ssh from cygwin
  5. Configure in %MERCURIAL_HOME%\Mercurial.ini (Default is C:\Mercurial\Mercurial.ini) the following:

    editor = vim
    ssh = C:\cygwin\bin\ssh.exe

Dumb trivial aside: It seems you can call cygwin commands directly without the cygwin shell if you have C:\cygwin\bin in your path. Although it might get confusing since cygwin also does path munging to make it feel more like UNIX

Now you should be able to use hg from either cygwin or the normal Windows shell properly. Enjoy.

Be Sociable, Share!