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

hggtk: further run() simplification

Move gtk.main() to hgtk.py. Make the main window more explicit. This
will be required to make ctrl-W and ctrl-Q work as expected.

Changeset 1e70009b6c38

Parent b6bc2ac7c7d1

by Steve Borho

Changes to 20 files · Browse files at 1e70009b6c38 Showing diff from parent b6bc2ac7c7d1 Diff from another changeset...

Change 1 of 1 Show Entire File hggtk/​about.py Stacked
 
79
80
81
82
 
83
84
85
86
87
88
89
90
91
92
93
 
 
79
80
81
 
82
83
84
85
86
87
 
 
 
 
 
 
88
@@ -79,15 +79,10 @@
  self.set_comments("with " + lib_versions + "\n\n" + comment)   self.set_logo(gtk.gdk.pixbuf_new_from_file(thg_logo))   self.set_icon_from_file(thg_icon) - +   # somehow clicking on the Close button doesn't automatically   # close the About dialog...   self.connect('response', gtk.main_quit)    def run(_ui, *pats, **opts): - dialog = AboutDialog() - dialog.show_all() - gtk.gdk.threads_init() - gtk.gdk.threads_enter() - gtk.main() - gtk.gdk.threads_leave() + return AboutDialog()
 
56
57
58
59
60
61
62
63
64
 
 
56
57
58
 
 
 
 
 
 
59
@@ -56,9 +56,4 @@
  return vbox    def run(_ui, *pats, **opts): - dialog = BugReport(_ui, None, None, None, opts, True) - gtk.gdk.threads_init() - gtk.gdk.threads_enter() - dialog.display() - gtk.main() - gtk.gdk.threads_leave() + return BugReport(_ui, None, None, None, opts, True)
Change 1 of 1 Show Entire File hggtk/​clone.py Stacked
 
319
320
321
322
323
324
325
326
327
 
 
319
320
321
 
 
 
 
 
 
322
@@ -319,9 +319,4 @@
  self._add_dest_to_recent(dest)    def run(_ui, *pats, **opts): - dialog = CloneDialog(pats) - dialog.show_all() - gtk.gdk.threads_init() - gtk.gdk.threads_enter() - gtk.main() - gtk.gdk.threads_leave() + return CloneDialog(pats)
Change 1 of 1 Show Changes Only hggtk/​commit.py Stacked
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
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
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
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
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
 
 
 
 
 
 
 
