Commits

Patrick Mézard committed b01d694

clpush: print email recipients when emailing

  • Participants
  • Parent commits 0bec2a8

Comments (0)

Files changed (2)

File lib/codereview/codereview.py

 		else:
 			pmsg += "Please take another look.\n"
 		typecheck(pmsg, str)
+		prefix = 'emailing: '
+		if onlyprint:
+			prefix = 'would have emailed: '
+		for i, recipient in enumerate(self.reviewer + self.cc):
+			op = i == 0 and prefix or ' '*len(prefix)
+			ui.status(op + recipient + '\n')
 		PostMessage(ui, self.name, pmsg, subject=self.Subject(),
 				reviewers=JoinComma(self.reviewer),
 				cc=JoinComma(self.cc), send_mail=not onlyprint)
 	ctype = "applications/x-www-form-urlencoded"
 	body = urllib.urlencode(form_fields)
 	response = MySend("/" + issue + "/publish", body, content_type=ctype)
-	if response != "":
-		print response
-		sys.exit(2)
+	if response:
+		raise hg_util.Abort(response)
 
 def DeleteCL(issue):
 	# Get the edit form for the xsrf token
 			'cannot create or update changelist from a changeset with a '
 			'non-public parent')
 
-
-review_opts = [
-	('r', 'reviewer', '', 'add reviewer'),
-	('', 'cc', '', 'add cc'),
-]
 @hgcommand('^clpush',
 	[('', 'email', False, 'send an email about the changelist update'),
 	 ('', 'print-email', False, 'only print the email, do not sent it'),

File tests/test-clpush.t

   $ hg phase --draft --force .
   $ hg clpush --email --print-email .
   Issue updated. URL: https://codereview.appspot.com/\d+ (re)
+  would have emailed: invalid@example.com
   
   Hello invalid@example.com,
   
 
 Mailing again
 
-  $ hg clpush --email --print-email .
+  $ hg clpush --email --print-email --reviewer reviewer@example.com \
+  >   --cc invalid@example.com,cc@example.com .
   Issue updated. URL: https://codereview.appspot.com/\d+ (re)
+  would have emailed: invalid@example.com
+                      reviewer@example.com
+                      cc@example.com
   
-  Hello invalid@example.com,
+  Hello invalid@example.com, reviewer@example.com (cc: cc@example.com),
   
   Please take another look.