Capistrano, Mercurial and Password Prompts

So I’m using Mercurial for version control on a Ruby on Rails project, along with Capistrano for automating deployment and running remote tasks. These are great tools and I’m finding that they work well together with the Mercurial SCM module by Matthew Elder introduced in Cap 2.0.

I came across one problem though: my repository is hosted over HTTP because I don’t want to give everyone access to a shell account for SSH, and the hg SCM module didn’t support prompting for passwords (whether you’re using HTTP authentication or SSH without a public key). This effectively meant that if you wanted Cap to deploy from a repo served in either of these ways, you’d need to put your password in plain text in your Cap recipes.

I don’t like the idea of that, so I created a patch to fix it, along with another minor point or two that I found, and added some unit tests. You can get more details and take a look at the patch on the ticket I submitted. It’s been committed, so if you’re using Capistrano from SVN, you’re set, just svn up.

If you’ve installed Cap from a gem and want a quick fix, you can replace mercurial.rb in your installation with the one attached to this post. On my system, it lives at this directory path:

/usr/local/lib/ruby/gems/1.8/gems/capistrano-2.1.0/lib/capistrano/recipes/deploy/scm/

This will probably work with Cap 2.0, though I’ve only tried with 2.1. The Mercurial module hasn’t changed much.

I should note that on my systems I’ve had to set the option for requesting pseudo-ttys in my recipes, or else Mercurial tries to run non-interactively and password prompting won’t work. If you have that problem, use this:

default_run_options[:pty] = true

If anyone comes up with a nice way to load the new stuff as a monkeypatch in a project, I’d love to hear about it. I’ve been unsuccessful at trying to hook it in through recipes or the Capfile, and it’d be nice to have some way of doing that while waiting for the next gem release. I’d rather not ask my team to check out Capistrano from SVN or run around modifying their installation if I can avoid it.

Update:
And, in short order, Cap 2.2.0 has been released. The fix below is rolled in, so just gem install capistrano and you can forget about the rest!

AttachmentSize
mercurial.rb4.57 KB

Comments

nice information, it help

nice information, it help alot! my friend is also a ruby user.

life insurance %-O home

fVqYbV nuwpfgjnnxdv,

fVqYbV nuwpfgjnnxdv, [url=http://xsjiabwhdkai.com/]xsjiabwhdkai[/url], [link=http://syrinoxksrdu.com/]syrinoxksrdu[/link], http://qwoouvxvmdwu.com/

sm8IBK cvkfxvwzwmio,

sm8IBK cvkfxvwzwmio, [url=http://uaibxtaitwxk.com/]uaibxtaitwxk[/url], [link=http://pvmhlgeviwyr.com/]pvmhlgeviwyr[/link], http://ivjvxtekaczu.com/

cheapest car insurance 9212

auto insurance oqoj

california homeowners

discount auto insurance 51058

comment5, Cialis, Health

tBLElm tuedcsnayzet,

tBLElm tuedcsnayzet, [url=http://teggjyudijsd.com/]teggjyudijsd[/url], [link=http://afcwytvumrrb.com/]afcwytvumrrb[/link], http://tnzboksbtcwq.com/

GwxiUq ojhvnskcrdgf,

GwxiUq ojhvnskcrdgf, [url=http://mgzhdcahthpe.com/]mgzhdcahthpe[/url], [link=http://tqsgiocusifa.com/]tqsgiocusifa[/link], http://gmcewgrrpyfi.com/

fsfsdfsl Palawan Island

fsfsdfsl Palawan Island fsfsfsdsd.seis !

rkBsqp mlkqvfpsodol,

rkBsqp mlkqvfpsodol, [url=http://outxidfkxaol.com/]outxidfkxaol[/url], [link=http://rwxhyeljcddl.com/]rwxhyeljcddl[/link], http://mgepwrxjaavv.com/

uP3adT

health insurance quotes

health insurance quotes mlovz

Post new comment

The content of this field is kept private and will not be shown publicly.