661
 #  # commit.py - commit dialog for TortoiseHg  #  # Copyright 2007 Brad Schick, brad at gmail . com  # Copyright (C) 2007 TK Soh <teekaysoh@gmail.com>  # Copyright (C) 2009 Steve Borho <steve@borho.org>  #    import os  import pygtk  import errno  import gtk  import pango  import tempfile  import cStringIO    from mercurial.i18n import _  from mercurial.node import *  from mercurial import ui, hg  from shlib import shell_notify  from gdialog import *  from status import *  from hgcmd import CmdDialog  from hglib import fromutf    class BranchOperationDialog(gtk.Dialog):   def __init__(self, branch, close):   gtk.Dialog.__init__(self, parent=None, flags=gtk.DIALOG_MODAL,   buttons=(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE))   self.connect('response', self.response)   self.set_title(_('Branch Operations'))   self.newbranch = None   self.closebranch = False     lbl = gtk.Label(_('Changes take effect on next commit'))   nochanges = gtk.RadioButton(None, _('No branch changes'))   self.newbranchradio = gtk.RadioButton(nochanges,   _('Open a new named branch'))   self.closebranchradio = gtk.RadioButton(nochanges,   _('Close current named branch'))   self.branchentry = gtk.Entry()     hbox = gtk.HBox()   hbox.pack_start(self.newbranchradio, False, False, 2)   hbox.pack_start(self.branchentry, True, True, 2)   self.vbox.pack_start(hbox, True, True, 2)   hbox = gtk.HBox()   hbox.pack_start(self.closebranchradio, True, True, 2)   self.vbox.pack_start(hbox, True, True, 2)   hbox = gtk.HBox()   hbox.pack_start(nochanges, True, True, 2)   self.vbox.pack_start(hbox, True, True, 2)   self.vbox.pack_start(lbl, True, True, 10)   self.newbranchradio.connect('toggled', self.nbtoggle)     self.newbranchradio.set_active(True)   if branch:   self.branchentry.set_text(branch)   self.newbranchradio.set_active(True)   elif close:   self.closebranchradio.set_active(True)   else:   nochanges.set_active(True)   self.show_all()     def nbtoggle(self, radio):   self.branchentry.set_sensitive(radio.get_active())     def response(self, widget, response_id):   if response_id != gtk.RESPONSE_CLOSE:   self.destroy()   return   if self.newbranchradio.get_active():   self.newbranch = self.branchentry.get_text()   elif self.closebranchradio.get_active():   self.closebranch = True   self.destroy()      class GCommit(GStatus):   """GTK+ based dialog for displaying repository status and committing   changes. Also provides related operations like add, delete, remove,   revert, refresh, ignore, diff, and edit.   """     ### Overrides of base class methods ###     def init(self):   GStatus.init(self)   self.mode = 'commit'   self.nextbranch = None   self.closebranch = False   self._last_commit_id = None   self.qnew = False     def parse_opts(self):   GStatus.parse_opts(self)     # Need an entry, because extdiff code expects it   if not self.test_opt('rev'):   self.opts['rev'] = ''     def get_title(self):   root = os.path.basename(self.repo.root)   user = self.opts.get('user')   if user: user = 'as ' + user   date = self.opts.get('date')   pats = ' '.join(self.pats)   if self.qnew:   return root + ' qnew'   elif self.mqmode:   patch = self.repo.mq.lookup('qtip')   return root + ' qrefresh ' + patch   return ' '.join([root, 'commit', pats or '', user or '', date or ''])     def get_icon(self):   return 'menucommit.ico'     def auto_check(self):   if self.test_opt('check'):   for entry in self.filemodel :   if entry[FM_STATUS] in 'MAR':   entry[FM_CHECKED] = True   self._update_check_count()       def save_settings(self):   settings = GStatus.save_settings(self)   settings['gcommit'] = self._vpaned.get_position()   return settings       def load_settings(self, settings):   GStatus.load_settings(self, settings)   if settings:   self._setting_vpos = settings['gcommit']   else:   self._setting_vpos = -1       def get_tbbuttons(self):   tbbuttons = GStatus.get_tbbuttons(self)   tbbuttons.insert(2, gtk.SeparatorToolItem())   self._undo_button = self.make_toolbutton(gtk.STOCK_UNDO, _('_Undo'),   self._undo_clicked, tip=_('undo recent commit'))   self._commit_button = self.make_toolbutton(gtk.STOCK_OK, _('_Commit'),   self._commit_clicked, tip=_('commit'))   tbbuttons.insert(2, self._undo_button)   tbbuttons.insert(2, self._commit_button)   return tbbuttons       def changed_cb(self, combobox):   model = combobox.get_model()   index = combobox.get_active()   if index >= 0:   buf = self.text.get_buffer()   if buf.get_char_count() and buf.get_modified():   response = Confirm(_('Discard Message'), [], self,   _('Discard current commit message?')).run()   if response != gtk.RESPONSE_YES:   combobox.set_active(-1)   return   buf.set_text(model[index][1])   buf.set_modified(False)     def _first_msg_popdown(self, combo, shown):   combo.disconnect(self.popupid)   self.popupid = None   self._update_recent_messages()     def _update_recent_messages(self, msg=None):   if msg is not None:   self._mru_messages.add(msg)   self.settings.write()   if self.popupid is not None: return   liststore = self.msg_cbbox.get_model()   liststore.clear()   for msg in self._mru_messages:   sumline = msg.split("\n")[0]   liststore.append([sumline, msg])     def branch_clicked(self, button):   dialog = BranchOperationDialog(self.nextbranch, self.closebranch)   dialog.run()   self.nextbranch = None   self.closebranch = False   if dialog.newbranch:   self.nextbranch = dialog.newbranch   elif dialog.closebranch:   self.closebranch = True   self.refresh_branchop()     def get_body(self):   status_body = GStatus.get_body(self)     vbox = gtk.VBox()     mbox = gtk.HBox()     self.branchbutton = gtk.Button()   self.branchbutton.connect('clicked', self.branch_clicked)   mbox.pack_start(self.branchbutton, False, False, 2)     if hasattr(self.repo, 'mq'):   label = gtk.Label('QNew: ')   mbox.pack_start(label, False, False, 2)   self.qnew_name = gtk.Entry()   self.qnew_name.set_width_chars(20)   self.qnew_name.connect('changed', self._qnew_changed)   mbox.pack_start(self.qnew_name, False, False, 2)   else:   self.qnew_name = None     liststore = gtk.ListStore(str, str)   self.msg_cbbox = gtk.ComboBox(liststore)   cell = gtk.CellRendererText()   self.msg_cbbox.pack_start(cell, True)   self.msg_cbbox.add_attribute(cell, 'text', 0)   liststore.append([_('Recent Commit Messages...'), ''])   self.msg_cbbox.set_active(0)   self.popupid = self.msg_cbbox.connect('notify::popup-shown',   self._first_msg_popdown)   self.msg_cbbox.connect('changed', self.changed_cb)   mbox.pack_start(self.msg_cbbox)   vbox.pack_start(mbox, False, False)   self._mru_messages = self.settings.mrul('recent_messages')     frame = gtk.Frame()   frame.set_shadow_type(gtk.SHADOW_ETCHED_IN)   scroller = gtk.ScrolledWindow()   scroller.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)   frame.add(scroller)   vbox.pack_start(frame)     self.text = gtk.TextView()   self.text.set_wrap_mode(gtk.WRAP_WORD)   self.text.modify_font(pango.FontDescription(self.fontcomment))   scroller.add(self.text)     self._vpaned = gtk.VPaned()   self._vpaned.add1(vbox)   self._vpaned.add2(status_body)   self._vpaned.set_position(self._setting_vpos)     # make ctrl-o trigger commit button   accel_group = gtk.AccelGroup()   self.add_accel_group(accel_group)   self._commit_button.add_accelerator("clicked", accel_group, ord("o"),   gtk.gdk.CONTROL_MASK, gtk.ACCEL_VISIBLE)   return self._vpaned       def get_menu_info(self):   """Returns menu info in this order: merge, addrem, unknown,   clean, ignored, deleted   """   merge, addrem, unknown, clean, ignored, deleted, unresolved, resolved \   = GStatus.get_menu_info(self)   return (merge + (('_commit', self._commit_file),),   addrem + (('_commit', self._commit_file),),   unknown + (('_commit', self._commit_file),),   clean,   ignored,   deleted + (('_commit', self._commit_file),),   unresolved,   resolved,   )       def should_live(self, widget=None, event=None):   # If there are more than a few character typed into the commit   # message, ask if the exit should continue.   live = False   buf = self.text.get_buffer()   if buf.get_char_count() > 10 and buf.get_modified():   dialog = Confirm(_('Exit'), [], self,   _('Save commit message at exit?'))   res = dialog.run()   if res == gtk.RESPONSE_YES:   begin, end = buf.get_bounds()   self._update_recent_messages(buf.get_text(begin, end))   elif res != gtk.RESPONSE_NO:   live = True   if not live and self.main:   self._destroying(widget)   return live       def reload_status(self):   if not self._ready: return False   success = GStatus.reload_status(self)   self._check_merge()   self._check_patch_queue()   self._check_undo()   self.refresh_branchop()   return success       ### End of overridable methods ###     def refresh_branchop(self):   if self.nextbranch:   text = _('new branch: ') + self.nextbranch   elif self.closebranch:   text = _('close branch: ') + self.repo[None].branch()   else:   text = _('branch: ') + self.repo[None].branch()   self.branchbutton.set_label(text)     def _check_undo(self):   can_undo = os.path.exists(self.repo.sjoin("undo")) and \   self._last_commit_id is not None   self._undo_button.set_sensitive(can_undo)       def _check_merge(self):   # disable the checkboxes on the filelist if repo in merging state   merged = len(self.repo.changectx(None).parents()) > 1     self.get_toolbutton(_('Re_vert')).set_sensitive(not merged)   self.get_toolbutton(_('_Add')).set_sensitive(not merged)   self.get_toolbutton(_('_Remove')).set_sensitive(not merged)   self.get_toolbutton(_('Move')).set_sensitive(not merged)     if merged:   # select all changes if repo is merged   for entry in self.filemodel:   if entry[FM_STATUS] in 'MARD':   entry[FM_CHECKED] = True   self._update_check_count()     # pre-fill commit message   buf = self.text.get_buffer()   buf.set_text(_('merge'))   buf.set_modified(False)   #else:   # self.selectlabel.set_text(   # _('toggle change hunks to leave them out of commit'))         def _check_patch_queue(self):   '''See if an MQ patch is applied, switch to qrefresh mode'''   self.qheader = None   if self.mqmode:   patch = self.repo.mq.lookup('qtip')   ph = self.repo.mq.readheaders(patch)   self.qheader = '\n'.join(ph.message)   buf = self.text.get_buffer()   if buf.get_char_count() == 0 or not buf.get_modified():   if self.qnew:   buf.set_text('')   else:   buf.set_text(self.qheader)   buf.set_modified(False)   c_btn = self.get_toolbutton(_('_Commit'))   if self.qnew:   c_btn.set_label(_('QNew'))   c_btn.set_tooltip(self.tooltips, _('QNew'))   self._hg_call_wrapper('Status', self._do_reload_status)   else:   c_btn.set_label(_('QRefresh'))   c_btn.set_tooltip(self.tooltips, _('QRefresh'))   elif self.qnew:   c_btn = self.get_toolbutton(_('_Commit'))   c_btn.set_label(_('QNew'))   c_btn.set_tooltip(self.tooltips, _('QNew'))   buf = self.text.get_buffer()   if not buf.get_modified():   buf.set_text('')   buf.set_modified(False)   else:   c_btn = self.get_toolbutton(('_Commit'))   c_btn.set_label(_('_Commit'))   c_btn.set_tooltip(self.tooltips, _('commit'))   self.branchbutton.set_sensitive(not (self.mqmode or self.qnew))     def _commit_clicked(self, toolbutton, data=None):   if not self._ready_message():   return True     if len(self.repo.changectx(None).parents()) > 1:   # as of Mercurial 1.0, merges must be committed without   # specifying file list.   self._hg_commit([])   shell_notify(self._relevant_files('MAR'))   self.reload_status()   else:   commitable = 'MAR'   addremove_list = self._relevant_files('?!')   if len(addremove_list) and self._should_addremove(addremove_list):   commitable += '?!'     commit_list = self._relevant_files(commitable)   if len(commit_list) > 0:   self._commit_selected(commit_list)   elif len(self.filemodel) == 0 and self.qnew:   self._commit_selected([])   else:   Prompt(_('Nothing Commited'),   _('No committable files selected'), self).run()   return True     def _commit_selected(self, files):   # 1a. get list of chunks not rejected   repo, chunks, ui = self.repo, self._shelve_chunks, self.ui   model = self.diff_model   files = [util.pconvert(f) for f in files]   hlist = [x[DM_CHUNK_ID] for x in model if not x[DM_REJECTED]]     # 2. backup changed files, so we can restore them in the end   backups = {}   backupdir = repo.join('record-backups')   try:   os.mkdir(backupdir)   except OSError, err:   if err.errno != errno.EEXIST:   Prompt(_('Commit'), _('Unable to create ') + backupdir,   self).run()   return   try:   # backup continues   for f in files:   if f not in self.modified: continue   fh = self._filechunks.get(f)   if not fh or len(fh) < 2: continue   # unfiltered files do not go through backup-revert-patch cycle   rejected = [x for x in fh[1:] if model[x][DM_REJECTED]]   if len(rejected) == 0: continue   fd, tmpname = tempfile.mkstemp(prefix=f.replace('/', '_')+'.',   dir=backupdir)   os.close(fd)   ui.debug(_('backup %r as %r\n') % (f, tmpname))   util.copyfile(repo.wjoin(f), tmpname)   backups[f] = tmpname     fp = cStringIO.StringIO()   for n, c in enumerate(chunks):   if c.filename() in backups and n in hlist:   c.write(fp)   dopatch = fp.tell()   fp.seek(0)     if backups:   if self.qheader is not None:   # 3a. apply filtered patch to top patch's parent   hg.revert(repo, self._node1, backups.has_key)   else:   # 3a. apply filtered patch to clean repo (clean)   hg.revert(repo, repo.dirstate.parents()[0], backups.has_key)     # 3b. (apply)   if dopatch:   try:   ui.debug(_('applying patch\n'))   ui.debug(fp.getvalue())   pfiles = {}   patch.internalpatch(fp, ui, 1, repo.root, files=pfiles)   patch.updatedir(ui, repo, pfiles)   except patch.PatchError, err:   s = str(err)   if s:   raise util.Abort(s)   else:   Prompt(_('Commit'), _('Unable to apply patch'), self).run()   raise util.Abort(_('patch failed to apply'))   del fp     # 4. We prepared working directory according to filtered patch.   # Now is the time to delegate the job to commit/qrefresh or the like!     # it is important to first chdir to repo root -- we'll call a   # highlevel command with list of pathnames relative to repo root   cwd = os.getcwd()   os.chdir(repo.root)   try:   self._hg_commit(files)   finally:   os.chdir(cwd)     return 0   finally:   # 5. finally restore backed-up files   try:   for realname, tmpname in backups.iteritems():   ui.debug(_('restoring %r to %r\n') % (tmpname, realname))   util.copyfile(tmpname, repo.wjoin(realname))   os.unlink(tmpname)   os.rmdir(backupdir)   except OSError:   pass   self.reload_status()       def _commit_file(self, stat, file):   if self._ready_message():   if stat not in '?!' or self._should_addremove([file]):   self._hg_commit([file])   shell_notify([file])   self.reload_status()   return True       def _undo_clicked(self, toolbutton, data=None):   response = Confirm(_('Undo commit'), [], self, _('Undo last commit')).run()   if response != gtk.RESPONSE_YES:   return     tip = self._get_tip_rev(True)   if not tip == self._last_commit_id:   Prompt(_('Undo commit'),   _('Unable to undo!\n\n'   'Tip revision differs from last commit.'),   self).run()   return     try:   self.repo.rollback()   self._last_commit_id = None   self.reload_status()   except:   Prompt(_('Undo commit'), _('Errors during rollback!'), self).run()       def _should_addremove(self, files):   if self.test_opt('addremove'):   return True   else:   response = Confirm(_('Add/Remove'), files, self).run()   if response == gtk.RESPONSE_YES:   # This will stay set for further commits (meaning no more prompts). Problem?   self.opts['addremove'] = True   return True   return False       def _ready_message(self):   buf = self.text.get_buffer()   if buf.get_char_count() == 0:   Prompt(_('Nothing Commited'),   _('Please enter commit message'), self).run()   self.text.grab_focus()   return False   begin, end = buf.get_bounds()   self.opts['message'] = buf.get_text(begin, end)   return True       def _hg_commit(self, files):   if not self.repo.ui.config('ui', 'username'):   Prompt(_('Commit: Invalid username'),   _('Your username has not been configured.\n\n'   'Please configure your username and try again'),   self).run()     # bring up the config dialog for user to enter their username.   # But since we can't be sure they will do it right, we will   # have them to retry, to re-trigger the checking mechanism.   from thgconfig import ConfigDialog   dlg = ConfigDialog(False)   dlg.show_all()   dlg.focus_field('ui.username')   dlg.run()   dlg.hide()   self.repo = hg.repository(ui.ui(), self.repo.root)   self.ui = self.repo.ui   return     cmdline = ['hg', 'commit', '--verbose', '--repository', self.repo.root]     if self.nextbranch:   newbranch = fromutf(self.nextbranch)   if newbranch in self.repo.branchtags():   if newbranch not in [p.branch() for p in self.repo.parents()]:   response = Confirm(_('Override Branch'), [], self,   _('A branch named "%s" already exists,\n'   'override?') % newbranch).run()   else:   response = gtk.RESPONSE_YES   else:   response = Confirm(_('New Branch'), [], self,   _('Create new named branch "%s"?') % newbranch).run()   if response == gtk.RESPONSE_YES:   self.repo.dirstate.setbranch(newbranch)   elif response != gtk.RESPONSE_NO:   return   elif self.closebranch:   cmdline.append('--close-branch')     # call the threaded CmdDialog to do the commit, so the the large commit   # won't get locked up by potential large commit. CmdDialog will also   # display the progress of the commit operation.   if self.qnew:   cmdline[1] = 'qnew'   cmdline.append('--force')   elif self.qheader is not None:   cmdline[1] = 'qrefresh'   if self.opts['addremove']:   cmdline += ['--addremove']   if self.opts['user']:   cmdline.extend(['--user', self.opts['user']])   if self.opts['date']:   cmdline.extend(['--date', self.opts['date']])   cmdline += ['--message', fromutf(self.opts['message'])]   if self.qnew:   cmdline += [fromutf(self._get_qnew_name())]   cmdline += [self.repo.wjoin(x) for x in files]   dialog = CmdDialog(cmdline, True)   dialog.set_transient_for(self)   dialog.run()   dialog.hide()     # refresh overlay icons and commit dialog   if dialog.return_code() == 0:   shell_notify([self.cwd] + files)   self.closebranch = False   self.nextbranch = None   buf = self.text.get_buffer()   if buf.get_modified():   self._update_recent_messages(self.opts['message'])   buf.set_modified(False)   if self.qnew:   self.qnew_name.set_text('')   self.repo.invalidate()   self.mode = 'commit'   self.qnew = False   _mq = self.repo.mq   _mq.__init__(_mq.ui, _mq.basepath, _mq.path)   elif self.qheader is None:   self.text.set_buffer(gtk.TextBuffer())   self._last_commit_id = self._get_tip_rev(True)     def _get_tip_rev(self, refresh=False):   if refresh:   self.repo.invalidate()   cl = self.repo.changelog   tip = cl.node(nullrev + len(cl))   return hex(tip)     def _get_qnew_name(self):   return self.qnew_name and self.qnew_name.get_text().strip() or ''     def _qnew_changed(self, element):   qnew = bool(self._get_qnew_name())   if self.qnew != qnew:   self.qnew = qnew   self.mode = qnew and 'status' or 'commit'   self.reload_status()   self.qnew_name.grab_focus() # set focus back    def run(_ui, *pats, **opts):   cmdoptions = {   'user':opts.get('user', ''), 'date':opts.get('date', ''),   'logfile':'', 'message':'',   'modified':True, 'added':True, 'removed':True, 'deleted':True,   'unknown':True, 'ignored':False,   'exclude':[], 'include':[],   'check': True, 'git':False, 'addremove':False,   } - - dialog = GCommit(_ui, None, None, pats, cmdoptions, True) - dialog.display() - gtk.gdk.threads_init() - gtk.gdk.threads_enter() - gtk.main() - gtk.gdk.threads_leave() + return GCommit(_ui, None, None, pats, cmdoptions, True)
