Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 0.8, 0.8.1, and 0.8.2

hgemail: allow to preview

new button for command "hg email --test"

Changeset 5363626be64b

Parent 559084cf0397

by Simon Heimberg

Changes to one file · Browse files at 5363626be64b Showing diff from parent 559084cf0397 Diff from another changeset...

Change 1 of 4 Show Entire File hggtk/​hgemail.py Stacked
 
35
36
37
 
 
 
38
39
40
 
230
231
232
 
 
 
 
 
 
233
234
235
 
256
257
258
259
 
260
261
262
 
268
269
270
271
272
273
274
275
276
 
 
 
 
 
 
 
277
278
279
 
 
280
281
282
 
35
36
37
38
39
40
41
42
43
 
233
234
235
236
237
238
239
240
241
242
243
244
 
265
266
267
 
268
269
270
271
 
277
278
279
 
 
 
 
 
 
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
@@ -35,6 +35,9 @@
  self._toolbutton(gtk.STOCK_GOTO_LAST, _('send'),   self._on_send_clicked,   _('Send email(s)')), + self._toolbutton(gtk.STOCK_FIND, _('test'), + self._on_test_clicked, + _('Show email(s) which would be sent')),   gtk.SeparatorToolItem(),   self._toolbutton(gtk.STOCK_PREFERENCES, _('configure'),   self._on_conf_clicked, @@ -230,6 +233,12 @@
  self._refresh(False)     def _on_send_clicked(self, button): + self.send() + + def _on_test_clicked(self, button): + self.send(True) + + def send(self, test = False):   def record_new_value(cpath, history, newvalue):   if not newvalue: return   if cpath not in history.get_keys(): @@ -256,7 +265,7 @@
  if not self.repo:   return   - if self.repo.ui.config('email', 'method', 'smtp') == 'smtp': + if self.repo.ui.config('email', 'method', 'smtp') == 'smtp' and not test:   if not self.repo.ui.config('smtp', 'host'):   info_dialog(self, _('Info required'),   _('You must configure SMTP')) @@ -268,15 +277,18 @@
  self._refresh(False)   return   - history = shlib.Settings('config_history') - record_new_value('email.to', history, totext) - record_new_value('email.cc', history, cctext) - record_new_value('email.from', history, fromtext) - record_new_value('email.subject', history, subjtext) - history.write() + if not test: + history = shlib.Settings('config_history') + record_new_value('email.to', history, totext) + record_new_value('email.cc', history, cctext) + record_new_value('email.from', history, fromtext) + record_new_value('email.subject', history, subjtext) + history.write()     cmdline = ['hg', 'email', '-f', fromtext, '-t', totext, '-c', cctext]   cmdline += ['--repository', self.repo.root] + if test: + cmdline.insert(2, '--test')   if subjtext:   cmdline += ['--subject', subjtext]   if self._bundle.get_active():