Confirming user name and password

Martin Geisler mg at lazybytes.net
Tue May 3 03:24:39 CDT 2011


Jason Harris <jason at jasonfharris.com> writes:

> Hi,
>
> From MacHg I just discovered the following: I am likely just missing
> something but is there a command which will test to see if a user-name
> + password are acceptable to a server?

There is no command that just tests the password -- but you can work
around the problem, see below.

> I was using the identify command to see if I could log in with the
> given username and password.
>
> [Volt:~/test/exclude-changesets] exclude-changesets 3(3) ⌘ hg identify --rev tip https://jfh:dog@bitbucket.org/jfh/exclude-changesets
> 8169bbc96762
> [Volt:~/test/exclude-changesets] exclude-changesets 3(3) ⌘ hg identify --rev tip https://jfh:cat@bitbucket.org/jfh/exclude-changesets
> 8169bbc96762
>
> Clearly the password can't be both dog and cat. Is it a bug that the
> server doesn't reject the request when the password is incorrect?
> Actually is this bitbucket specific?

No, the explanation is much simpler: you are authenticated as needed,
and read-only operations require no authentication on a public repo.

You should do a dummy operation that requires authentication. In
Mercurial that means an operation that pushes something to the repo.
Since you don't want to push random changesets around for this check, I
suggest you instead try pushing a new pushkey namespace:

Here it works because I have setup my [auth] section:

  $ hg debugpushkey --noninteractive \
       https://bitbucket.org/mg/hg-i18n \
       namespaces key old new
  False

The False you see is because changing 'key' from 'old' to 'new' failed.
Pushing to the 'namespaces' namespace always fails.

Here it fails since my authentication doesn't work for your repo:

  $ hg debugpushkey --noninteractive \
       https://bitbucket.org/jfh/exclude-changesets \
       namespaces key old new
  abort: http authorization required

So this is a work-around in Mercurial.

-- 
Martin Geisler

Mercurial links: http://mercurial.ch/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: <http://selenic.com/pipermail/mercurial-devel/attachments/20110503/a0364016/attachment.pgp>


More information about the Mercurial-devel mailing list