[PATCH] record: --user/-u now works with record when ui.username not set (issue3857)
Pierre-Yves David
pierre-yves.david at ens-lyon.org
Tue Dec 10 03:28:54 CST 2013
On 12/10/2013 12:47 AM, Prasoon Shukla wrote:
> # HG changeset patch
> # User Prasoon Shukla <prasoon92.iitr at gmail.com>
> # Date 1386665165 -19800
> # Tue Dec 10 14:16:05 2013 +0530
> # Node ID 662044cd452faa1e39a633a3fbf7daa5b07a1830
> # Parent 1c92524c37cdd251c1a36b2da0fb4148b0e6ba09
> record: --user/-u now works with record when ui.username not set (issue3857)
>
> The -u flag didn't work when ui.username was not set and resulted in an
> abort message. This was fixed.
>
> diff -r 1c92524c37cd -r 662044cd452f hgext/record.py
> --- a/hgext/record.py Sun Dec 01 21:24:48 2013 -0600
> +++ b/hgext/record.py Tue Dec 10 14:16:05 2013 +0530
> @@ -502,7 +502,14 @@
> cmdsuggest)
>
> # make sure username is set before going interactive
> - ui.username()
> + try:
> + ui.username()
> + except:
> + # username not set so we check whether --user was provided
> + if opts.has_key('user'):
> + ui.setconfig('ui', 'username', opts['user'])
> + # check again, abort if username not set
> + ui.username()
I believe it is not necessary to overwrite the value in ui to have this
working
It is even a bad idea to overwrite le configuration.
(note: you should check the `get` method of dictionary)
> def recordfunc(ui, repo, message, match, opts):
> """This is generic record driver.
> diff -r 1c92524c37cd -r 662044cd452f tests/test-record.t
> --- a/tests/test-record.t Sun Dec 01 21:24:48 2013 -0600
> +++ b/tests/test-record.t Tue Dec 10 14:16:05 2013 +0530
> @@ -1277,5 +1277,20 @@
> c
> +d
>
> +Test -u flag when ui.username not set
> + $ echo e >> subdir/f1
> + $ hg record --config ui.username= -d '8 0' -m "user flag" <<EOF
> + > y
> + > y
> + > EOF
> + diff --git a/subdir/f1 b/subdir/f1
> + 1 hunks, 1 lines changed
> + examine changes to 'subdir/f1'? [Ynesfdaq?]
> + @@ -4,3 +4,4 @@
> + b
> + c
> + d
> + +e
> + record this change to 'subdir/f1'? [Ynesfdaq?]
>
> $ cd ..
How come I do not see any --user in your test ?
(note we usually prefer long version of argument in test for readability
purpose)
--
Pierre-Yves David
More information about the Mercurial-devel
mailing list