Patchwork [V3] url: added authuri when login information is requested (issue3209)

login
register
mail settings
Submitter Lucas Moscovicz
Date Jan. 17, 2014, 1:22 a.m.
Message ID <74c8ded4f411da6c0f5e.1389921771@devrs047.prn2.facebook.com>
Download mbox | patch
Permalink /patch/3363/
State Accepted
Commit 7d589d923b8a1ae7b920a88cf66a79d3faa330b5
Headers show

Comments

Lucas Moscovicz - Jan. 17, 2014, 1:22 a.m.
# HG changeset patch
# User Lucas Moscovicz <lmoscovicz@fb.com>
# Date 1389833180 28800
#      Wed Jan 15 16:46:20 2014 -0800
# Node ID 74c8ded4f411da6c0f5e6a2893cdc99f47316ed6
# Parent  f694cd81b600b65d23dcdc7a02cfd6a57dd1d018
url: added authuri when login information is requested (issue3209)

When users are using a revset they can get multiple password prompts.
This prompts have no extra information about which password is being requested
so I added the authuri to the prompt to make it recognizable.

As in:
$ hg log -r "outgoing('https://bitbucket.org/mg/test') -
outgoing('https://bitbucket.org/nesneros/test')"
http authorization required
realm: Bitbucket.org HTTP
user: interrupted!

I changed it to describe the url when prompting for password.
As in:
$ hg log -r "outgoing('https://bitbucket.org/mg/test') -
outgoing('https://bitbucket.org/nesneros/test')"
http authorization required for https://bitbucket.org/mg/test
realm: Bitbucket.org HTTP
user: interrupted!
Matt Mackall - Jan. 18, 2014, 3:14 a.m.
On Thu, 2014-01-16 at 17:22 -0800, Lucas Moscovicz wrote:
> # HG changeset patch
> # User Lucas Moscovicz <lmoscovicz@fb.com>
> # Date 1389833180 28800
> #      Wed Jan 15 16:46:20 2014 -0800
> # Node ID 74c8ded4f411da6c0f5e6a2893cdc99f47316ed6
> # Parent  f694cd81b600b65d23dcdc7a02cfd6a57dd1d018
> url: added authuri when login information is requested (issue3209)

Queued for default, thanks. Check-code.py had the following thoughts to
share with you:

mercurial/url.py:36:
 >             u.query=None
 missing whitespace in assignment
tests/test-http.t:162:
 >   >   return "pass" 
 trailing whitespace on non-output

Patch

diff --git a/mercurial/url.py b/mercurial/url.py
--- a/mercurial/url.py
+++ b/mercurial/url.py
@@ -32,10 +32,14 @@ 
                 user, passwd = auth.get('username'), auth.get('password')
                 self.ui.debug("using auth.%s.* for authentication\n" % group)
         if not user or not passwd:
+            u = util.url(authuri)
+            u.query=None
             if not self.ui.interactive():
-                raise util.Abort(_('http authorization required'))
+                raise util.Abort(_('http authorization required for %s') %
+                                 util.hidepassword(str(u)))
 
-            self.ui.write(_("http authorization required\n"))
+            self.ui.write(_("http authorization required for %s\n") %
+                          util.hidepassword(str(u)))
             self.ui.write(_("realm: %s\n") % realm)
             if user:
                 self.ui.write(_("user: %s\n") % user)
diff --git a/tests/test-http.t b/tests/test-http.t
--- a/tests/test-http.t
+++ b/tests/test-http.t
@@ -156,12 +156,24 @@ 
   >    --config server.preferuncompressed=True
   $ cat pid >> $DAEMON_PIDS
 
+  $ cat << EOF > get_pass.py
+  > import getpass
+  > def newgetpass(arg):
+  >   return "pass" 
+  > getpass.getpass = newgetpass
+  > EOF
+
   $ hg id http://localhost:$HGPORT2/
-  abort: http authorization required
+  abort: http authorization required for http://localhost:$HGPORT2/
   [255]
-  $ hg id http://user@localhost:$HGPORT2/
-  abort: http authorization required
+  $ hg id http://localhost:$HGPORT2/
+  abort: http authorization required for http://localhost:$HGPORT2/
   [255]
+  $ hg id --config ui.interactive=true --config extensions.getpass=get_pass.py http://user@localhost:$HGPORT2/
+  http authorization required for http://localhost:$HGPORT2/
+  realm: mercurial
+  user: user
+  password: 5fed3813f7f5
   $ hg id http://user:pass@localhost:$HGPORT2/
   5fed3813f7f5
   $ echo '[auth]' >> .hg/hgrc
@@ -183,7 +195,7 @@ 
   5 files updated, 0 files merged, 0 files removed, 0 files unresolved
 
   $ hg id http://user2@localhost:$HGPORT2/
-  abort: http authorization required
+  abort: http authorization required for http://localhost:$HGPORT2/
   [255]
   $ hg id http://user:pass2@localhost:$HGPORT2/
   abort: HTTP Error 403: no