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

thgconfig: add edit button

open the file being configured in the user's preferred visual editor
Fixes #174

Changeset 8bab71d06373

Parent d5e6aa621783

by Steve Borho

Changes to one file · Browse files at 8bab71d06373 Showing diff from parent d5e6aa621783 Diff from another changeset...

 
10
11
12
 
13
14
15
 
342
343
344
 
345
346
347
 
426
427
428
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
429
430
431
 
10
11
12
13
14
15
16
 
343
344
345
346
347
348
349
 
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
@@ -10,6 +10,7 @@
 import os  import re  import urlparse +import threading  from mercurial.i18n import _  from mercurial import hg, ui, util, url  from dialog import error_dialog, question_dialog @@ -342,6 +343,7 @@
  """ Initialize the Dialog. """   gtk.Dialog.__init__(self, parent=None, flags=0,   buttons=(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE)) + self.add_button(gtk.STOCK_EDIT, gtk.RESPONSE_YES)   shlib.set_tortoise_keys(self)     self.ui = ui.ui() @@ -426,6 +428,31 @@
  self.dirty = False     def should_live(self, *args): + if len(args) == 2 and args[1] == gtk.RESPONSE_YES: + def doedit(): + util.system("%s \"%s\"" % (editor, self.fn)) + # reload configs, in case they have been written since opened + if self.configrepo: + repo = hg.repository(ui.ui(), path=rootpath()) + u = repo.ui + else: + u = ui.ui() + editor = (u.config('tortoisehg', 'editor') or + u.config('gtools', 'editor') or + os.environ.get('HGEDITOR') or + u.config('ui', 'editor') or + os.environ.get('EDITOR', 'vi')) + if os.path.basename(editor) in ('vi', 'vim', 'hgeditor'): + import gdialog + gdialog.Prompt(_('No visual editor configured'), + _('Please configure a visual editor.'), self).run() + self.focus_field('tortoisehg.editor') + self.emit_stop_by_name('response') + return True + thread = threading.Thread(target=doedit, name='edit config') + thread.setDaemon(True) + thread.start() + return False   if self.dirty:   if question_dialog(self, _('Quit without saving?'),   _('Yes to abandon changes, No to continue')) != gtk.RESPONSE_YES: