Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 0.7, 0.7.1, and 0.7.2

status: rename tree, model to filetree, filemodel

Changeset e248eca12d8b

Parent f22355489493

by Steve Borho

Changes to 2 files · Browse files at e248eca12d8b Showing diff from parent f22355489493 Diff from another changeset...

Change 1 of 2 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
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
 #  # 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  pygtk.require('2.0')  import errno  import gtk  import pango  import tempfile  import cStringIO    from mercurial.i18n 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 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._last_commit_id = None     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'] = ''     if self.test_opt('message'):   buffer = gtk.TextBuffer()   buffer.set_text(self.opts['message'])   self.text.set_buffer(buffer)     if self.test_opt('logfile'):   buffer = gtk.TextBuffer()   buffer.set_text('Comment will be read from file ' + self.opts['logfile'])   self.text.set_buffer(buffer)   self.text.set_sensitive(False)       def get_title(self):   return os.path.basename(self.repo.root) + ' commit ' + ' '.join(self.pats) + ' ' + self.opts['user'] + ' ' + self.opts['date']     def get_icon(self):   return 'menucommit.ico'     def auto_check(self):   if self.test_opt('check'): - for entry in self.model : + 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:   buffer = self.text.get_buffer()   begin, end = buffer.get_bounds()   cur_msg = buffer.get_text(begin, end)   if len(cur_msg):   response = Confirm('Discard Message', [], self,   'Discard current commit message?').run()   if response != gtk.RESPONSE_YES:   return   buffer.set_text(model[index][1])     def _update_recent_messages(self, msg=None):   if msg is not None:   self._mru_messages.add(msg)   self.settings.write()     liststore = self.msg_cbbox.get_model()   liststore.clear()   for msg in self._mru_messages:   sumline = msg.split("\n")[0]   liststore.append([sumline, msg])   #self.msg_cbbox.set_active(-1)     def get_body(self):   status_body = GStatus.get_body(self)     vbox = gtk.VBox()     mbox = gtk.HBox()   label = gtk.Label('Recent Commit Messages: ')   mbox.pack_start(label, False, False, 2)   self.msg_cbbox = gtk.combo_box_new_text()   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)   #cell = gtk.CellRendererText()   #self.msg_cbbox.pack_start(cell, True)   #self.msg_cbbox.add_attribute(cell, 'text', 1)   mbox.pack_start(self.msg_cbbox)   vbox.pack_start(mbox, False, False)   self._mru_messages = self.settings.mrul('recent_messages')   self._update_recent_messages()   self.msg_cbbox.connect('changed', self.changed_cb)     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   buffer = self.text.get_buffer()   begin, end = buffer.get_bounds()   cur_msg = buffer.get_text(begin, end)   if buffer.get_char_count() > 10 and cur_msg != self.qheader:   dialog = Confirm('Exit', [], self, 'Save commit message at exit?')   res = dialog.run()   if res == gtk.RESPONSE_YES:   self._update_recent_messages(cur_msg)   elif res != gtk.RESPONSE_NO:   live = True   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()   return success       ### End of overridable methods ###     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.model: + for entry in self.filemodel:   if entry[FM_STATUS] in 'MARD':   entry[FM_CHECKED] = True   self._update_check_count()     # pre-fill commit message   self.text.get_buffer().set_text('merge')       def _check_patch_queue(self):   '''See if an MQ patch is applied, switch to qrefresh mode'''   self.qheader = None   if not hasattr(self.repo, 'mq'): return   if not self.repo.mq.applied: return   patch = self.repo.mq.lookup('qtip')   ph = self.repo.mq.readheaders(patch)   title = os.path.basename(self.repo.root) + ' qrefresh ' + patch   self.set_title(title)   self.qheader = '\n'.join(ph.message)   self.text.get_buffer().set_text(self.qheader)   self.get_toolbutton('_Commit').set_label('QRefresh')     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([])   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)   return True   else:   Prompt('Nothing Commited', 'No committable files selected', self).run()   return True     def _commit_selected(self, files):   import hgshelve   # 1a. get list of chunks not rejected   hlist = [x[DM_CHUNK_ID] for x in self.diff_model if not x[DM_REJECTED]]   repo, chunks, ui = self.repo, self._shelve_chunks, self.ui     # 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._filechunks: continue   if len(self._filechunks[f]) == 1: continue   if f not in self.modified: 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])   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):   begin, end = self.text.get_buffer().get_bounds()   message = self.text.get_buffer().get_text(begin, end)   if not self.test_opt('logfile') and not message:   Prompt('Nothing Commited', 'Please enter commit message', self).run()   self.text.grab_focus()   return False   else:   if not self.test_opt('logfile'):   self.opts['message'] = message   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(self.repo.root, 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     # 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.   cmdline = ['hg', 'commit', '--verbose', '--repository', self.repo.root]   if self.qheader is not None:   cmdline[1] = 'qrefresh'   if self.opts['addremove']:   cmdline += ['--addremove']   cmdline += ['--message', fromutf(self.opts['message'])]   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)   if self.qheader is None:   self.text.set_buffer(gtk.TextBuffer())   self._update_recent_messages(self.opts['message'])   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 launch(root='', files=[], cwd='', main=True):   u = ui.ui()   u.updateopts(debug=False, traceback=False)   repo = hg.repository(u, path=root)     # move cwd to repo root if repo is merged, so we can show   # all the changed files   if len(repo.changectx(None).parents()) > 1 and repo.root != cwd:   cwd = repo.root   repo = hg.repository(u, path=cwd)   files = [cwd]     ct = repo.ui.config('tortoisehg', 'commit', 'internal')   if ct not in ['', 'internal']:   from hglib import thgdispatch   args = ['--repository', root, ct]   try:   ret = thgdispatch(repo.ui, args=args)   except SystemExit:   pass   return None     cmdoptions = {   'user':'', 'date':'',   'modified':True, 'added':True, 'removed':True, 'deleted':True,   'unknown':True, 'ignored':False,   'exclude':[], 'include':[],   'check': True, 'git':False, 'logfile':'', 'addremove':False,   }     dialog = GCommit(u, repo, cwd, files, cmdoptions, main)   dialog.display()   return dialog    def run(root='', files=[], cwd='', **opts):   # If no files or directories were selected, take current dir   # TODO: Not clear if this is best; user may expect repo wide   if not files and cwd:   files = [cwd]   if launch(root, files, cwd, True):   gtk.gdk.threads_init()   gtk.gdk.threads_enter()   gtk.main()   gtk.gdk.threads_leave()    if __name__ == "__main__":   import sys   from hglib import rootpath     opts = {}   opts['cwd'] = len(sys.argv) > 1 and sys.argv[1] or os.getcwd()   opts['root'] = rootpath(opts['cwd'])   run(**opts)
