We are test driving Mercurial at work. We don't want to have to enter our user/pass each time we interact with a repository, so we set up the mercurial_keyring extension. We:
And then made the appropriate changes to %userprofile%/mercurial.ini in the [auth]
section. It works fine on my colleague's computer (32bit xp sp3), but it does not work on my machine (Windows 7 Ultimate x64). Also noteworthy, the setuptools had to be built from source on Win 7 x64 (python setup.py bdist_wininst
, then run the resulting setuptools-0.6c11.win-amd64.exe).
Using just hg.exe from the Mercurial 1.5 binary installation (the .msi), I get this error when I run hg.exe:
*** failed to import extension mercurial_keyring: No module named mercurial_keyring
I tried to change my mercurial.ini, to specify the path to the mercurial_keyring.py file, instead of having mercurial find it (since it's in the PYTHONPATH).
Old:
[extensions]
mercurial_keyring =
New:
[extensions] mercurial_keyring =
c:/mercurial/extensions/mercurial_keyring.py
The error changes to:
abort: could not import module keyring!
So while providing the path to the mercurial_keyring extension works, the dependent keyring module still cannot be found.
After further investigation, it appears that NO extensions work. They all produce the error:
*** failed to import extension [extension name]: No module named [module name]
It appears that when running hg.exe, it is not aware of PYTHONPATH. I have tried:
Nothing works. The closest I've got is using hg.py when building from source. It at least doesn't give me errors, and actually creates %userprofile%/wincrypto_pass.cfg when I enter my credentials. But on subsequent requests, it doesn't enter the credentials automatically. It prompts me for them again.
Interestingly, TortoiseHG is using the keyring. I just can't get it to work on the command line. I think something is going on with Win 7 x64 that is preventing mercurial (hg.exe) from seeing the PYTHONPATH, so it can't find any of the installed modules.
Does anyone have extensions working in Win 7 x64? Specifically with the binary installation of mercurial (not hg.py)?
UPDATE I've found a suitable work around for now. Since TortoiseHG does work with mercurial_keyring, I've simply changed my PATH setup to include the tortoiseHG folder, but not c:\mercurial. Now when I type "hg" at the command line, it's using the hg.exe in the tortoiseHG folder, which works fine. Just the same, this is still a problem with mercurial extensions on Win 7 x64. Answers welcome.
Answering my own question with my previous update, since there are no other takers yet.
Suitable workaround: Since TortoiseHG does work with mercurial_keyring, I've simply changed my PATH to include the tortoiseHG folder, and exclude c:\mercurial. Now when I type "hg" at the command line, it's using the hg.exe in the tortoiseHG folder, which works fine with the keyring.
I'm using:
On both setups, all configured extensions are loaded without errors.
All tools are installed using the installers provided on their sites. Mercurial appears before TortoiseHg in PATH. I'm using a common configuration file ~/.hgrc
for both tools, and a Mercurial.ini
file in TortoiseHg installation folder that is loading just the mercurial_keyring
extension.
On the command line I have to input the password every time it's needed, but in TortoiseHg the keyring extensions it's fully working.
From the Keyring Extension page on the Mercurial wiki:
If you are on Windows, we recommend you use TortoiseHg. THG ships with Windows specific keyring backends, without which the mercurial-keyring extension cannot function properly on Windows.
UPDATE http://asimilatorul.com/adapter/post/using-mercurial_keyring-extension-with-mercurial-on-windows/
You can copy the required files from TortoiseHg's library.zip into Mercurial's library.zip:
The extension page states that TortoiseHG has some additional components to make it work on Windows and that it doesn't work properly without them. It sounds like the workaround of referencing the TortoiseHG version may be the easiest way to get it working on Windows.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With