Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 1.1, 1.1.1, and 1.1.2

made hgtk adapt to dark color schemes

Changeset 81e9adc8efb2

Parent 0bfd2f6747ac

by Mathias Panzenböck

Changes to 9 files · Browse files at 81e9adc8efb2 Showing diff from parent 0bfd2f6747ac Diff from another changeset...

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
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
 
789
790
791
792
793
794
795
796
797
798
799
800
 
801
802
 
803
804
 
805
806
 
807
808
809
810
 
811
812
813
814
 
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
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
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
 
787
788
789
790
791
792
793
794
795
796
797
798
 
799
800
 
801
802
 
803
804
 
805
806
807
808
 
809
810
811
812
 
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
 # changeset.py - Changeset dialog for TortoiseHg  #  # Copyright 2008 Steve Borho <steve@borho.org>  #  # This software may be used and distributed according to the terms of the  # GNU General Public License version 2, incorporated herein by reference.    import os  import re  import gtk  import gobject  import pango  import Queue    from mercurial import cmdutil, util, patch, mdiff, error    from tortoisehg.util.i18n import _  from tortoisehg.util import shlib, hglib, paths    from tortoisehg.hgtk import csinfo, gdialog, gtklib, hgcmd, statusbar    class ChangeSet(gdialog.GWindow):   'GTK+ based dialog for displaying repository logs'   def __init__(self, ui, repo, cwd, pats, opts, stbar=None):   gdialog.GWindow.__init__(self, ui, repo, cwd, pats, opts)   self.stbar = stbar   self.glog_parent = None   self.bfile = None   self.colorstyle = repo.ui.config('tortoisehg', 'diffcolorstyle')     # initialize changeset/issue tracker link regex and dict   csmatch = r'(\b[0-9a-f]{12}(?:[0-9a-f]{28})?\b)'   httpmatch = r'(\b(http|https)://([-A-Za-z0-9+&@#/%?=~_()|!:,.;]*[-A-Za-z0-9+&@#/%=~_()|]))'   issue = repo.ui.config('tortoisehg', 'issue.regex')   if issue:   regexp = r'%s|%s|(%s)' % (csmatch, httpmatch, issue)   else:   regexp = r'%s|%s' % (csmatch, httpmatch)   self.bodyre = re.compile(regexp)   self.issuedict = dict()     def get_title(self):   title = _('%s changeset ') % self.get_reponame()   rev = self.opts['rev']   if isinstance(rev, str):   title += rev   else:   title += rev[0]   return title     def get_icon(self):   return 'menushowchanged.ico'     def get_tbbuttons(self):   return []     def parent_toggled(self, button):   self.load_details(self.currev)     def prepare_display(self):   self.currow = None   self.graphview = None   self.glog_parent = None   node0, node1 = cmdutil.revpair(self.repo, self.opts.get('rev'))   self.load_details(self.repo.changelog.rev(node0))     def save_settings(self):   settings = gdialog.GWindow.save_settings(self)   settings['changeset'] = self._hpaned.get_position()   return settings     def load_settings(self, settings):   gdialog.GWindow.load_settings(self, settings)   if settings and 'changeset' in settings:   self._setting_hpos = settings['changeset']   else:   self._setting_hpos = -1     def set_repo(self, repo):   self.repo = repo   self.summarypanel.update(repo=repo)     def clear_cache(self):   self.summarypanel.info.clear_cache()     def clear(self):   self._buffer.set_text('')   self._filelist.clear()   self.summarybox.hide()     def diff_other_parent(self):   return self.parent_button.get_active()     def load_details(self, rev):   'Load selected changeset details into buffer and filelist'   oldrev = hasattr(self, 'currev') and self.currev or None   self.currev = rev   ctx = self.repo[rev]   if not ctx:   return     parents = ctx.parents()   title = self.get_title()   if parents:   if len(parents) == 2:   # deferred adding of parent check button   if not self.parent_button.parent:   self.parent_box.pack_start(self.parent_button, False, False)   self.parent_box.pack_start(gtk.HSeparator(), False, False)   self.parent_box.show_all()     # show parent box   self.parent_box.show()     # uncheck the check button   if rev != oldrev:   self.parent_button.handler_block_by_func(   self.parent_toggled)   self.parent_button.set_active(False)   self.parent_button.handler_unblock_by_func(   self.parent_toggled)     # determine title and current parent   if self.diff_other_parent():   title += ':' + str(parents[1].rev())   parent = parents[1].node()   else:   title += ':' + str(parents[0].rev())   parent = parents[0].node()     # clear cache for highlighting parent correctly   self.clear_cache()   else:   # hide parent box   self.parent_box.hide()   parent = parents[0].node()   else:   parent = self.repo[-1]     oldother = hasattr(self, 'otherparent') and self.otherparent or None   self.otherparent = len(parents) == 2 and self.diff_other_parent()     # refresh merge row without graph redrawing   if self.graphview:   gview = self.graphview   if oldother:   gview.model.clear_parents()   elif self.otherparent:   gview.model.set_parent(ctx.rev(), parent)   gview.hide()   gview.show()     # update dialog title   self.set_title(title)     pats = self.pats   if self.graphview:   (path, focus) = self.graphview.treeview.get_cursor()   if path:   wfile = self.graphview.get_wfile_at_path(path)   if wfile:   pats.append(wfile)     self._filelist.clear()   self._filelist.append(('*', _('[All Files]'), ''))   modified, added, removed = self.repo.status(parent, ctx.node())[:3]   selrow = None   for f in modified:   if f in pats:   selrow = len(self._filelist)   self._filelist.append(('M', hglib.toutf(f), f))   for f in added:   if f in pats:   selrow = len(self._filelist)   self._filelist.append(('A', hglib.toutf(f), f))   for f in removed:   if f in pats:   selrow = len(self._filelist)   self._filelist.append(('R', hglib.toutf(f), f))   self.curnodes = (parent, ctx.node())   if selrow is not None:   self._filesel.select_path((selrow,))   self._filelist_tree.set_cursor((selrow,))   elif len(self._filelist) > 1:   self._filesel.select_path((1,))   self._filelist_tree.set_cursor((1,))   else:   self._filesel.select_path((0,))     self.reset_scroll_pos()     def load_patch_details(self, patchfile):   'Load specified patch details into buffer and file list'   self._filelist.clear()   self._filelist.append(('*', _('[All Files]'), ''))     # append files & collect hunks   self.currev = -1   self.curphunks = {}   self.curpatch = patchfile   pf = open(self.curpatch)   def get_path(a, b):   type = (a == '/dev/null') and 'A' or 'M'   type = (b == '/dev/null') and 'R' or type   rawpath = (b != '/dev/null') and b or a   if not (rawpath.startswith('a/') or rawpath.startswith('b/')):   return type, rawpath   return type, rawpath.split('/', 1)[-1]   hunks = []   files = []   map = {'MODIFY': 'M', 'ADD': 'A', 'DELETE': 'R',   'RENAME': '', 'COPY': ''}   try:   try:   for state, values in patch.iterhunks(self.ui, pf):   if state == 'git':   for m in values:   f = m.path   self._filelist.append((map[m.op], hglib.toutf(f), f))   files.append(f)   elif state == 'file':   type, path = get_path(values[0], values[1])   self.curphunks[path] = hunks = ['diff']   if path not in files:   self._filelist.append((type, hglib.toutf(path), path))   files.append(path)   elif state == 'hunk':   hunks.extend([l.rstrip('\r\n') for l in values.hunk])   else:   raise _('unknown hunk type: %s') % state   except patch.NoHunks:   pass   finally:   pf.close()     # select first file   if len(self._filelist) > 1:   self._filesel.select_path((1,))   else:   self._filesel.select_path((0,))     self.reset_scroll_pos()     def filelist_rowchanged(self, sel):   model, path = sel.get_selected()   if not path:   return   status, file_utf8, file = model[path]   if self.currev != -1:   self.curfile = file   self.generate_change_header()   if self.curfile:   self.append_diff(self.curfile)   else:   for _, _, f in model:   self.append_diff(f)   else:   self.generate_patch_header()   if file:   self.append_patch_diff(file)   else:   self.append_all_patch_diffs()     def reset_scroll_pos(self):   adj = self.diffscroller.get_vadjustment()   adj.set_value(0)   adj = self.diffscroller.get_hadjustment()   adj.set_value(0)     def generate_change_header(self):   self.summarypanel.update(self.currev, self.csetstyle)   self.summarybox.show()     desc = self.summarypanel.get_data('desc')   self.set_commitlog(desc)     def generate_patch_header(self):   self.summarypanel.update(self.curpatch, self.patchstyle)   self.summarybox.show()     desc = self.summarypanel.get_data('desc')   self.set_commitlog(desc)     def set_commitlog(self, desc):   'Append commit log after clearing buffer'   buf = self._buffer   buf.set_text('')   eob = buf.get_end_iter()   desc = desc.rstrip('\n\r')     pos = 0   self.issuedict.clear()   for m in self.bodyre.finditer(desc):   a, b = m.span()   if a > pos:   buf.insert(eob, desc[pos:a])   pos = b   groups = m.groups()   if groups[0]:   link = groups[0]   buf.insert_with_tags_by_name(eob, link, 'csetlink')   elif groups[1]:   link = groups[1]   buf.insert_with_tags_by_name(eob, link, 'urllink')   else:   link = groups[4]   if len(groups) > 4:   self.issuedict[link] = groups[4:]   buf.insert_with_tags_by_name(eob, link, 'issuelink')   if pos < len(desc):   buf.insert(eob, desc[pos:])   buf.insert(eob, '\n\n')     def append_diff(self, wfile):   if not wfile:   return   buf, rev = self._buffer, self.currev   n1, n2 = self.curnodes     eob = buf.get_end_iter()   offset = eob.get_offset()     try:   fctx = self.repo[rev].filectx(wfile)   except error.LookupError:   fctx = None   if fctx and fctx.size() > hglib.getmaxdiffsize(self.repo.ui):   lines = ['diff',   _(' %s is larger than the specified max diff size') % wfile]   else:   lines = []   m = cmdutil.matchfiles(self.repo, [wfile])   opts = mdiff.diffopts(git=True, nodates=True)   try:   for s in patch.diff(self.repo, n1, n2, match=m, opts=opts):   lines.extend(s.splitlines())   except (error.RepoLookupError, error.RepoError, error.LookupError), e:   err = _('Repository Error: %s, refresh suggested') % str(e)   lines = ['diff', '', err]   tags, lines = self.prepare_diff(lines, offset, wfile)   for l in lines:   buf.insert(eob, l) -   # inserts the tags   for name, p0, p1 in tags:   i0 = buf.get_iter_at_offset(p0)   i1 = buf.get_iter_at_offset(p1)   buf.apply_tag_by_name(name, i0, i1)     sob, eob = buf.get_bounds()   pos = buf.get_iter_at_offset(offset)   buf.apply_tag_by_name('diff', pos, eob)   return True     def append_patch_diff(self, patchfile):   if not patchfile:   return     # append diffs   buf = self._buffer   eob = buf.get_end_iter()   offset = eob.get_offset()   lines = self.curphunks[patchfile]   tags, lines = self.prepare_diff(lines, offset, patchfile)   for line in lines:   buf.insert(eob, line)     # insert the tags   for name, p0, p1 in tags:   i0 = buf.get_iter_at_offset(p0)   i1 = buf.get_iter_at_offset(p1)   buf.apply_tag_by_name(name, i0, i1)     sob, eob = buf.get_bounds()   pos = buf.get_iter_at_offset(offset)   buf.apply_tag_by_name('diff', pos, eob)     def append_all_patch_diffs(self):   model = self._filelist   if len(model) > 1:   for st, fu, fn in model:   self.append_patch_diff(fn)   else:   self._buffer.insert(self._buffer.get_end_iter(),   '\n' + _('[no hunks to display]'))     def prepare_diff(self, difflines, offset, fname):   'Borrowed from hgview; parses changeset diffs'   def addtag( name, offset, length ):   if tags and tags[-1][0] == name and tags[-1][2]==offset:   tags[-1][2] += length   else:   tags.append( [name, offset, offset+length] )     add, rem = 0, 0   for l in difflines[1:]:   if l.startswith('+'):   add += 1   elif l.startswith('-'):   rem += 1   outlines = []   tags = []   txt = hglib.toutf('=== (+%d,-%d) %s ===\n' % (add, rem, fname))   addtag( 'greybg', offset, len(txt) )   outlines.append(txt)   offset += len(txt.decode('utf-8'))   for l1 in difflines[1:]:   l = hglib.toutf(l1)   if l.startswith('--- '):   continue   if l.startswith('+++ '):   continue   if l.startswith('@@'):   tag = 'blue'   elif l.startswith('+'):   tag = 'green'   l = hglib.diffexpand(l)   elif l.startswith('-'):   tag = 'red'   l = hglib.diffexpand(l)   else: - tag = 'black' + tag = 'normal'   l = hglib.diffexpand(l)   l = l+"\n"   length = len(l.decode('utf-8'))   addtag( tag, offset, length )   outlines.append( l )   offset += length   return tags, outlines     def link_event(self, label, event, revnum):   revnum = int(revnum)   if self.graphview:   self.graphview.set_revision_id(revnum, load=True)   else:   self.load_details(revnum)     def file_context_menu(self):   m = gtklib.MenuBuilder()   m.append(_('_Visual Diff'), self.diff_file_rev,   gtk.STOCK_JUSTIFY_FILL)   m.append(_('Diff to _local'), self.diff_to_local)   m.append_sep()   m.append(_('_View at Revision'), self.view_file_rev, gtk.STOCK_EDIT)   self.msave = m.append(_('_Save at Revision...'),   self.save_file_rev, gtk.STOCK_SAVE)   m.append_sep()   m.append(_('_File History'), self.file_history, 'menulog.ico')   self.ann_menu = m.append(_('_Annotate File'), self.ann_file,   'menublame.ico')   m.append_sep()   m.append(_('_Revert File Contents'), self.revert_file,   gtk.STOCK_MEDIA_REWIND)     menu = m.build()   menu.show_all()   return menu     def get_body(self):   embedded = bool(self.stbar)   use_expander = embedded and self.ui.configbool(   'tortoisehg', 'changeset-expander')     self.curfile = ''   self.filemenu = self.file_context_menu()     details_frame_parent = gtk.VBox()     # changeset frame   details_frame = gtk.Frame()   details_frame.set_shadow_type(gtk.SHADOW_ETCHED_IN)   scroller = gtk.ScrolledWindow()   scroller.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)   details_frame.add(scroller)   self.diffscroller = scroller     details_box = gtk.VBox()   scroller.add_with_viewport(details_box)   scroller.child.set_shadow_type(gtk.SHADOW_NONE)     ## changeset panel   def revid_markup(revid, **kargs):   opts = dict(face='monospace', size='9000')   opts.update(kargs)   return gtklib.markup(revid, **opts)   def data_func(widget, item, ctx):   def summary_line(desc):   desc = hglib.tounicode(desc.replace('\0', '').split('\n')[0])   return hglib.toutf(desc[:80])   def revline_data(ctx, hl=False, branch=None):   if isinstance(ctx, basestring):   return ctx   desc = ctx.description()   return (str(ctx.rev()), str(ctx), summary_line(desc), hl, branch)   if item == 'cset':   return revline_data(ctx)   elif item == 'branch':   value = hglib.toutf(ctx.branch())   return value != 'default' and value or None   elif item == 'parents':   pindex = self.diff_other_parent() and 1 or 0   pctxs = ctx.parents()   parents = []   for pctx in pctxs:   highlight = len(pctxs) == 2 and pctx == pctxs[pindex]   branch = None   if hasattr(pctx, 'branch') and pctx.branch() != ctx.branch():   branch = pctx.branch()   parents.append(revline_data(pctx, highlight, branch))   return parents   elif item == 'children':   children = []   for cctx in ctx.children():   branch = None   if hasattr(cctx, 'branch') and cctx.branch() != ctx.branch():   branch = cctx.branch()   children.append(revline_data(cctx, branch=branch))   return children   elif item in ('transplant', 'p4', 'svn'):   ts = widget.get_data(item, usepreset=True)   if not ts:   return None   try:   tctx = self.repo[ts]   return revline_data(tctx)   except (error.LookupError, error.RepoLookupError, error.RepoError):   return ts   elif item == 'patch':   if hasattr(ctx, '_patchname'):   desc = ctx.description()   return (ctx._patchname, str(ctx), summary_line(desc))   return None   raise csinfo.UnknownItem(item)   def label_func(widget, item):   if item == 'cset':   return _('Changeset:')   elif item == 'parents':   return _('Parent:')   elif item == 'children':   return _('Child:')   elif item == 'patch':   return _('Patch:')   raise csinfo.UnknownItem(item)   def markup_func(widget, item, value):   def revline_markup(revnum, revid, summary, highlight=None, branch=None):   revnum = gtklib.markup(revnum)   summary = gtklib.markup(summary)   if revid:   revid = revid_markup(revid)   if branch:   return '%s (%s) %s %s' % (revnum, revid, branch, summary)   return '%s (%s) %s' % (revnum, revid, summary)   else:   if branch:   return '%s - %s %s' % (revnum, branch, summary)   return '%s - %s' % (revnum, summary)   if item in ('cset', 'transplant', 'patch', 'p4', 'svn'):   if isinstance(value, basestring):   return revid_markup(value)   return revline_markup(*value)   elif item in ('parents', 'children'):   csets = []   for cset in value:   if isinstance(cset, basestring):   csets.append(revid_markup(cset))   else:   csets.append(revline_markup(*cset))   return csets   raise csinfo.UnknownItem(item)   def widget_func(widget, item, markups):   def linkwidget(revnum, revid, summary, highlight=None, branch=None):   # revision label - opts = dict(underline='single', color='blue') + opts = dict(underline='single', color=gtklib.BLUE)   if highlight:   opts['weight'] = 'bold'   rev = '%s (%s)' % (gtklib.markup(revnum, **opts),   revid_markup(revid, **opts))   revlabel = gtk.Label()   revlabel.set_markup(rev)   revlabel.set_selectable(True)   revlabel.connect('button-release-event', self.link_event, revnum)   # summary & branch label   sum = gtklib.markup(summary)   if branch: - sum = gtklib.markup(branch, color='black', + sum = gtklib.markup(branch, color=gtklib.NORMAL,   background=gtklib.PGREEN) + ' ' + sum   sumlabel = gtk.Label()   sumlabel.set_markup(sum)   sumlabel.set_selectable(True)   box = gtk.HBox()   box.pack_start(revlabel, False, False)   box.pack_start(sumlabel, True, True, 4)   return box   def genwidget(param):   if isinstance(param, basestring):   label = gtk.Label()   label.set_markup(param)   label.set_selectable(True)   return label   return linkwidget(*param)   if item in ('parents', 'children'):   csets = widget.get_data(item)   return [genwidget(cset) for cset in csets]   elif item == 'transplant':   cset = widget.get_data(item)   return genwidget(cset)   raise csinfo.UnknownItem(item)     custom = csinfo.custom(data=data_func, label=label_func,   markup=markup_func, widget=widget_func)   self.csetstyle = csinfo.panelstyle(contents=('cset', 'branch',   'user', 'dateage', 'parents', 'children',   'tags', 'transplant', 'p4', 'svn'), selectable=True)   self.patchstyle = csinfo.panelstyle(contents=('patch', 'branch',   'user', 'dateage', 'parents'),   selectable=True)   if use_expander:   self.csetstyle['expander'] = True   self.patchstyle['expander'] = True     self.summarypanel = csinfo.create(self.repo, custom=custom)     ## summary box (summarypanel + separator)   self.summarybox = gtk.VBox()   if use_expander:   # don't scroll summarybox   details_frame_parent.pack_start(self.summarybox, False, False)   else:   # scroll summarybox   details_box.pack_start(self.summarybox, False, False)   self.summarybox.pack_start(self.summarypanel, False, False)   self.summarybox.pack_start(gtk.HSeparator(), False, False)     ## changeset diff   details_text = gtk.TextView()   details_text.set_wrap_mode(gtk.WRAP_NONE)   details_text.connect('populate-popup', self.add_to_popup)   details_text.set_editable(False)   details_text.modify_font(self.fonts['comment'])   details_box.pack_start(details_text)     self._buffer = gtk.TextBuffer()   self.setup_tags()   details_text.set_buffer(self._buffer)   self.textview = details_text     ## file list   filelist_tree = gtk.TreeView()   filelist_tree.set_headers_visible(False)   filesel = filelist_tree.get_selection()   filesel.connect('changed', self.filelist_rowchanged)   self._filesel = filesel   filelist_tree.connect('button-release-event',   self.file_button_release)   filelist_tree.connect('popup-menu', self.file_popup_menu)   filelist_tree.connect('row-activated', self.file_row_act)   filelist_tree.set_search_equal_func(self.search_filelist)   filelist_tree.modify_font(self.fonts['list'])   self._filelist_tree = filelist_tree     accelgroup = gtk.AccelGroup()   if self.glog_parent:   self.glog_parent.add_accel_group(accelgroup)   else:   self.add_accel_group(accelgroup)   mod = gtklib.get_thg_modifier()   key, modifier = gtk.accelerator_parse(mod+'d')   filelist_tree.add_accelerator('thg-diff', accelgroup, key,   modifier, gtk.ACCEL_VISIBLE)   filelist_tree.connect('thg-diff', self.thgdiff)     def scroll_details(widget, direction=gtk.SCROLL_PAGE_DOWN):   self.diffscroller.emit("scroll-child", direction, False)     # signal, accelerator key, handler, (parameters,)   status_accelerators = [   ('status-scroll-down', 'bracketright', scroll_details,   (gtk.SCROLL_PAGE_DOWN,)),   ('status-scroll-up', 'bracketleft', scroll_details,   (gtk.SCROLL_PAGE_UP,)),   ('status-next-file', 'period', gtklib.move_treeview_selection,   (filelist_tree, 1)),   ('status-previous-file', 'comma', gtklib.move_treeview_selection,   (filelist_tree, -1)),   ]     for signal, accelerator, handler, param in status_accelerators:   root = self.glog_parent or self   gtklib.add_accelerator(root, signal, accelgroup,   mod + accelerator)   root.connect(signal, handler, *param)     self._filelist = gtk.ListStore(   gobject.TYPE_STRING, # MAR status   gobject.TYPE_STRING, # filename (utf-8 encoded)   gobject.TYPE_STRING, # filename   )   filelist_tree.set_model(self._filelist)     column = gtk.TreeViewColumn()   filelist_tree.append_column(column)     iconcell = gtk.CellRendererPixbuf()   filecell = gtk.CellRendererText()     column.pack_start(iconcell, expand=False)   column.pack_start(filecell, expand=False)   column.add_attribute(filecell, 'text', 1)     size = gtk.ICON_SIZE_SMALL_TOOLBAR   addedpixbuf = gtklib.get_icon_pixbuf('fileadd.ico', size)   removedpixbuf = gtklib.get_icon_pixbuf('filedelete.ico', size)   modifiedpixbuf = gtklib.get_icon_pixbuf('filemodify.ico', size)     def cell_seticon(column, cell, model, iter):   state = model.get_value(iter, 0)   pixbuf = None   if state == 'A':   pixbuf = addedpixbuf   elif state == 'R':   pixbuf = removedpixbuf   elif state == 'M':   pixbuf = modifiedpixbuf   cell.set_property('pixbuf', pixbuf)     column.set_cell_data_func(iconcell, cell_seticon)     list_frame = gtk.Frame()   list_frame.set_shadow_type(gtk.SHADOW_ETCHED_IN)   scroller = gtk.ScrolledWindow()   scroller.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)   scroller.add(filelist_tree)   flbox = gtk.VBox()   list_frame.add(flbox)   self.parent_box = gtk.VBox()   flbox.pack_start(self.parent_box, False, False)   flbox.pack_start(scroller)     btn = gtk.CheckButton(_('Diff to second Parent'))   btn.connect('toggled', self.parent_toggled)   # don't pack btn yet to keep it initially invisible   self.parent_button = btn     self._hpaned = gtk.HPaned()   self._hpaned.pack1(list_frame, True, True)   self._hpaned.pack2(details_frame_parent, True, True)   self._hpaned.set_position(self._setting_hpos)     details_frame_parent.pack_start(details_frame, True, True)     if embedded:   # embedded by changelog browser   return self._hpaned   else:   # add status bar for main app   vbox = gtk.VBox()   vbox.pack_start(self._hpaned, True, True)   self.stbar = statusbar.StatusBar()   self.stbar.show()   vbox.pack_start(gtk.HSeparator(), False, False)   vbox.pack_start(self.stbar, False, False)   return vbox     def search_filelist(self, model, column, key, iter):   'case insensitive filename search'   key = key.lower()   if key in model.get_value(iter, 1).lower():   return False   return True     def setup_tags(self):   'Creates the tags to be used inside the TextView'   def make_texttag(name, **kwargs):   'Helper function generating a TextTag'   tag = gtk.TextTag(name)   for key, value in kwargs.iteritems():   key = key.replace("_","-")   try:   tag.set_property(key, value)   except TypeError:   print "Warning the property %s is unsupported in" % key   print "this version of pygtk"   return tag     tag_table = self._buffer.get_tag_table()     tag_table.add(make_texttag('diff', font=self.rawfonts['fontdiff'])) - tag_table.add(make_texttag('blue', foreground='blue')) + tag_table.add(make_texttag('blue', foreground=gtklib.BLUE))   if self.colorstyle == 'background':   tag_table.add(make_texttag('red',   paragraph_background=gtklib.PRED))   tag_table.add(make_texttag('green',   paragraph_background=gtklib.PGREEN))   elif self.colorstyle == 'none':   tag_table.add(make_texttag('red'))   tag_table.add(make_texttag('green'))   else:   tag_table.add(make_texttag('red', foreground=gtklib.DRED))   tag_table.add(make_texttag('green', foreground=gtklib.DGREEN)) - tag_table.add(make_texttag('black', foreground='black')) + tag_table.add(make_texttag('normal', foreground=gtklib.NORMAL))   tag_table.add(make_texttag('greybg', - paragraph_background='grey', + paragraph_background=gtklib.CHANGE_HEADER,   weight=pango.WEIGHT_BOLD)) - tag_table.add(make_texttag('yellowbg', background='yellow')) + tag_table.add(make_texttag('yellowbg', background=gtklib.YELLOW))   - issuelink_tag = make_texttag('issuelink', foreground='blue', + issuelink_tag = make_texttag('issuelink', foreground=gtklib.BLUE,   underline=pango.UNDERLINE_SINGLE)   issuelink_tag.connect('event', self.issuelink_event)   tag_table.add(issuelink_tag) - urllink_tag = make_texttag('urllink', foreground='blue', + urllink_tag = make_texttag('urllink', foreground=gtklib.BLUE,   underline=pango.UNDERLINE_SINGLE)   urllink_tag.connect('event', self.urllink_event)   tag_table.add(urllink_tag) - csetlink_tag = make_texttag('csetlink', foreground='blue', + csetlink_tag = make_texttag('csetlink', foreground=gtklib.BLUE,   underline=pango.UNDERLINE_SINGLE)   csetlink_tag.connect('event', self.csetlink_event)   tag_table.add(csetlink_tag)     def urllink_event(self, tag, widget, event, liter):   if event.type != gtk.gdk.BUTTON_RELEASE:   return   text = self.get_link_text(tag, widget, liter)   shlib.browse_url(text)     def issuelink_event(self, tag, widget, event, liter):   if event.type != gtk.gdk.BUTTON_RELEASE:   return   text = self.get_link_text(tag, widget, liter)   if not text:   return   link = self.repo.ui.config('tortoisehg', 'issue.link')   if link:   groups = self.issuedict.get(text, [text])   link, num = re.subn(r'\{(\d+)\}', lambda m:   groups[int(m.group(1))], link)   if not num:   link += text   shlib.browse_url(link)     def csetlink_event(self, tag, widget, event, liter):   if event.type != gtk.gdk.BUTTON_RELEASE:   return   text = self.get_link_text(tag, widget, liter)   if not text:   return   try:   rev = self.repo[text].rev()   if self.graphview:   self.graphview.set_revision_id(rev, load=True)   else:   self.load_details(rev)   except error.RepoError:   pass     def get_link_text(self, tag, widget, liter):   text_buffer = widget.get_buffer()   beg = liter.copy()   while not beg.begins_tag(tag):   beg.backward_char()   end = liter.copy()   while not end.ends_tag(tag):   end.forward_char()   text = text_buffer.get_text(beg, end)   return text     def file_button_release(self, widget, event):   if event.button == 3 and not (event.state & (gtk.gdk.SHIFT_MASK |   gtk.gdk.CONTROL_MASK)):   self.file_popup_menu(widget, event.button, event.time)   return False     def file_popup_menu(self, treeview, button=0, time=0):   if not self.curfile:   return   self.filemenu.popup(None, None, None, button, time)     # If the filelog entry this changeset references does not link   # back to this changeset, it means this changeset did not   # actually change the contents of this file, and thus the file   # cannot be annotated at this revision (since this changeset   # does not appear in the filelog)   ctx = self.repo[self.currev]   try:   fctx = ctx.filectx(self.curfile)   has_filelog = fctx.filelog().linkrev(fctx.filerev()) == ctx.rev()   except error.LookupError:   has_filelog = False   self.ann_menu.set_sensitive(has_filelog)   self.msave.set_sensitive(has_filelog)   return True     def thgdiff(self, treeview):   # Do not steal ctrl-d from changelog treeview   if not treeview.is_focus() and self.glog_parent:   w = self.glog_parent.get_focus()   if isinstance(w, gtk.TreeView):   w.emit('thg-diff')   return False   if not self.curfile:   return False   opts = {'change':str(self.currev), 'bundle':self.bfile}   self._do_diff([self.curfile], opts)     def file_row_act(self, tree, path, column):   self.diff_file_rev(None)   return True     def save_file_rev(self, menuitem):   wfile = util.localpath(self.curfile)   wfile, ext = os.path.splitext(os.path.basename(wfile))   if wfile:   filename = "%s@%d%s" % (wfile, self.currev, ext)   else:   filename = "%s@%d" % (ext, self.currev)   result = gtklib.NativeSaveFileDialogWrapper(title=_("Save file to"),   initial=self.cwd,   filename=filename).run()   if result:   q = Queue.Queue()   hglib.hgcmd_toq(q, 'cat', '--rev',   str(self.currev), '--output', hglib.fromutf(result), self.curfile)     def diff_to_local(self, menuitem):   if not self.curfile:   return   opts = {'rev':[str(self.currev)], 'bundle':self.bfile}   self._do_diff([self.curfile], opts)     def diff_file_rev(self, menuitem):   'User selected visual diff file from the file list context menu'   if not self.curfile:   return     rev = self.currev   opts = {'change':str(rev), 'bundle':self.bfile}   parents = self.repo[rev].parents()   if len(parents) == 2:   if self.diff_other_parent():   parent = parents[1].rev()   else:   parent = parents[0].rev()   opts['rev'] = [str(parent), str(rev)]     self._do_diff([self.curfile], opts)     def view_file_rev(self, menuitem):   'User selected view file revision from the file list context menu'   if not self.curfile:   return   rev = self.currev   parents = [x.rev() for x in self.repo[rev].parents()]   if len(parents) == 0:   parent = rev-1   else:   parent = parents[0]   pair = '%u:%u' % (parent, rev)   self._node1, self._node2 = cmdutil.revpair(self.repo, [pair])   self._view_files([self.curfile], False)     def ann_file(self, menuitem):   'User selected annotate file from the file list context menu'   from tortoisehg.hgtk import datamine   rev = self.currev   dialog = datamine.DataMineDialog(self.ui, self.repo, self.cwd, [], {})   dialog.display()   dialog.close_current_page()   dialog.add_annotate_page(self.curfile, str(rev))     def file_history(self, menuitem):   'User selected file history from file list context menu'   if self.glog_parent:   # If this changeset browser is embedded in glog, send   # send this event to the main app   fname = hglib.toutf(self.curfile)   opts = {'pats': [fname]}   self.glog_parent.filtercombo.set_active(1)   self.glog_parent.filterentry.set_text(fname)   self.glog_parent.filterbar.get_button('custom').set_active(True)   self.glog_parent.filter = 'custom'   self.glog_parent.reload_log(**opts)   else:   # Else launch our own glog instance   from tortoisehg.hgtk import history   dlg = history.run(self.ui, filehist=self.curfile)   dlg.display()     def revert_file(self, menuitem):   'User selected file revert from the file list context menu'   rev = self.currev   dialog = gdialog.Confirm(_('Confirm revert file to old revision'),   [], self, _('Revert %s to contents at revision %d?') %   (self.curfile, rev))   if dialog.run() == gtk.RESPONSE_NO:   return   cmdline = ['hg', 'revert', '--verbose', '--rev', str(rev), self.curfile]   dlg = hgcmd.CmdDialog(cmdline)   dlg.run()   dlg.hide()   shlib.shell_notify([self.repo.wjoin(self.curfile)])     def add_to_popup(self, textview, menu):   menu.append(gtk.SeparatorMenuItem())   check = self.textview.get_wrap_mode() == gtk.WRAP_WORD   menu.append(gtklib.create_menuitem(_('Enable _Wordwrap'),   self.wordwrap_activated,   ascheck=True, check=check))   menu.show_all()     def wordwrap_activated(self, menuitem):   mode = self.textview.get_wrap_mode() != gtk.WRAP_WORD \   and gtk.WRAP_WORD or gtk.WRAP_NONE   self.textview.set_wrap_mode(mode)
 
