configwizard: Ask user for IRC nick when configuring review path (Bug 1284948) r?gps draft
authorConnor Sheehan <sheehan@mozilla.com>
Thu, 11 Jan 2018 17:26:39 -0500
changeset 11987 eb807264eb22a96562f0385373b9be30c6dc07ea
parent 11983 ec49538a6fb503c43c3b5d18cfc6cf9f13ed9d0f
push id1862
push userbmo:sheehan@mozilla.com
push dateFri, 12 Jan 2018 16:34:30 +0000
reviewersgps
bugs1284948
configwizard: Ask user for IRC nick when configuring review path (Bug 1284948) r?gps Asks the user to input their IRC nick to add to MozReview pushes. MozReview-Commit-ID: 8eZQlXvPFUh
hgext/configwizard/__init__.py
hgext/configwizard/tests/test-codereview.t
--- a/hgext/configwizard/__init__.py
+++ b/hgext/configwizard/__init__.py
@@ -80,16 +80,23 @@ to author commits, you'll need to define
 
 This data will be publicly available when you send commits/patches to others.
 If you aren't comfortable giving us your full name, pseudonames are
 acceptable.
 
 (Relevant config option: ui.username)
 '''.lstrip()
 
+MISSING_IRCNICK = '''
+You don't have a Mozilla IRC nickname defined in your Mercurial config file.
+You will need to add your nick in order to push commits to MozReview.
+
+(Relevant config option: mozilla.ircnick)
+'''
+
 BAD_DIFF_SETTINGS = '''
 Mercurial is not configured to produce diffs in a more readable format.
 
 Would you like to change this (Yn)? $$ &Yes $$ &No
 '''.strip()
 
 PAGER_INFO = '''
 The "pager" extension transparently redirects command output to a pager
@@ -897,41 +904,46 @@ def _checkcodereview(ui, cw):
 
     if not bzuser:
         bzuser = ui.prompt('What is your Bugzilla email address? (optional)', default='')
 
     if bzuser and not bzapikey:
         ui.write(BUGZILLA_API_KEY_INSTRUCTIONS)
         bzapikey = ui.prompt('Please enter a Bugzilla API Key: (optional)', default='')
 
-    if bzuser or bzapikey:
-        if 'bugzilla' not in cw.c:
-            cw.c['bugzilla'] = {}
-
-    if bzuser:
-        cw.c['bugzilla']['username'] = bzuser
-    if bzapikey:
-        cw.c['bugzilla']['apikey'] = bzapikey
 
     if any(ui.hasconfig('bugzilla', c) for c in ('password', 'userid', 'cookie')):
         ui.write(LEGACY_BUGZILLA_CREDENTIALS_DETECTED)
 
     for c in ('password', 'userid', 'cookie'):
         try:
             del cw.c['bugzilla'][c]
         except KeyError:
             pass
 
     prompt = ('Configure the "review" path so you can `hg push review` commits to '
              'Mozilla for review (Yn)? $$ &Yes $$ &No')
     if not ui.config('paths', 'review') and not ui.promptchoice(prompt):
         cw.c.setdefault('paths', {})
         cw.c['paths']['review'] = 'https://reviewboard-hg.mozilla.org/autoreview'
 
-    # TODO configure mozilla.ircnick
+    if not ui.config('mozilla', 'ircnick'):
+        ircnick = ui.prompt('What is your IRC nick? ', default=None)
+        if ircnick:
+            cw.c.setdefault('mozilla', {})
+            cw.c['mozilla']['ircnick'] = ircnick
+
+    if bzuser or bzapikey:
+        if 'bugzilla' not in cw.c:
+            cw.c['bugzilla'] = {}
+
+    if bzuser:
+        cw.c['bugzilla']['username'] = bzuser
+    if bzapikey:
+        cw.c['bugzilla']['apikey'] = bzapikey
 
 
 def _checkmultiplevct(ui, cw):
     # References to multiple version-control-tools checkouts can confuse
     # version-control-tools since various Mercurial extensions resolve
     # dependencies via __file__. Files from different revisions could lead
     # to unexpected environments and break things.
     seenvct = set()
