[RFC] [PATCH] username: default should be prompt if no username are found

Matt Mackall mpm at selenic.com
Mon May 3 17:53:26 CDT 2010


On Sun, 2010-05-02 at 14:51 +0200, Benoit Boissinot wrote:
> Let's start with the history:
> 
>    0:9117c6561b0b: username is selected based only on env ($HGUSER), if
>                    unset it is constructed from fqdn + login
> later revisions only adds more env variable ($EMAIL, $USERNAME, etc.)
> 
>  608:d2994b5298fb: moves the code to ui.py, deprecates $HGUSER and
>                    checks ui.username in hgrc
> 3461:8b55c0ba8048: make the username mandatory, don't fallback to the
>        	    fqdn+login method (some people where annoyed by this
>        	    behaviour, since you end up with login at localhost
>        	    often)
> 3721:98f2507c5551: reverts 3461, only print a warning instead of abort
>        	    (the idea was that abort was not nice for new users,
>        	    and that it doesn't give a good first impression
>        	    when your first commit tells you "abort: blabla")
> 6862:7192876ac329: adds the ui.askusername config option, if set to
>                    True, prompts the user for a username
> 9612:c63c336ee2f7: aborts instead of using fqdn+login when interactive
> 
> I think that we should have used something along the patch first
> proposed by Martin instead: http://markmail.org/thread/kzjofsq3gvxju5we
> 
> I think the prompt should be more explicit, maybe with an example how a
> typical username looks like, e.g. Jane Doe <jdoe at example.com>
> (suggestions welcome).

Yes, it should really suggest a standard email address.

> cheers,
> 
> Benoit
> 
> # HG changeset patch
> # User Benoit Boissinot <benoit.boissinot at ens-lyon.org>
> # Date 1272800489 -7200
> # Node ID 1440c8733558fafd0049af1898199ef7a7bbe216
> # Parent  c2601c2163333a2f8913efc95e83f74dc0e912ad
> commit: if interactive and no username have been found, ask the user
> 
> diff --git a/mercurial/ui.py b/mercurial/ui.py
> --- a/mercurial/ui.py
> +++ b/mercurial/ui.py
> @@ -268,7 +268,10 @@
>              user = self.config("ui", "username")
>          if user is None:
>              user = os.environ.get("EMAIL")
> -        if user is None and self.configbool("ui", "askusername"):
> +        ask = self.configbool("ui", "askusername", None)
> +        if user is None and (ask or ask is None):
> +            if ask is None and self.interactive():
> +                ui.warn(_('No username supplied (see "hg help config")\n'))
>              user = self.prompt(_("enter a commit username:"), default=None)

This defaults to:

                user = '%s@%s' % (util.getuser(), socket.getfqdn())

Perhaps we should show this in the prompt.

-- 
Mathematics is the supreme nostalgia of our time.




More information about the Mercurial-devel mailing list