Change 1 of 1 Show Entire File hggtk/​datamine.py Stacked
 
703
704
705
706
707
708
709
710
711
 
 
703
704
705
 
 
 
 
 
 
706
@@ -703,9 +703,4 @@
  'only_merges':None, 'prune':[], 'git':False, 'verbose':False,   'include':[], 'exclude':[]   } - dialog = DataMineDialog(ui, None, None, pats, cmdoptions, True) - dialog.display() - gtk.gdk.threads_init() - gtk.gdk.threads_enter() - gtk.main() - gtk.gdk.threads_leave() + return DataMineDialog(ui, None, None, pats, cmdoptions, True)
Change 1 of 1 Show Entire File hggtk/​guess.py Stacked
 
367
368
369
370
371
372
373
374
375
376
 
 
367
368
369
 
 
 
 
 
 
 
370
@@ -367,10 +367,4 @@
  buf.insert(bufiter, line)    def run(ui, *pats, **opts): - dialog = DetectRenameDialog() - dialog.show_all() - dialog.connect('destroy', gtk.main_quit) - gtk.gdk.threads_init() - gtk.gdk.threads_enter() - gtk.main() - gtk.gdk.threads_leave() + return DetectRenameDialog()
Change 1 of 1 Show Entire File hggtk/​hgignore.py Stacked
 
