Patchwork [V3] record: --user/-u now works with record when ui.username not set (issue3857)

login
register
mail settings
Submitter Prasoon Shukla
Date Dec. 12, 2013, 9:43 a.m.
Message ID <8d8bb0493d5c9defda6d.1386841407@jimmypage>
Download mbox | patch
Permalink /patch/3214/
State Accepted
Commit a765611e06dc8e0ce9be4f25ee8e18d72f1b9580
Headers show

Comments

Prasoon Shukla - Dec. 12, 2013, 9:43 a.m.
# HG changeset patch
# User Prasoon Shukla <prasoon92.iitr@gmail.com>
# Date 1386831356 -19800
#      Thu Dec 12 12:25:56 2013 +0530
# Node ID 8d8bb0493d5c9defda6d0122cb6c3caee8102486
# 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 by checking for the 'user' key in the opts
dictionary. If the key is present, the step causing the exception is not
executed.
Sean Farley - Dec. 12, 2013, 8:27 p.m.
prasoon92.iitr@gmail.com writes:

> # HG changeset patch
> # User Prasoon Shukla <prasoon92.iitr@gmail.com>
> # Date 1386831356 -19800
> #      Thu Dec 12 12:25:56 2013 +0530
> # Node ID 8d8bb0493d5c9defda6d0122cb6c3caee8102486
> # 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 by checking for the 'user' key in the opts
> dictionary. If the key is present, the step causing the exception is not
> executed.
>
> diff -r 1c92524c37cd -r 8d8bb0493d5c hgext/record.py
> --- a/hgext/record.py	Sun Dec 01 21:24:48 2013 -0600
> +++ b/hgext/record.py	Thu Dec 12 12:25:56 2013 +0530
> @@ -502,7 +502,8 @@
>                           cmdsuggest)
>  
>      # make sure username is set before going interactive
> -    ui.username()
> +    if not opts.get('user'):
> +        ui.username() # raise exception, username not provided
>  
>      def recordfunc(ui, repo, message, match, opts):
>          """This is generic record driver.
> diff -r 1c92524c37cd -r 8d8bb0493d5c tests/test-record.t
> --- a/tests/test-record.t	Sun Dec 01 21:24:48 2013 -0600
> +++ b/tests/test-record.t	Thu Dec 12 12:25:56 2013 +0530
> @@ -1277,5 +1277,25 @@
>     c
>    +d
>    
> +Test --user when ui.username not set
> +  $ unset HGUSER
> +  $ echo e >> subdir/f1
> +  $ hg record  --config ui.username= -d '8 0' --user xyz -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?] 
> +  $ hg log --template '{author}\n' -l 1
> +  xyz
> +  $ HGUSER="test"
> +  $ export HGUSER
>  
>    $ cd ..

This looks much better and looks good to me. Thanks for sticking through it!
Augie Fackler - Dec. 13, 2013, 5:43 p.m.
On Thu, Dec 12, 2013 at 03:13:27PM +0530, Prasoon Shukla wrote:
> # HG changeset patch
> # User Prasoon Shukla <prasoon92.iitr@gmail.com>
> # Date 1386831356 -19800
> #      Thu Dec 12 12:25:56 2013 +0530
> # Node ID 8d8bb0493d5c9defda6d0122cb6c3caee8102486
> # Parent  1c92524c37cdd251c1a36b2da0fb4148b0e6ba09
> record: --user/-u now works with record when ui.username not set (issue3857)

queued, thanks (also thanks to smf for reviewing earlier rounds)

>
> The -u flag didn't work when ui.username was not set and resulted in an
> abort message. This was fixed by checking for the 'user' key in the opts
> dictionary. If the key is present, the step causing the exception is not
> executed.
>
> diff -r 1c92524c37cd -r 8d8bb0493d5c hgext/record.py
> --- a/hgext/record.py	Sun Dec 01 21:24:48 2013 -0600
> +++ b/hgext/record.py	Thu Dec 12 12:25:56 2013 +0530
> @@ -502,7 +502,8 @@
>                           cmdsuggest)
>
>      # make sure username is set before going interactive
> -    ui.username()
> +    if not opts.get('user'):
> +        ui.username() # raise exception, username not provided
>
>      def recordfunc(ui, repo, message, match, opts):
>          """This is generic record driver.
> diff -r 1c92524c37cd -r 8d8bb0493d5c tests/test-record.t
> --- a/tests/test-record.t	Sun Dec 01 21:24:48 2013 -0600
> +++ b/tests/test-record.t	Thu Dec 12 12:25:56 2013 +0530
> @@ -1277,5 +1277,25 @@
>     c
>    +d
>
> +Test --user when ui.username not set
> +  $ unset HGUSER
> +  $ echo e >> subdir/f1
> +  $ hg record  --config ui.username= -d '8 0' --user xyz -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?]
> +  $ hg log --template '{author}\n' -l 1
> +  xyz
> +  $ HGUSER="test"
> +  $ export HGUSER
>
>    $ cd ..
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel

Patch

diff -r 1c92524c37cd -r 8d8bb0493d5c hgext/record.py
--- a/hgext/record.py	Sun Dec 01 21:24:48 2013 -0600
+++ b/hgext/record.py	Thu Dec 12 12:25:56 2013 +0530
@@ -502,7 +502,8 @@ 
                          cmdsuggest)
 
     # make sure username is set before going interactive
-    ui.username()
+    if not opts.get('user'):
+        ui.username() # raise exception, username not provided
 
     def recordfunc(ui, repo, message, match, opts):
         """This is generic record driver.
diff -r 1c92524c37cd -r 8d8bb0493d5c tests/test-record.t
--- a/tests/test-record.t	Sun Dec 01 21:24:48 2013 -0600
+++ b/tests/test-record.t	Thu Dec 12 12:25:56 2013 +0530
@@ -1277,5 +1277,25 @@ 
    c
   +d
   
+Test --user when ui.username not set
+  $ unset HGUSER
+  $ echo e >> subdir/f1
+  $ hg record  --config ui.username= -d '8 0' --user xyz -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?] 
+  $ hg log --template '{author}\n' -l 1
+  xyz
+  $ HGUSER="test"
+  $ export HGUSER
 
   $ cd ..