mozhg: make prompt default argument an empty string (
bug 1247044); r?smacleod
Mercurial 3.7 enforces that the value for "default" be a string or
character buffer object. We were previously passing None, which is
neither. This was causing the prompt to throw a TypeError on Mercurial
3.7.
Since we're only checking truthiness of the result, it doesn't matter if
it is an empty string or None, since they are both Falsy. So use an
empty string.
MozReview-Commit-ID: 9O9FPbnokMu
--- a/hgext/bzexport/tests/test-auth.t
+++ b/hgext/bzexport/tests/test-auth.t
@@ -23,41 +23,41 @@ Dummy out profiles directory to prevent
$ hg init repo
$ cd repo
$ touch foo
$ hg -q commit -A -m initial
No auth info should lead to prompting (verifies mozhg.auth is hooked up)
$ hg newbug --product TestProduct --component TestComponent -t 'No auth' 'dummy'
- Bugzilla username: None
+ Bugzilla username:
abort: unable to obtain Bugzilla authentication.
[255]
bzexport.username is deprecated and should print a warning
$ hg --config bzexport.username=olduser newbug --product TestProduct --component TestComponent -t 'old username' 'dummy'
(the bzexport.username config option is deprecated and ignored; use bugzilla.username instead)
- Bugzilla username: None
+ Bugzilla username:
abort: unable to obtain Bugzilla authentication.
[255]
bzexport.password is deprecated and should print a warning
$ hg --config bzexport.password=oldpass newbug --product TestProduct --component TestComponent -t 'old password' 'dummy'
(the bzexport.password config option is deprecated and ignored; use bugzilla.password or cookie auth by logging into Bugzilla in Firefox)
- Bugzilla username: None
+ Bugzilla username:
abort: unable to obtain Bugzilla authentication.
[255]
bzexport.api_server is deprecated and should print a warning
$ hg --config bzexport.api_server=http://dummy/bzapi newbug --product TestProduct --component TestComponent -t 'api server' 'dummy'
(the bzexport.api_server config option is deprecated and ignored; delete it from your config)
- Bugzilla username: None
+ Bugzilla username:
abort: unable to obtain Bugzilla authentication.
[255]
Invalid cookie should result in appropriate error message
$ hg --config bugzilla.userid=badid --config bugzilla.cookie=badcookie newbug --product TestProduct --component TestComponent -t 'Bad Cookie' 'dummy'
Refreshing configuration cache for http://$DOCKER_HOSTNAME:$HGPORT/bzapi/
Using default version 'unspecified' of product TestProduct
--- a/hgext/reviewboard/tests/test-errors.t
+++ b/hgext/reviewboard/tests/test-errors.t
@@ -115,17 +115,17 @@ Attempt to push with Bugzilla not config
pushing to http://localhost:$HGPORT/
(adding commit id to 2 changesets)
saved backup bundle to $TESTTMP/client/.hg/strip-backup/54e4f001f1bf*-addcommitid.hg (glob)
searching for changes
remote: adding changesets
remote: adding manifests
remote: adding file changes
remote: added 2 changesets with 1 changes to 1 files (+1 heads)
- Bugzilla username: None
+ Bugzilla username:
Bugzilla credentials not available. Not submitting review.
Configure authentication
$ cat >> .hg/hgrc << EOF
> [bugzilla]
> username = user
> password = pass
--- a/pylib/mozhg/mozhg/auth.py
+++ b/pylib/mozhg/mozhg/auth.py
@@ -92,20 +92,20 @@ def getbugzillaauth(ui, require=False, p
if userid and cookie:
return BugzillaAuth(userid=userid, cookie=cookie)
except NoSQLiteError:
ui.warn('SQLite unavailable. Unable to look for Bugzilla cookie.\n')
break
if not username:
- username = ui.prompt(_('Bugzilla username:'), None)
+ username = ui.prompt(_('Bugzilla username:'), '')
if not password:
- password = ui.getpass(_('Bugzilla password: '), None)
+ password = ui.getpass(_('Bugzilla password: '), '')
if username and password:
return BugzillaAuth(username=username, password=password)
if require:
raise util.Abort(_('unable to obtain Bugzilla authentication.'))
return None
--- a/pylib/mozhg/mozhg/tests/test-hg-auth.t
+++ b/pylib/mozhg/mozhg/tests/test-hg-auth.t
@@ -9,23 +9,23 @@ generic Mercurial perspective.
> EOF
Dummy out the profiles directory to prevent running system from leaking in
$ export FIREFOX_PROFILES_DIR=`pwd`
If nothing defined and not interactive, we get no auth
$ hg bzauth
- Bugzilla username: None
+ Bugzilla username:
no auth
If nothing defined and not interactive and we require input, we should abort
$ hg bzauth --require
- Bugzilla username: None
+ Bugzilla username:
abort: unable to obtain Bugzilla authentication.
[255]
If nothing defined, we get prompted for username and password
$ hg --config ui.interactive=true bzauth --fakegetpass fakepass << EOF
> user-i
> EOF
Bugzilla username: user-i
@@ -123,24 +123,24 @@ Now we set up some Firefox profiles to t
> Path=profile2
> EOF
$ mkdir profiles/foo profiles/profile2
Empty profile should have no cookies and should get nothing
$ hg bzauth
- Bugzilla username: None
+ Bugzilla username:
no auth
Profile with cookie from an unknown Bugzilla should get nothing
$ hg bzcreatecookie profiles/foo http://dummy/ dummyuser dummypass
$ hg bzauth
- Bugzilla username: None
+ Bugzilla username:
no auth
Profile with cookie from BMO should be returned
$ hg bzcreatecookie profiles/foo https://bugzilla.mozilla.org/ bmouser bmocookie
$ hg bzauth
userid: bmouser
cookie: bmocookie