Change 1 of 21 Show Entire File hggtk/​status.py Stacked
 
58
59
60
61
 
62
63
64
 
239
240
241
242
243
244
 
 
 
245
246
247
248
249
250
251
252
253
254
255
256
257
258
 
 
 
 
 
 
 
 
 
 
 
 
 
259
260
261
 
270
271
272
273
 
274
275
276
 
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
 
331
332
333
334
335
 
 
336
337
338
 
350
351
352
353
354
 
 
355
356
357
 
367
368
369
370
 
371
372
373
 
469
470
471
472
 
473
474
475
 
539
540
541
542
 
543
544
545
 
547
548
549
550
551
 
 
552
553
554
555
556
557
558
 
559
560
 
561
562
563
 
567
568
569
570
 
571
572
573
 
574
575
576
577
 
578
579
580
 
603
604
605
606
607
 
 
608
609
610
 
783
784
785
786
 
787
788
789
790
 
791
792
793
 
796
797
798
799
 
800
801
802
803
 
804
805
806
 
923
924
925
926
 
927
928
929
930
 
931
932
933
 
953
954
955
956
 
957
958
959
 
960
961
962
 
1216
1217
1218
1219
 
1220
1221
1222
 
1226
1227
1228
1229
 
1230
1231
1232
1233
1234
 
1235
1236
1237
 
1266
1267
1268
1269
 
1270
1271
1272
 
1282
1283
1284
1285
 
1286
1287
1288
 
1297
1298
1299
1300
 
1301
1302
1303
 
58
59
60
 
61
62
63
64
 