198
199
200
201
202
203
204
205
206
207
 
 
198
199
200
 
 
 
 
 
 
 
201
@@ -198,10 +198,4 @@
 def run(_ui, *pats, **opts):   if pats and pats[0].endswith('.hgignore'):   pats = [] - dialog = HgIgnoreDialog(*pats) - dialog.show_all() - dialog.connect('destroy', gtk.main_quit) - gtk.gdk.threads_init() - gtk.gdk.threads_enter() - gtk.main() - gtk.gdk.threads_leave() + return HgIgnoreDialog(*pats)
Change 1 of 1 Show Entire File hggtk/​hginit.py Stacked
 
165
166
167
168
169
170
171
172
173
 
 
165
166
167
 
 
 
 
 
 
168
@@ -165,9 +165,4 @@
  _('in directory %s') % toutf(os.path.abspath(dest)))    def run(ui, *pats, **opts): - dialog = InitDialog(repos=pats) - dialog.show_all() - gtk.gdk.threads_init() - gtk.gdk.threads_enter() - gtk.main() - gtk.gdk.threads_leave() + return InitDialog(pats)
Change 1 of 6 Show Entire File hggtk/​hgtk.py Stacked
 
15
16
17
 
18
19
20
 
35
36
37
38
 
 
 
 
 
