HGEDITOR is an environment variable that can be used to control which editor Mercurial uses for commit messages.