[PATCH] allow http authentication information to be specified in the configuration

Benoit Boissinot benoit.boissinot at ens-lyon.org
Mon Apr 6 16:49:19 CDT 2009


On Mon, Apr 06, 2009 at 11:12:54PM +0200, Benoit Boissinot wrote:

This patch has a bug, with the fix below it passes the testsuite
(except for a small bug in statichttprepo.py, I didn't notice path was
used below, the fix is to just add ui in the call to getauthinfo() and
not touch the path variable.

> # HG changeset patch
> # User Sune Foldager <cryo at cyanite.org>
> # Date 1238961876 -7200
> # Node ID d2632947ec737a0f0e29ba07d2facb11c29b3797
> # Parent  685ce2f7ee35dfe29d296f80ba2dff124a1caa63
> allow http authentication information to be specified in the configuration
> 
> diff --git a/mercurial/url.py b/mercurial/url.py
> --- a/mercurial/url.py
> +++ b/mercurial/url.py
> @@ -271,6 +272,30 @@
>          authinfo = None
>      return url, authinfo
>  
> +def getauthinfo(ui, path):
> +    path, authinfo = urlauthinfo(path)
> +    if authinfo:
> +        return path, authinfo
> +
> +    def splituserpass(userpass):
> +        return netlocsplit(userpass + '@localhost')[2:4]
> +
> +    fuzzyauthn = dict(ui.configitems('auth'))
> +
> +    default_auth = fuzzyauthn.pop('*', None)
> +    if default_auth:
> +        default_auth = splituserpass(default_auth)
> +
> +    fuzzyauthn = [(url, splituserpass(userpass))
> +                  for url, userpass in fuzzyauthn.iteritems()]
> +    fuzzyauthn.sort()
> +    # find closest matching prefix
> +    i = bisect.bisect(fuzzyauthn, path)
> +    if path.startswith(fuzzyauthn[i][0]):

should be "if fuzzyauthn and path.startswith(...):"
otherwise it throws indexerror when the list is empty.

regards,

Benoit

-- 
:wq


More information about the Mercurial-devel mailing list