39
40
41
 
161
162
163
 
 
 
 
 
 
 
 
 
 
164
165
166
167
 
168
169
170
 
174
175
176
177
 
178
179
180
 
194
195
196
197
 
198
199
200
201
202
 
203
204
205
206
207
208
 
209
210
211
212
213
214
 
215
216
217
218
219
220
221
 
222
223
224
225
226
 
227
228
229
230
231
 
232
233
234
235
236
 
237
238
239
240
241
 
242
243
244
245
246
 
247
248
249
250
251
 
252
253
254
255
256
 
257
258
259
260
261
 
262
263
264
265
266
 
267
268
269
270
271
 
272
273
274
275
276
 
277
278
279
 
283
284
285
286
 
287
288
289
290
291
 
292
293
294
295
296
 
297
298
299
 
15
16
17
18
19
20
21
 
36
37
38
 
39
40
41
42
43
44
45
46
 
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
 
182
183
184
185
 
189
190
191
 
192
193
194
195
 
209
210
211
 
212
213
214
215
216
 
217
218
219
220
221
222
 
223
224
225
226
227
228
 
229
230
231
232
233
234
235
 
236
237
238
239
240
 
241
242
243
244
245
 
246
247
248
249
250
 
251
252
253
254
255
 
256
257
258
259
260
 
