Kiln’s kilnauth.py crashes under python 2.4
We recently switched to using Mercurial hosted at Joel Spolsky’s Kiln. So far I love it. I think distributed source control is the way of the future and I’m all for it.
Anyway, Kiln provides a number of useful Mercurial plugins, one of which is called ‘kilnauth’ and helps by caching your http authentication cookies so you don’t have to enter your password a bunch of times. I was setting this up on our linux box, which only has python 2.4, and kilnauth was causing a crash when it tried to do an md5 hash. The fix is pretty easy. Near the top where they import the md5 library, change this line:
try:
from hashlib import md5
except:
# Python 2.4
import md5
To this:
try:
from hashlib import md5
except:
# Python 2.4
from md5 import md5
That’s it. Simple little typo that they probably just didn’t test.
And on the subject of passwords, if you are bothered that capistrano outputs your inline http authentication passwords to the console, you can install this gem I wrote, cap_password_filter, to fix that.
To help out with searching, I’m including the full stack trace of the error:
** unknown exception encountered, details follow
** report bug details to http://mercurial.selenic.com/bts/
** or mercurial@selenic.com
** Mercurial Distributed SCM (version 1.5)
** Extensions loaded: kilnauth
Traceback (most recent call last):
File "/usr/bin/hg", line 27, in ?
mercurial.dispatch.run()
File "/usr/lib/python2.4/site-packages/mercurial/dispatch.py", line 16, in run
sys.exit(dispatch(sys.argv[1:]))
File "/usr/lib/python2.4/site-packages/mercurial/dispatch.py", line 30, in dispatch
return _runcatch(u, args)
File "/usr/lib/python2.4/site-packages/mercurial/dispatch.py", line 47, in _runcatch
return _dispatch(ui, args)
File "/usr/lib/python2.4/site-packages/mercurial/dispatch.py", line 466, in _dispatch
return runcommand(lui, repo, cmd, fullargs, ui, options, d)
File "/usr/lib/python2.4/site-packages/mercurial/dispatch.py", line 336, in runcommand
ret = _runcommand(ui, options, cmd, d)
File "/usr/lib/python2.4/site-packages/mercurial/dispatch.py", line 517, in _runcommand
return checkargs()
File "/usr/lib/python2.4/site-packages/mercurial/dispatch.py", line 471, in checkargs
return cmdfunc()
File "/usr/lib/python2.4/site-packages/mercurial/dispatch.py", line 465, in
d = lambda: util.checksignature(func)(ui, *args, **cmdoptions)
File “/usr/lib/python2.4/site-packages/mercurial/util.py”, line 401, in check
return func(*args, **kwargs)
File “/usr/lib/python2.4/site-packages/mercurial/commands.py”, line 677, in clone
branch=opts.get(’branch’))
File “/usr/lib/python2.4/site-packages/mercurial/hg.py”, line 209, in clone
src_repo = repository(ui, source)
File “/usr/lib/python2.4/site-packages/mercurial/hg.py”, line 82, in repository
repo = _lookup(path).instance(ui, path, create)
File “/usr/lib/python2.4/site-packages/mercurial/httprepo.py”, line 271, in instance
inst.between([(nullid, nullid)])
File “/usr/lib/python2.4/site-packages/mercurial/httprepo.py”, line 190, in between
d = self.do_read(”between”, pairs=n)
File “/usr/lib/python2.4/site-packages/mercurial/httprepo.py”, line 134, in do_read
fp = self.do_cmd(cmd, **args)
File “/usr/lib/python2.4/site-packages/mercurial/httprepo.py”, line 85, in do_cmd
resp = self.urlopener.open(req)
File “/home/xxx/kilnauth.py”, line 145, in open
cj = get_cookiejar(ui)
File “/home/xxx/kilnauth.py”, line 66, in get_cookiejar
cookie_path = os.path.join(cookie_path, md5(current_user).hexdigest())
File “/usr/lib/python2.4/site-packages/mercurial/demandimport.py”, line 71, in __call__
raise TypeError(”%s object is not callable” % repr(self))