This patch addresses a handful of issues with the Mercurial module, the largest being the one in subject line.
The current Hg module requires that :scm_password be set in recipes if you're using a repository with HTTP authentication or SSH without a public key. Actually, the latter doesn't work correctly anyway, because the password regex in #handle_data doesn't catch the 'user@host.com's password:' style of prompt for SSH. I'm currently using HTTP auth on a project, and I don't want to put the password in plaintext in the recipe file. I suspect many others feel the same way =)
Also, the module uses :scm_user instead of the now-preferred :scm_username variable, and it has no unit tests.
The affixed patch addresses these issues as follows:
- password regex uses word boundary instead of start-of-line, like some other SCM modules. This catches an SSH prompt or Mercurial's prompt for HTTP auth.
- supports :scm_username with backwards compatibility for those who have :scm_user in existing recipes
- honors Cap 2.1's :scm_prefer_prompt variable and will prompt for passwords if :scm_password is not set. If neither variable is set, falls back on the current behavior of raising an exception with an informative message.
- provides unit tests for the module, including the new functionality above.
The patch was built against revision [8916]. I don't believe the module has changed since the 2.1 release, so the attached diff should apply cleanly to mercurial.rb for users of the 2.1 gem. I'll try to contact Matthew Elder as well.