261
262
263
264
265
 
266
267
268
269
270
 
271
272
273
274
275
 
276
277
278
279
280
 
281
282
283
284
285
 
286
287
288
289
290
 
291
292
293
294
 
298
299
300
 
301
302
303
304
305
 
306
307
308
309
310
 
311
312
313
314
@@ -15,6 +15,7 @@
 import mercurial.ui as _ui  from mercurial import hg, util, fancyopts, cmdutil  import hglib +import gtk    import os  import pdb @@ -35,7 +36,11 @@
  pdb.post_mortem(sys.exc_info()[2])   error = traceback.format_exc()   from bugreport import run - run(u, **{'cmd':' '.join(sys.argv[1:]), 'error':error}) + opts = {} + opts['cmd'] = ' '.join(sys.argv[1:]) + opts['error'] = error + print error + gtkrun(run(u, **opts))    def get_list_from_file(filename):   try: @@ -161,10 +166,20 @@
  raise   raise hglib.ParseError(cmd, _("invalid arguments"))   +def gtkrun(mainwin): + mainwin.show_all() + if hasattr(mainwin, 'display'): + mainwin.display() + mainwin.connect('destroy', gtk.main_quit) + gtk.gdk.threads_init() + gtk.gdk.threads_enter() + gtk.main() + gtk.gdk.threads_leave() +  def about(ui, *pats, **opts):   """about TortoiseHg"""   from hggtk.about import run - run(ui, *pats, **opts) + gtkrun(run(ui, *pats, **opts))    def add(ui, *pats, **opts):   """add files""" @@ -174,7 +189,7 @@
 def clone(ui, *pats, **opts):   """clone tool"""   from hggtk.clone import run - run(ui, *pats, **opts) + gtkrun(run(ui, *pats, **opts))    def commit(ui, *pats, **opts):   """commit tool""" @@ -194,86 +209,86 @@
  os.chdir(repo.root)   pats = []   from hggtk.commit import run - run(ui, *pats, **opts) + gtkrun(run(ui, *pats, **opts))    def shelve(ui, *pats, **opts):   """shelve/unshelve tool"""   from hggtk.thgshelve import run - run(ui, *pats, **opts) + gtkrun(run(ui, *pats, **opts))    def userconfig(ui, *pats, **opts):   """user configuration editor"""   from hggtk.thgconfig import run   opts['repomode'] = False - run(ui, *pats, **opts) + gtkrun(run(ui, *pats, **opts))    def repoconfig(ui, *pats, **opts):   """repository configuration editor"""   from hggtk.thgconfig import run   opts['repomode'] = True - run(ui, *pats, **opts) + gtkrun(run(ui, *pats, **opts))    def rename(ui, *pats, **opts):   """rename a single file or directory"""   from hggtk.rename import run   if not pats or len(pats) > 2:   raise util.Abort(_('rename takes one or two path arguments')) - run(ui, *pats, **opts) + gtkrun(run(ui, *pats, **opts))    def guess(ui, *pats, **opts):   """guess previous renames or copies"""   from hggtk.guess import run - run(ui, *pats, **opts) + gtkrun(run(ui, *pats, **opts))    def datamine(ui, *pats, **opts):   """repository search and annotate tool"""   from hggtk.datamine import run - run(ui, *pats, **opts) + gtkrun(run(ui, *pats, **opts))    def hgignore(ui, *pats, **opts):   """ignore filter editor"""   from hggtk.hgignore import run - run(ui, *pats, **opts) + gtkrun(run(ui, *pats, **opts))    def hginit(ui, *pats, **opts):   """repository initialization tool"""   from hggtk.hginit import run - run(ui, *pats, **opts) + gtkrun(run(ui, *pats, **opts))    def log(ui, *pats, **opts):   """changelog viewer"""   from hggtk.history import run - run(ui, *pats, **opts) + gtkrun(run(ui, *pats, **opts))    def merge(ui, node=None, rev=None, **opts):   """merge tool"""   from hggtk.merge import run - run(ui, *pats, **opts) + gtkrun(run(ui, *pats, **opts))    def recovery(ui, *pats, **opts):   """recover, rollback & verify"""   from hggtk.recovery import run - run(ui, *pats, **opts) + gtkrun(run(ui, *pats, **opts))    def remove(ui, *pats, **opts):   """file status viewer in remove mode"""   from hggtk.status import run - run(ui, *pats, **opts) + gtkrun(run(ui, *pats, **opts))    def revert(ui, *pats, **opts):   """file status viewer in revert mode"""   from hggtk.status import run - run(ui, *pats, **opts) + gtkrun(run(ui, *pats, **opts))    def serve(ui, *pats, **opts):   """web server"""   from hggtk.serve import run - run(ui, *pats, **opts) + gtkrun(run(ui, *pats, **opts))    def status(ui, *pats, **opts):   """file status viewer"""   from hggtk.status import run - run(ui, *pats, **opts) + gtkrun(run(ui, *pats, **opts))    def synch(ui, *pats, **opts):   """repository synchronization tool""" @@ -283,17 +298,17 @@
  opts['pushmode'] = True   else:   opts['pushmode'] = False - run(ui, *pats, **opts) + gtkrun(run(ui, *pats, **opts))    def update(ui, *pats, **opts):   """update/checkout tool"""   from hggtk.update import run - run(ui, *pats, **opts) + gtkrun(run(ui, *pats, **opts))    def vdiff(ui, *pats, **opts):   """launch configured visual diff tool"""   from hggtk.visdiff import run - run(ui, *pats, **opts) + gtkrun(run(ui, *pats, **opts))    ### help management, adapted from mercurial.commands.help_()  def help_(ui, name=None, with_version=False):
