[MERGE] Prompt for user names if they are not in the configuration.

Vincent Ladeuil v.ladeuil+lp at free.fr
Wed Apr 1 10:15:17 BST 2009


>>>>> "Jelmer" == Jelmer Vernooij <jelmer at samba.org> writes:

    Jelmer> Hi Vincent,
    Jelmer> On Tue, Mar 31, 2009 at 05:36:08PM +0200, Vincent Ladeuil wrote:
    >> >>>>> "Jelmer" == Jelmer Vernooij <jelmer at samba.org> writes:

    >> <snip/>

    Jelmer> === modified file 'bzrlib/config.py'
    Jelmer> --- bzrlib/config.py	2009-03-23 14:59:43 +0000
    Jelmer> +++ bzrlib/config.py	2009-03-31 14:22:01 +0000
    Jelmer> @@ -1152,6 +1152,17 @@
    Jelmer> user = credentials['user']
    Jelmer> else:
    Jelmer> user = None
    Jelmer> +        # Prompt user if we couldn't find a username
    Jelmer> +        if user is None:
    Jelmer> +            if prompt is None:
    Jelmer> +                # Create a default prompt suitable for most cases
    Jelmer> +                prompt = scheme.upper() + ' %(host)s username'
    Jelmer> +            # Special handling for optional fields in the prompt
    Jelmer> +            if port is not None:
    Jelmer> +                prompt_host = '%s:%d' % (host, port)
    Jelmer> +            else:
    Jelmer> +                prompt_host = host
    Jelmer> +            user = ui.ui_factory.get_username(prompt, host=prompt_host)
    Jelmer> return user

    >> You can't do that here unconditionally or you'll break the actual
    >> bzr policy of defaulting to getpass.getuser().

    Jelmer> Thanks for the review.

    Jelmer> Can we perhaps have get_username() default to
    Jelmer> getpass.getuser() ?
    Jelmer> I'm thinking of a prompt like:

    Jelmer> HTTP www.foo.com username [jelmer]: 

    Jelmer> Where just pressing <enter> will use "jelmer".

Sure.

    Jelmer> Where exactly does bzr default to getpass.getuser()
    Jelmer> atm?

It used to do that for *all* protocols. I dropped it for http
(semi-consciously) and nobody ever complained.

    Jelmer> It seems strange to assume that the user has the same
    Jelmer> username on a remote FTP server as on the local
    Jelmer> machine.

You tell me :-)

But that's the way it is.

And it makes sense on intranets (people already complain about
multiple passwords so they tend to use the same login everywhere
they can).

Anyway, since authentication.conf can address using the same user
on any subnet, I think proposing getpass.getuser() as a default
can be restored for all protocols when the user is prompted.

     Vincent



More information about the bazaar mailing list