--- a/hgext/configwizard/tests/test-codereview.t
+++ b/hgext/configwizard/tests/test-codereview.t
@@ -54,16 +54,17 @@ reviewboard is enabled when requested
   use Bugzilla for authentication, you'll need to supply an API Key.
   
   The Bugzilla API Key is optional. However, if you don't supply one,
   certain features may not work and/or you'll be prompted for one.
   
   You should only need to configure a Bugzilla API Key once.
   What is your Bugzilla email address? (optional) 
   Configure the "review" path so you can `hg push review` commits to Mozilla for review (Yn)?  y
+  What is your IRC nick?  
   Your config file needs updating.
   Would you like to see a diff of the changes first (Yn)?  y
   --- hgrc.old
   +++ hgrc.new
   @@ -0,0 +1,4 @@
   +[extensions]
   +reviewboard = */hgext/reviewboard/client.py (glob)
   +[paths]
@@ -81,16 +82,17 @@ only bzexport can be enabled when reques
 
   $ hg --config ui.interactive=true --config configwizard.steps=codereview,configchange configwizard << EOF
   > 
   > y
   > 3
   > someone@example.com
   > apikey
   > y
+  > mynick
   > y
   > y
   > EOF
   This wizard will guide you through configuring Mercurial for an optimal
   experience contributing to Mozilla projects.
   
   The wizard makes no changes without your permission.
   
@@ -122,55 +124,63 @@ only bzexport can be enabled when reques
   
   Please perform the following steps:
   
     1) Open https://bugzilla.mozilla.org/userprefs.cgi?tab=apikey
     2) Generate a new API Key
     3) Copy the generated key and paste it here
   Please enter a Bugzilla API Key: (optional) apikey
   Configure the "review" path so you can `hg push review` commits to Mozilla for review (Yn)?  y
+  What is your IRC nick?  mynick
   Your config file needs updating.
   Would you like to see a diff of the changes first (Yn)?  y
   --- hgrc.old
   +++ hgrc.new
-  @@ -1,4 +1,8 @@
+  @@ -1,4 +1,10 @@
    [extensions]
    reviewboard = */hgext/reviewboard/client.py (glob)
   +bzexport = */hgext/bzexport (glob)
    [paths]
    review = https://reviewboard-hg.mozilla.org/autoreview
+  +[mozilla]
+  +ircnick = mynick
   +[bugzilla]
   +username = someone@example.com
   +apikey = apikey
   
   Write changes to hgrc file (Yn)?  y
 
+
   $ cat .hgrc
   [extensions]
   reviewboard = */hgext/reviewboard/client.py (glob)
   bzexport = */hgext/bzexport (glob)
   [paths]
   review = https://reviewboard-hg.mozilla.org/autoreview
+  [mozilla]
+  ircnick = mynick
   [bugzilla]
   username = someone@example.com
   apikey = apikey
 
+
 Legacy credentials are removed from config file
 
   $ cat >> .hgrc << EOF
   > cookie = bzcookie
   > EOF
 
   $ hg --config ui.interactive=true --config bugzilla.cookie=cookie --config configwizard.steps=codereview,configchange configwizard << EOF
   > 
   > y
   > 3
   > someone2@example.com
   > apikey2
   > y
+  > mynick
   > y
   > y
   > EOF
   This wizard will guide you through configuring Mercurial for an optimal
   experience contributing to Mozilla projects.
   
   The wizard makes no changes without your permission.
   
@@ -209,23 +219,24 @@ Legacy credentials are removed from conf
   Your existing Mercurial config uses a legacy method for defining Bugzilla
   credentials. Bugzilla API Keys are the most secure and preferred method
   for defining Bugzilla credentials. Bugzilla API Keys are also required
   if you have enabled 2 Factor Authentication in Bugzilla.
   
   For security reasons, the legacy credentials are being removed from the
   config.
   Configure the "review" path so you can `hg push review` commits to Mozilla for review (Yn)?  y
+  What is your IRC nick?  mynick
   Your config file needs updating.
   Would you like to see a diff of the changes first (Yn)?  y
   --- hgrc.old
   +++ hgrc.new
-  @@ -4,6 +4,5 @@
-   [paths]
-   review = https://reviewboard-hg.mozilla.org/autoreview
+  @@ -6,6 +6,5 @@
+   [mozilla]
+   ircnick = mynick
    [bugzilla]
   -username = someone@example.com
   -apikey = apikey
   -cookie = bzcookie
   +username = someone2@example.com
   +apikey = apikey2
   
   Write changes to hgrc file (Yn)?  y