Change 1 of 1 Show Entire File hggtk/​history.py Stacked
 
734
735
736
737
738
739
740
741
742
743
 
 
734
735
736
 
 
 
 
 
 
 
737
@@ -734,10 +734,4 @@
  'date':None, 'only_merges':None, 'prune':[], 'git':False,   'verbose':False, 'include':[], 'exclude':[]   } - - dialog = GLog(ui, None, None, pats, cmdoptions, True) - gtk.gdk.threads_init() - gtk.gdk.threads_enter() - dialog.display() - gtk.main() - gtk.gdk.threads_leave() + return GLog(ui, None, None, pats, cmdoptions, True)
Change 1 of 1 Show Entire File hggtk/​merge.py Stacked
 
236
237
238
239
240
241
242
243
244
245
 
 
236
237
238
 
 
 
 
 
 
 
239
@@ -236,10 +236,4 @@
  self._refresh()    def run(ui, *pats, **opts): - dialog = MergeDialog() - dialog.connect('destroy', gtk.main_quit) - dialog.show_all() - gtk.gdk.threads_init() - gtk.gdk.threads_enter() - gtk.main() - gtk.gdk.threads_leave() + return MergeDialog()
Change 1 of 1 Show Entire File hggtk/​recovery.py Stacked
 
208
209
210
211
212
213
214
215
216
 
 
208
209
210
 
 
 
 
 
 
211
@@ -208,9 +208,4 @@
  return False # Stop polling this function    def run(ui, *pats, **opts): - dialog = RecoveryDialog(root) - dialog.show_all() - gtk.gdk.threads_init() - gtk.gdk.threads_enter() - gtk.main() - gtk.gdk.threads_leave() + return RecoveryDialog()