349
350
351
352
 
353
354
355
 
356
357
358
 
349
350
351
 
352
353
354
 
355
356
357
358
@@ -349,10 +349,10 @@
  elif item in ('revnum', 'p4', 'svn'):   return str(value)   elif item in ('rawbranch', 'branch'): - return gtklib.markup(' %s ' % value, color='black', + return gtklib.markup(' %s ' % value, color=gtklib.BLACK,   background=gtklib.PGREEN)   elif item in ('rawtags', 'tags'): - opts = dict(color='black', background=gtklib.PYELLOW) + opts = dict(color=gtklib.BLACK, background=gtklib.PYELLOW)   tags = [gtklib.markup(' %s ' % tag, **opts) for tag in value]   return ' '.join(tags)   elif item in ('desc', 'summary', 'user', 'shortuser',
 
37
38
39
 
 
 
40
41
42
 
44
45
46
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
47
48
49
 
37
38
39
40
41
42
43
44
45
 
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
@@ -37,6 +37,9 @@
 DRED = '#900000'  DGREEN = '#006400'  DBLUE = '#000090' +DYELLOW = '#6A6A00' +DORANGE = '#AA5000' +# DORANGE = '#FF8000'    PRED = '#ffcccc'  PGREEN = '#aaffaa' @@ -44,6 +47,102 @@
 PYELLOW = '#ffffaa'  PORANGE = '#ffddaa'   +RED = 'red' +GREEN = 'green' +BLUE = 'blue' +YELLOW = 'yellow' +BLACK = 'black' +WHITE = 'white' +GREY = 'grey' + +NORMAL = BLACK +NEW_REV_COLOR = DGREEN +CHANGE_HEADER = GREY + +UP_ARROW_COLOR = '#feaf3e' +DOWN_ARROW_COLOR = '#8ae234' +STAR_COLOR = '#fce94f' +CELL_GREY = '#2e3436' +STATUS_HEADER = '#DDDDDD' +STATUS_REJECT_BACKGROUND = '#EEEEEE' +STATUS_REJECT_FOREGROUND = '#888888' + +# line colors +MAINLINE_COLOR = ( 0.0, 0.0, 0.0 ) +LINE_COLORS = [ + ( 1.0, 0.0, 0.0 ), + ( 1.0, 1.0, 0.0 ), + ( 0.0, 1.0, 0.0 ), + ( 0.0, 1.0, 1.0 ), + ( 0.0, 0.0, 1.0 ), + ( 1.0, 0.0, 1.0 ), + ] + +def get_gtk_colors(): + color_scheme = gtk.settings_get_default().get_property('gtk-color-scheme') + colors = {} + for color in color_scheme.split('\n'): + color = color.strip() + if color: + name, color = color.split(':') + colors[name.strip()] = gtk.gdk.color_parse(color.strip()) + return colors + +def _init_colors(): + global NORMAL, MAINLINE_COLOR + + gtk_colors = get_gtk_colors() + + try: + normal = gtk_colors['fg_color'] + except KeyError: + # TODO: find out how to log such errors + pass + else: + NORMAL = str(normal) + MAINLINE_COLOR = ( + normal.red_float, + normal.green_float, + normal.blue_float + ) + + # adjust colors for a dark color scheme: + if normal.value > 0.5: + global RED, GREEN, BLUE, BLACK, WHITE, \ + DRED, DGREEN, DBLUE, DYELLOW, DORANGE, \ + PRED, PGREEN, PBLUE, PYELLOW, PORANGE, \ + NEW_REV_COLOR, LINE_COLORS, CHANGE_HEADER + + RED = PRED + GREEN = NEW_REV_COLOR = PGREEN + BLUE = PBLUE + PRED = DRED + DRED = '#FF6161' +# DRED, PRED = PRED, DRED + DGREEN, PGREEN = PGREEN, DGREEN + DBLUE, PBLUE = PBLUE, DBLUE + DYELLOW, PYELLOW = PYELLOW, DYELLOW + DORANGE, PORANGE = PORANGE, DORANGE + BLACK, WHITE = WHITE, BLACK + + CHANGE_HEADER = '#404040' + + LINE_COLORS = [ + ( 1.0, 0.3804, 0.3804 ), + ( 1.0, 1.0, 0.0 ), + ( 0.0, 1.0, 0.0 ), + ( 0.0, 1.0, 1.0 ), + ( 0.2902, 0.4863, 0.851 ), + ( 1.0, 0.3882, 1.0 ), + ] + + # TODO: dark color scheme for: + # UP_ARROW_COLOR, DOWN_ARROW_COLOR, STAR_COLOR, + # CELL_GREY, STATUS_HEADER, STATUS_REJECT_BACKGROUND, + # STATUS_REJECT_FOREGROUND + +_init_colors() +  def set_tortoise_icon(window, thgicon):   ico = paths.get_tortoise_icon(thgicon)   if ico: window.set_icon_from_file(ico)
 
196
197
198
199
 
200
201
202
 
196
197
198
 
199
200
201
202
@@ -196,7 +196,7 @@
  self.buf = gtk.TextBuffer()   self.buf.create_tag('removed', foreground=gtklib.DRED)   self.buf.create_tag('added', foreground=gtklib.DGREEN) - self.buf.create_tag('position', foreground='#FF8000') + self.buf.create_tag('position', foreground=gtklib.DORANGE)   self.buf.create_tag('header', foreground=gtklib.DBLUE)   diffview = gtk.TextView(self.buf)   scroller.add(diffview)
 
402
403
404
405
 
406
407
408
 
402
403
404
 
405
406
407
408
@@ -402,7 +402,7 @@
  markup = markup % (gtklib.DRED, 'bold')   icons = {'error': True}   else: - markup = markup % ('black', 'normal') + markup = markup % (gtklib.NORMAL, 'normal')   icons = {}   text = gtklib.markup_escape_text(text)   self.rlabel.set_markup(markup % text)
 
19
20
21
 
 
22
23
24
 
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
 
106
107
 
108
109
110
 
187
188
189
190
 
191
192
193
 
196
197
198
199
 
200
201
202
203
204
 
205
206
207
 
216
217
218
219
 
220
221
222
 
19
20
21
22
23
24
25
26
 
89
90
91
 
 
 
 
 
 
 
 
 
92
93
94
95
96
97
 
98
99
 
100
101
102
103
 
180
181
182
 
183
184
185
186
 
189
190
191
 
192
193
194
195
196
 
197
198
199
200
 
209
210
211
 
212
213
214
215
@@ -19,6 +19,8 @@
 import pango  import cairo   +from tortoisehg.hgtk import gtklib +  # Styles used when rendering revision graph edges  style_SOLID = 0  style_DASHED = 1 @@ -87,24 +89,15 @@
  colours and the fg parameter provides the multiplier that should be   applied to the foreground colours.   """ - mainline_color = ( 0.0, 0.0, 0.0 ) - colours = [ - ( 1.0, 0.0, 0.0 ), - ( 1.0, 1.0, 0.0 ), - ( 0.0, 1.0, 0.0 ), - ( 0.0, 1.0, 1.0 ), - ( 0.0, 0.0, 1.0 ), - ( 1.0, 0.0, 1.0 ), - ]     if isinstance(colour, str):   r, g, b = colour[1:3], colour[3:5], colour[5:7]   colour_rgb = int(r, 16) / 255., int(g, 16) / 255., int(b, 16) / 255.   else:   if colour == 0: - colour_rgb = mainline_color + colour_rgb = gtklib.MAINLINE_COLOR   else: - colour_rgb = colours[colour % len(colours)] + colour_rgb = gtklib.LINE_COLORS[colour % len(gtklib.LINE_COLORS)]     red = (colour_rgb[0] * fg) or bg   green = (colour_rgb[1] * fg) or bg @@ -187,7 +180,7 @@
  # Possible node status   if status != 0:   def draw_arrow(x, y, dir): - self.set_colour(ctx, '#2e3436', 0.0, 1.0) + self.set_colour(ctx, gtklib.CELL_GREY, 0.0, 1.0)   ctx.rectangle(x, y, 2, 5)   ax, ay = x, y + (dir == 'down' and 5 or 0)   inc = 3 * (dir == 'up' and -1 or 1) @@ -196,12 +189,12 @@
  ctx.line_to(ax + 1, ay + inc)   ctx.line_to(ax - 2, ay)   ctx.stroke_preserve() - fillcolor = dir == 'up' and '#feaf3e' or '#8ae234' + fillcolor = dir == 'up' and gtklib.UP_ARROW_COLOR or gtklib.DOWN_ARROW_COLOR   self.set_colour(ctx, fillcolor, 0.0, 1.0)   ctx.fill()     def draw_star(x, y, radius, nodes, offset=False): - self.set_colour(ctx, '#2e3436', 0.0, 1.0) + self.set_colour(ctx, gtklib.CELL_GREY, 0.0, 1.0)   total_nodes = nodes * 2 #inner + outer nodes   angle = 2 * math.pi / total_nodes;   offset = offset and angle / 2 or 0 @@ -216,7 +209,7 @@
  else:   ctx.line_to(arc_x, arc_y)   ctx.stroke_preserve() - self.set_colour(ctx, '#fce94f', 0.0, 1.0) + self.set_colour(ctx, gtklib.STAR_COLOR, 0.0, 1.0)   ctx.fill()     arrow_y = arc_start_position_y - box_size / 4
 
179
180
181
182
 
183
184
185
 
217
218
219
220
 
221
222
223
224
225
226
 
227
228
229
 
295
296
297
298
 
299
300
301
 
303
304
305
306
 
307
308
309
 
179
180
181
 
182
183
184
185
 
217
218
219
 
220
221
222
223
224
225
 
226
227
228
229
 
295
296
297
 
298
299
300
301
 
303
304
305
 
306
307
308
309
@@ -179,7 +179,7 @@
  if parent is None:   parent = ctx.parents()[0].node()   M, A, R = self.repo.status(parent, ctx.node())[:3] - common = dict(color='black') + common = dict(color=gtklib.BLACK)   M = M and gtklib.markup(' %s ' % len(M),   background=gtklib.PORANGE, **common) or ''   A = A and gtklib.markup(' %s ' % len(A), @@ -217,13 +217,13 @@
  bg = gtklib.PORANGE   elif tag in self.mqpatches:   bg = gtklib.PBLUE - style = {'color': 'black', 'background': bg} + style = {'color': gtklib.BLACK, 'background': bg}   tstr += gtklib.markup(' %s ' % tag, **style) + ' '     branch = ctx.branch()   bstr = ''   if self.branchtags.get(branch) == node: - bstr += gtklib.markup(' %s ' % branch, color='black', + bstr += gtklib.markup(' %s ' % branch, color=gtklib.BLACK,   background=gtklib.PGREEN) + ' '     if revid in self.wcparents: @@ -295,7 +295,7 @@
  self.color_func = self.text_color_author     def text_color_default(self, rev, author): - return int(rev) >= self.origtip and 'darkgreen' or 'black' + return int(rev) >= self.origtip and gtklib.NEW_REV_COLOR or gtklib.NORMAL     colors = '''black blue deeppink mediumorchid blue burlywood4 goldenrod   slateblue red2 navy dimgrey'''.split() @@ -303,7 +303,7 @@
    def text_color_author(self, rev, author):   if int(rev) >= self.origtip: - return 'darkgreen' + return gtklib.NEW_REV_COLOR   for re, v in self.author_pats:   if (re.search(author)):   return v
 
53
54
55
56
 
57
58
59
 
411
412
413
414
 
415
416
417
 
420
421
422
423
424
 
 
425
426
427
 
869
870
871
872
 
 
873
874
875
 
919
920
921
922
 
923
924
 
925
926
 
927
928
 
929
930
 
931
932
933
 
1095
1096
1097
1098
 
1099
1100
1101
 
53
54
55
 
56
57
58
59
 
411
412
413
 
414
415
416
417
 
420
421
422
 
 
423
424
425
426
427
 
869
870
871
 
872
873
874
875
876
 
920
921
922
 
923
924
 
925
926
 
927
928
 
929
930
 
931
932
933
934
 
1096
1097
1098
 
1099
1100
1101
1102
@@ -53,7 +53,7 @@
  elif line.startswith('+'):   hunk += gtklib.markup(line, color=gtklib.DGREEN)   elif line.startswith('@@'): - hunk = gtklib.markup(line, color='#FF8000') + hunk = gtklib.markup(line, color=gtklib.DORANGE)   else:   hunk += gtklib.markup(line)   return hunk @@ -411,7 +411,7 @@
  diffcol.add_attribute(cell, 'markup', DM_DISP_TEXT)     # differentiate header chunks - cell.set_property('cell-background', '#DDDDDD') + cell.set_property('cell-background', gtklib.STATUS_HEADER)   diffcol.add_attribute(cell, 'cell_background_set', DM_IS_HEADER)   self.headerfont = self.difffont.copy()   self.headerfont.set_weight(pango.WEIGHT_HEAVY) @@ -420,8 +420,8 @@
  self.rejfont = self.difffont.copy()   self.rejfont.set_weight(pango.WEIGHT_LIGHT)   diffcol.add_attribute(cell, 'font-desc', DM_FONT) - cell.set_property('background', '#EEEEEE') - cell.set_property('foreground', '#888888') + cell.set_property('background', gtklib.STATUS_REJECT_BACKGROUND) + cell.set_property('foreground', gtklib.STATUS_REJECT_FOREGROUND)   diffcol.add_attribute(cell, 'background-set', DM_REJECTED)   diffcol.add_attribute(cell, 'foreground-set', DM_REJECTED)   difftree.append_column(diffcol) @@ -869,7 +869,8 @@
  sel = lambda x: x >= lasthunk or not dmodel[hc+x+1][DM_REJECTED]   newtext = chunks[0].selpretty(sel)   if not selected: - newtext = "<span foreground='#888888'>" + newtext + "</span>" + newtext = "<span foreground='" + gtklib.STATUS_REJECT_FOREGROUND + \ + "'>" + newtext + "</span>"   dmodel[hc][DM_DISP_TEXT] = newtext     def updated_codes(self): @@ -919,15 +920,15 @@
  elif stat == 'R':   text_renderer.set_property('foreground', gtklib.DRED)   elif stat == 'C': - text_renderer.set_property('foreground', 'black') + text_renderer.set_property('foreground', gtklib.NORMAL)   elif stat == '!': - text_renderer.set_property('foreground', 'red') + text_renderer.set_property('foreground', gtklib.RED)   elif stat == '?': - text_renderer.set_property('foreground', '#AA5000') + text_renderer.set_property('foreground', gtklib.DORANGE)   elif stat == 'I': - text_renderer.set_property('foreground', 'black') + text_renderer.set_property('foreground', gtklib.NORMAL)   else: - text_renderer.set_property('foreground', 'black') + text_renderer.set_property('foreground', gtklib.NORMAL)       def rename_file(self, wfile): @@ -1095,7 +1096,7 @@
  else:   buf.create_tag('removed', foreground=gtklib.DRED)   buf.create_tag('added', foreground=gtklib.DGREEN) - buf.create_tag('position', foreground='#FF8000') + buf.create_tag('position', foreground=gtklib.DORANGE)   buf.create_tag('header', foreground=gtklib.DBLUE)     bufiter = buf.get_start_iter()
 
721
722
723
724
 
725
726
 
727
728
 
729
730
731
 
721
722
723
 
724
725
 
726
727
 
728
729
730
731
@@ -721,11 +721,11 @@
    stat = row[MQ_STATUS]   if stat == 'A': - cell.set_property('foreground', 'blue') + cell.set_property('foreground', gtklib.BLUE)   elif stat == 'U': - cell.set_property('foreground', '#909090') + cell.set_property('foreground', gtklib.GREY)   else: - cell.set_property('foreground', 'black') + cell.set_property('foreground', gtklib.NORMAL)     patchname = row[MQ_NAME]   if self.is_qtip(patchname):