Hint for setting the username

Simon King simon at simonking.org.uk
Tue Jul 9 11:32:30 CDT 2013


On Tue, Jul 9, 2013 at 3:51 PM, Arne Babenhauserheide <arne_bab at web.de> wrote:
> Hi,
>
> As followup on the earlier discussion¹, I created a patch for adding a hint how to add the username.
>
> # HG changeset patch
> # User Arne Babenhauserheide <arne_bab at web.de>
> # Date 1373381124 -7200
> #      Tue Jul 09 16:45:24 2013 +0200
> # Node ID ffab6750bcc27f226ac8d3face81ff42baed5302
> # Parent  648d1974b3f328947ee6cf2d00c66815a33cd208
> when no username is set, provide a hint with the user rcfile.
>
> diff -r 648d1974b3f3 -r ffab6750bcc2 mercurial/ui.py
> --- a/mercurial/ui.py   Sun Jun 30 15:19:39 2013 -0500
> +++ b/mercurial/ui.py   Tue Jul 09 16:45:24 2013 +0200
> @@ -448,7 +448,8 @@
>              except KeyError:
>                  pass
>          if not user:
> -            raise util.Abort(_('no username supplied (see "hg help config")'))
> +            raise util.Abort(_('no username supplied (see "hg help config")\n'
> +                               '(add section [ui] with username = YOURNAME in %s)')%scmutil.userrcpath()[0])
>          if "\n" in user:
>              raise util.Abort(_("username %s contains a newline\n") % repr(user))
>          return user
>
>
> You can also pull it from bitbucket as ffab6750bcc27f226ac8d3face81ff42baed5302:
>
>     https://bitbucket.org/ArneBab/hg-stable/
>
>
> Best wishes,
> Arne
>
> ¹: discussion about the new-user workflow breaking when a username is
>    required:
>    http://draketo.de/light/english/dvcs-workflow-failures-git-hg

(Presuming to be qualified to review patches, which I'm really not)

This falls foul of a number of rules on
http://mercurial.selenic.com/wiki/ContributingChanges and
http://mercurial.selenic.com/wiki/CodingStyle. Specifically, the ones
about patch description, line length, and spaces around operators.

>From a more technical point of view, the Abort exception accepts a
"hint" keyword parameter. Hints will automatically be displayed after
the main message:

  http://selenic.com/hg/file/fbdac607bff3/mercurial/dispatch.py#l52

The irony (or whatever) of rejecting a patch that aims to make it
easier for people to contribute changes is not lost on me...

Simon


More information about the Mercurial-devel mailing list