[PATCH] config: allow 'user' in .hgrc ui section (issue3169)

Augie Fackler raf at durin42.com
Sat Jul 26 09:36:04 CDT 2014


On Jul 26, 2014, at 2:27 AM, anatoly techtonik <techtonik at gmail.com> wrote:

> # HG changeset patch
> # User anatoly techtonik <techtonik at gmail.com>
> # Date 1406356031 -10800
> #      Sat Jul 26 09:27:11 2014 +0300
> # Node ID 7c1a32d12c36165253c48f947ef7ccf0fe090e7b
> # Parent  7142e04b438eab39685e63085503b8af0e42b31e
> config: allow 'user' in .hgrc ui section (issue3169)
> 
> diff -r 7142e04b438e -r 7c1a32d12c36 mercurial/ui.py
> --- a/mercurial/ui.py	Fri Jul 18 19:46:56 2014 -0400
> +++ b/mercurial/ui.py	Sat Jul 26 09:27:11 2014 +0300
> @@ -438,6 +438,8 @@
>         user = os.environ.get("HGUSER")
>         if user is None:
>             user = self.config("ui", "username")
> +            if user is None:
> +                user = self.config("ui", "user")

You could actually do

self.config('ui', ['username', 'user'])

instead. See:

http://selenic.com/hg/file/868e2cea3ea0/mercurial/ui.py#l174

(I have no feelings one way or the other on accepting this patch - I'll leave that to others, but it might be nice to use the alternates support built into ui.ui.config.)

>             if user is not None:
>                 user = os.path.expandvars(user)
>         if user is None:
> diff -r 7142e04b438e -r 7c1a32d12c36 tests/test-committer.t
> --- a/tests/test-committer.t	Fri Jul 18 19:46:56 2014 -0400
> +++ b/tests/test-committer.t	Sat Jul 26 09:27:11 2014 +0300
> @@ -63,4 +63,17 @@
>   abort: empty username!
>   [255]
> 
> +  $ echo 1234 > asdf
> +  $ echo "[ui]" > .hg/hgrc
> +  $ echo "user = Foo Bar II <foo2 at bar.com>" >> .hg/hgrc
> +  $ hg commit -m commit-1
> +  $ hg tip
> +  changeset:   5:83fd986938c3
> +  tag:         tip
> +  user:        Foo Bar II <foo2 at bar.com>
> +  date:        Thu Jan 01 00:00:00 1970 +0000
> +  summary:     commit-1
> +  
> +  $ rm .hg/hgrc
> +
>   $ cd ..
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://selenic.com/pipermail/mercurial-devel/attachments/20140726/0af6f60d/attachment.pgp>


More information about the Mercurial-devel mailing list