239
240
241
 
 
 
242
243
244
245
 
 
 
 
 
 
 
 
 
 
 
 
 
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
 
270
271
272
 
273
274
275
276
 
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
 
331
332
333
 
 
334
335
336
337
338
 
350
351
352
 
 
353
354
355
356
357
 
367
368
369
 
370
371
372
373
 
469
470
471
 
472
473
474
475
 
539
540
541
 
542
543
544
545
 
547
548
549
 
 
550
551
552
553
554
555
556
557
 
558
559
 
560
561
562
563
 
567
568
569
 
570
571
572
 
573
574
575
576
 
577
578
579
580
 
603
604
605
 
 
606
607
608
609
610
 
783
784
785
 
786
787
788
789
 
790
791
792
793
 
796
797
798
 
799
800
801
802
 
803
804
805
806
 
923
924
925
 
926
927
928
929
 
930
931
932
933
 
953
954
955
 
956
957
958
 
959
960
961
962
 
1216
1217
1218
 
1219
1220
1221
1222
 
1226
1227
1228
 
1229
1230
1231
1232
1233
 
1234
1235
1236
1237
 
1266
1267
1268
 
1269
1270
1271
1272
 
1282
1283
1284
 
1285
1286
1287
1288
 
1297
1298
1299
 
1300
1301
1302
1303
@@ -58,7 +58,7 @@
    def auto_check(self):   if self.test_opt('check'): - for entry in self.model: + for entry in self.filemodel:   entry[FM_CHECKED] = True   self._update_check_count()   @@ -239,23 +239,23 @@
  self._menus['MU'] = unresolved_menu     # model stores the file list. - self.model = gtk.ListStore(bool, str, str, str, str) - self.model.set_sort_func(1001, self._sort_by_stat) - self.model.set_default_sort_func(self._sort_by_stat) + self.filemodel = gtk.ListStore(bool, str, str, str, str, bool) + self.filemodel.set_sort_func(1001, self._sort_by_stat) + self.filemodel.set_default_sort_func(self._sort_by_stat)   - self.tree = gtk.TreeView(self.model) - self.tree.connect('button-press-event', self._tree_button_press) - self.tree.connect('button-release-event', self._tree_button_release) - self.tree.connect('popup-menu', self._tree_popup_menu) - self.tree.connect('row-activated', self._tree_row_act) - self.tree.connect('key-press-event', self._tree_key_press) - self.tree.set_reorderable(False) - self.tree.set_enable_search(True) - self.tree.set_search_column(2) - if hasattr(self.tree, 'set_rubber_banding'): - self.tree.set_rubber_banding(True) - self.tree.modify_font(pango.FontDescription(self.fontlist)) - self.tree.set_headers_clickable(True) + self.filetree = gtk.TreeView(self.filemodel) + self.filetree.connect('button-press-event', self._tree_button_press) + self.filetree.connect('button-release-event', self._tree_button_release) + self.filetree.connect('popup-menu', self._tree_popup_menu) + self.filetree.connect('row-activated', self._tree_row_act) + self.filetree.connect('key-press-event', self._tree_key_press) + self.filetree.set_reorderable(False) + self.filetree.set_enable_search(True) + self.filetree.set_search_column(2) + if hasattr(self.filetree, 'set_rubber_banding'): + self.filetree.set_rubber_banding(True) + self.filetree.modify_font(pango.FontDescription(self.fontlist)) + self.filetree.set_headers_clickable(True)     toggle_cell = gtk.CellRendererToggle()   toggle_cell.connect('toggled', self._select_toggle) @@ -270,7 +270,7 @@
  col0.add_attribute(toggle_cell, 'active', FM_CHECKED)   #col0.set_sort_column_id(0)   col0.set_resizable(False) - self.tree.append_column(col0) + self.filetree.append_column(col0)   self.selcb = self._add_header_checkbox(col0, self._sel_clicked)     col1 = gtk.TreeViewColumn('st', stat_cell) @@ -278,25 +278,25 @@
  col1.set_cell_data_func(stat_cell, self._text_color)   col1.set_sort_column_id(1001)   col1.set_resizable(False) - self.tree.append_column(col1) + self.filetree.append_column(col1)     col = gtk.TreeViewColumn('ms', stat_cell)   col.add_attribute(stat_cell, 'text', FM_MERGE_STATUS)   #col.set_cell_data_func(stat_cell, self._text_color)   col.set_sort_column_id(4)   col.set_resizable(False) - self.tree.append_column(col) + self.filetree.append_column(col)     col2 = gtk.TreeViewColumn('path', path_cell)   col2.add_attribute(path_cell, 'text', FM_PATH_UTF8)   col2.set_cell_data_func(path_cell, self._text_color)   col2.set_sort_column_id(2)   col2.set_resizable(True) - self.tree.append_column(col2) + self.filetree.append_column(col2)     scroller = gtk.ScrolledWindow()   scroller.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) - scroller.add(self.tree) + scroller.add(self.filetree)     tree_frame = gtk.Frame()   tree_frame.set_shadow_type(gtk.SHADOW_ETCHED_IN) @@ -331,8 +331,8 @@
  diffcol = gtk.TreeViewColumn('diff', diff_hunk_cell)   diffcol.set_resizable(True)   self.diff_tree.append_column(diffcol) - self.tree.get_selection().set_mode(gtk.SELECTION_MULTIPLE) - self.tree.get_selection().connect('changed', + self.filetree.get_selection().set_mode(gtk.SELECTION_MULTIPLE) + self.filetree.get_selection().connect('changed',   self._tree_selection_changed, False)   scroller.add(self.diff_tree)   @@ -350,8 +350,8 @@
  self.merge_diff_text.set_wrap_mode(gtk.WRAP_NONE)   self.merge_diff_text.set_editable(False)   self.merge_diff_text.modify_font(pango.FontDescription(self.fontdiff)) - self.tree.get_selection().set_mode(gtk.SELECTION_SINGLE) - self.tree.get_selection().connect('changed', + self.filetree.get_selection().set_mode(gtk.SELECTION_SINGLE) + self.filetree.get_selection().connect('changed',   self._merge_tree_selection_changed, False)   self._activate_shelve_buttons(False)   scroller.add(self.merge_diff_text) @@ -367,7 +367,7 @@
  self._diffpane.set_position(self._setting_pos)   self._diffpane_moved_id = self._diffpane.connect('notify::position',   self._diffpane_moved) - self.tree.set_headers_clickable(True) + self.filetree.set_headers_clickable(True)   return self._diffpane     def _patch_button_release(self, widget, event): @@ -469,7 +469,7 @@
  def _update_check_count(self):   file_count = 0   check_count = 0 - for row in self.model: + for row in self.filemodel:   file_count = file_count + 1   if row[FM_CHECKED]:   check_count = check_count + 1 @@ -539,7 +539,7 @@
  explicit_changetypes = changetypes + (('clean', 'C', clean),)     # List of the currently checked and selected files to pass on to the new data - model, paths = self.tree.get_selection().get_selected_rows() + model, paths = self.filetree.get_selection().get_selected_rows()   recheck = [entry[FM_PATH_UTF8] for entry in model if entry[FM_CHECKED]]   reselect = [model[iter][FM_PATH_UTF8] for iter in paths]   @@ -547,17 +547,17 @@
  ms = merge_.mergestate(self.repo)     # Load the new data into the tree's model - self.tree.hide() - self.model.clear() + self.filetree.hide() + self.filemodel.clear()     for opt, char, changes in ([ct for ct in explicit_changetypes   if self.test_opt(ct[0])] or changetypes) :   for file in changes:   mst = file in ms and ms[file].upper() or ""   file = util.localpath(file) - self.model.append([file in recheck, char, toutf(file), file, mst]) + self.filemodel.append([file in recheck, char, toutf(file), file, mst, False])   - selection = self.tree.get_selection() + selection = self.filetree.get_selection()   selected = False   for row in model:   if row[FM_PATH_UTF8] in reselect: @@ -567,14 +567,14 @@
  if not selected:   selection.select_path((0,))   - files = [row[FM_PATH] for row in self.model] + files = [row[FM_PATH] for row in self.filemodel]   self._show_diff_hunks(files)   - self.tree.show() + self.filetree.show()   if hasattr(self, 'text'):   self.text.grab_focus()   else: - self.tree.grab_focus() + self.filetree.grab_focus()   return True     @@ -603,8 +603,8 @@
    def _select_toggle(self, cellrenderer, path):   '''User manually toggled file status''' - self.model[path][FM_CHECKED] = not self.model[path][FM_CHECKED] - self._update_chunk_state(self.model[path]) + self.filemodel[path][FM_CHECKED] = not self.filemodel[path][FM_CHECKED] + self._update_chunk_state(self.filemodel[path])   self._update_check_count()   return True   @@ -783,11 +783,11 @@
  self.merge_diff_text.set_buffer(buffer)     if self.showdiff_toggle.get_active(): - sel = self.tree.get_selection().get_selected_rows()[1] + sel = self.filetree.get_selection().get_selected_rows()[1]   if not sel:   self._last_file = None   return False - file = self.model[sel[0]][2] + file = self.filemodel[sel[0]][FM_PATH_UTF8]   if force or file != self._last_file:   self._last_file = file   self._hg_call_wrapper('Diff', dohgdiff) @@ -796,11 +796,11 @@
    def _tree_selection_changed(self, selection, force):   if self.showdiff_toggle.get_active(): - sel = self.tree.get_selection().get_selected_rows()[1] + sel = self.filetree.get_selection().get_selected_rows()[1]   if not sel:   self._last_file = None   return False - file = self.model[sel[0]][2] + file = self.filemodel[sel[0]][FM_PATH_UTF8]   if force or file != self._last_file:   self._last_file = file   if file in self._filechunks: @@ -923,11 +923,11 @@
    if togglebutton.get_active():   if hasattr(self, 'merge_diff_text'): - self._merge_tree_selection_changed(self.tree.get_selection(), True) + self._merge_tree_selection_changed(self.filetree.get_selection(), True)   self._activate_shelve_buttons(False)   else:   self._activate_shelve_buttons(True) - self._tree_selection_changed(self.tree.get_selection(), True) + self._tree_selection_changed(self.filetree.get_selection(), True)   self._diffpane.set_position(self._setting_lastpos)   else:   self._setting_lastpos = self._diffpane.get_position() @@ -953,10 +953,10 @@
  elif paned.get_position() < sizemax - 55:   self.showdiff_toggle.set_active(True)   if hasattr(self, 'merge_diff_text'): - self._merge_tree_selection_changed(self.tree.get_selection(), True) + self._merge_tree_selection_changed(self.filetree.get_selection(), True)   self._activate_shelve_buttons(False)   else: - self._tree_selection_changed(self.tree.get_selection(), True) + self._tree_selection_changed(self.filetree.get_selection(), True)   self._activate_shelve_buttons(True)     self.showdiff_toggle.handler_unblock(self._showdiff_toggled_id) @@ -1216,7 +1216,7 @@
      def _select_files(self, state, ctype=None): - for entry in self.model: + for entry in self.filemodel:   if ctype and not entry[FM_STATUS] in ctype:   continue   if entry[FM_CHECKED] != state: @@ -1226,12 +1226,12 @@
      def _relevant_files(self, stats): - return [item[FM_PATH] for item in self.model \ + return [item[FM_PATH] for item in self.filemodel \   if item[FM_CHECKED] and item[FM_STATUS] in stats]       def _context_menu_act(self, menuitem, handler): - selection = self.tree.get_selection() + selection = self.filetree.get_selection()   assert(selection.count_selected_rows() == 1)     list, paths = selection.get_selected_rows() @@ -1266,7 +1266,7 @@
  return menu     def _tree_popup_menu(self, widget, button=0, time=0) : - selection = self.tree.get_selection() + selection = self.filetree.get_selection()   if selection.count_selected_rows() != 1:   return False   @@ -1282,7 +1282,7 @@
  list[path][FM_CHECKED] = not list[path][FM_CHECKED]   self._update_chunk_state(list[path])   - selection = self.tree.get_selection() + selection = self.filetree.get_selection()   selection.selected_foreach(toggler)   return True   return False @@ -1297,7 +1297,7 @@
  self._ignore_next_act = False   return True   - selection = self.tree.get_selection() + selection = self.filetree.get_selection()   if selection.count_selected_rows() != 1:   return False