Change 1 of 1 Show Entire File hggtk/​rename.py Stacked
 
30
31
32
33
34
35
36
37
38
 
39
40
41
 
30
31
32
 
 
 
 
 
 
33
34
35
36
@@ -30,12 +30,7 @@
  title = 'Rename ' + toutf(fname)   dialog = entry_dialog(None, title, True, target, rename_resp)   dialog.orig = fname - dialog.show_all() - dialog.connect('destroy', gtk.main_quit) - gtk.gdk.threads_init() - gtk.gdk.threads_enter() - gtk.main() - gtk.gdk.threads_leave() + return dialog    def rename_resp(dialog, response):   if response != gtk.RESPONSE_OK:
Change 1 of 1 Show Entire File hggtk/​serve.py Stacked
 
342
343
344
345
346
347
348
349
350
 
 
342
343
344
 
 
 
 
 
 
345
@@ -342,9 +342,4 @@
  _('hg serve [OPTION]...'))}    def run(ui, *pats, **opts): - dialog = ServeDialog(opts.get('webdir_conf')) - dialog.show_all() - gtk.gdk.threads_init() - gtk.gdk.threads_enter() - gtk.main() - gtk.gdk.threads_leave() + return ServeDialog(opts.get('webdir_conf'))
Change 1 of 1 Show Entire File hggtk/​status.py Stacked
 
1318
1319
1320
1321
1322
1323
1324
1325
1326
 
 
1318
1319
1320
 
 
 
 
 
 
1321
@@ -1318,9 +1318,4 @@
  'exclude':[], 'include':[], 'debug':True, 'verbose':True, 'git':False,   'check':True   } - dialog = GStatus(ui, None, None, pats, cmdoptions, True) - gtk.gdk.threads_init() - gtk.gdk.threads_enter() - dialog.display() - gtk.main() - gtk.gdk.threads_leave() + return GStatus(ui, None, None, pats, cmdoptions, True)
Change 1 of 1 Show Entire File hggtk/​synch.py Stacked
 
617
618
619
620
621
622
623
624
625
 
 
617
618
619
 
 
 
 
 
 
620
@@ -617,9 +617,4 @@
  set_value(key, value)    def run(ui, *pats, **opts): - dialog = SynchDialog(pats, opts.get('pushmode') or False) - dialog.show_all() - gtk.gdk.threads_init() - gtk.gdk.threads_enter() - gtk.main() - gtk.gdk.threads_leave() + return SynchDialog(pats, opts.get('pushmode'))
 
988
989
990
991
992
993
994
995
996
997
 
 
988
989
990
 
 
 
 
 
 
 
991
@@ -988,10 +988,4 @@
  return 0    def run(ui, *pats, **opts): - dialog = ConfigDialog(opts.get('repomode') or False) - dialog.show_all() - dialog.connect('response', gtk.main_quit) - gtk.gdk.threads_init() - gtk.gdk.threads_enter() - gtk.main() - gtk.gdk.threads_leave() + return ConfigDialog(opts.get('repomode'))
 
217
218
219
220
221
222
223
224
225
226
 
 
217
218
219
 
 
 
 
 
 
 
220
@@ -217,10 +217,4 @@
  'exclude':[], 'include':[],   'check': True, 'git':False, 'addremove':False,   } - - dialog = GShelve(_ui, None, None, pats, cmdoptions, True) - dialog.display() - gtk.gdk.threads_init() - gtk.gdk.threads_enter() - gtk.main() - gtk.gdk.threads_leave() + return GShelve(_ui, None, None, pats, cmdoptions, True)
Change 1 of 1 Show Entire File hggtk/​update.py Stacked
 
181
182
183
184
185
186
187
188
189
190
 
 
181
182
183
 
 
 
 
 
 
 
184
@@ -181,10 +181,4 @@
  shell_notify([self.root])    def run(ui, *pats, **opts): - dialog = UpdateDialog() - dialog.connect('destroy', gtk.main_quit) - dialog.show_all() - gtk.gdk.threads_init() - gtk.gdk.threads_enter() - gtk.main() - gtk.gdk.threads_leave() + return UpdateDialog()
Change 1 of 1 Show Entire File hggtk/​visdiff.py Stacked
 
261
262
263
264
265
266
267
268
269
270
 
 
261
262
263
 
 
 
 
 
 
 
264
@@ -261,10 +261,4 @@
  canonpats = []   for f in pats:   canonpats.append(util.canonpath(root, os.getcwd(), f)) - dialog = FileSelectionDialog(canonpats, opts) - dialog.connect('destroy', gtk.main_quit) - dialog.show_all() - gtk.gdk.threads_init() - gtk.gdk.threads_enter() - gtk.main() - gtk.gdk.threads_leave() + return FileSelectionDialog(canonpats, opts)