Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 1.0, 1.0.1, and 1.0.2

Merge with issue 466 changes

Changeset 0c91f8d135c1

Parents 05ec6f2f1798

Parents 9d1ee2a6dda6

by Steve Borho

Changes to 18 files · Browse files at 0c91f8d135c1 Showing diff from parent 05ec6f2f1798 9d1ee2a6dda6 Diff from another changeset...

 
12
13
14
 
 
 
 
 
 
 
 
 
 
15
16
17
 
64
65
66
 
67
68
69
70
 
71
72
73
 
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
 
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
 
74
75
76
77
78
79
80
81
82
83
84
85
 
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
@@ -12,6 +12,16 @@
 Root: HKLM32; Subkey: Software\TortoiseHg; Check: Is64BitInstallMode; Flags: uninsdeletekey  Root: HKLM32; Subkey: Software\TortoiseHg; Check: Is64BitInstallMode; ValueType: string; ValueName: ; ValueData: {app}   +; cmenu handler COM control +Root: HKCR; Subkey: CLSID\{{B456DB9F-7BF4-478c-937A-05130C2C212E}; Flags: uninsdeletekey; Components: shell +Root: HKCR; Subkey: CLSID\{{B456DB9F-7BF4-478c-937A-05130C2C212E}; ValueType: string; ValueName: ; ValueData: TortoiseHg; Components: shell +Root: HKCR; Subkey: CLSID\{{B456DB9F-7BF4-478c-937A-05130C2C212E}\InProcServer32; ValueType: string; ValueName: ; ValueData: {app}\THgShell.dll; Components: shell +Root: HKCR; Subkey: CLSID\{{B456DB9F-7BF4-478c-937A-05130C2C212E}\InProcServer32; ValueType: string; ValueName: ThreadingModel; ValueData: Apartment; Components: shell +Root: HKCR32; Subkey: CLSID\{{B456DB9F-7BF4-478c-937A-05130C2C212E}; Check: Is64BitInstallMode; Flags: uninsdeletekey; Components: shell +Root: HKCR32; Subkey: CLSID\{{B456DB9F-7BF4-478c-937A-05130C2C212E}; Check: Is64BitInstallMode; ValueType: string; ValueName: ; ValueData: TortoiseHg; Components: shell +Root: HKCR32; Subkey: CLSID\{{B456DB9F-7BF4-478c-937A-05130C2C212E}\InProcServer32; Check: Is64BitInstallMode; ValueType: string; ValueName: ; ValueData: {app}\THgShellx86.dll; Components: shell +Root: HKCR32; Subkey: CLSID\{{B456DB9F-7BF4-478c-937A-05130C2C212E}\InProcServer32; Check: Is64BitInstallMode; ValueType: string; ValueName: ThreadingModel; ValueData: Apartment; Components: shell +  ; overlay handler COM controls  ; Normal  Root: HKCR; Subkey: CLSID\{{B456DBA0-7BF4-478c-937A-05130C2C212E}; Flags: uninsdeletekey; Components: shell @@ -64,10 +74,12 @@
 Root: HKLM32; Subkey: Software\TortoiseOverlays\Unversioned; Check: Is64BitInstallMode; ValueType: string; ValueName: TortoiseHg; ValueData: {{B456DBA6-7BF4-478c-937A-05130C2C212E}; Components: shell    ; Make them approved by administrator +Root: HKLM; Subkey: SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Approved; ValueType: string; ValueName: {{B456DB9F-7BF4-478c-937A-05130C2C212E}; ValueData: TortoiseHg; Flags: uninsdeletevalue; Components: shell  Root: HKLM; Subkey: SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Approved; ValueType: string; ValueName: {{B456DBA0-7BF4-478c-937A-05130C2C212E}; ValueData: TortoiseHg; Flags: uninsdeletevalue; Components: shell  Root: HKLM; Subkey: SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Approved; ValueType: string; ValueName: {{B456DBA1-7BF4-478c-937A-05130C2C212E}; ValueData: TortoiseHg; Flags: uninsdeletevalue; Components: shell  Root: HKLM; Subkey: SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Approved; ValueType: string; ValueName: {{B456DBA2-7BF4-478c-937A-05130C2C212E}; ValueData: TortoiseHg; Flags: uninsdeletevalue; Components: shell  Root: HKLM; Subkey: SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Approved; ValueType: string; ValueName: {{B456DBA6-7BF4-478c-937A-05130C2C212E}; ValueData: TortoiseHg; Flags: uninsdeletevalue; Components: shell +Root: HKLM32; Subkey: SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Approved; Check: Is64BitInstallMode; ValueType: string; ValueName: {{B456DB9F-7BF4-478c-937A-05130C2C212E}; ValueData: TortoiseHg; Flags: uninsdeletevalue; Components: shell  Root: HKLM32; Subkey: SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Approved; Check: Is64BitInstallMode; ValueType: string; ValueName: {{B456DBA0-7BF4-478c-937A-05130C2C212E}; ValueData: TortoiseHg; Flags: uninsdeletevalue; Components: shell  Root: HKLM32; Subkey: SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Approved; Check: Is64BitInstallMode; ValueType: string; ValueName: {{B456DBA1-7BF4-478c-937A-05130C2C212E}; ValueData: TortoiseHg; Flags: uninsdeletevalue; Components: shell  Root: HKLM32; Subkey: SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Approved; Check: Is64BitInstallMode; ValueType: string; ValueName: {{B456DBA2-7BF4-478c-937A-05130C2C212E}; ValueData: TortoiseHg; Flags: uninsdeletevalue; Components: shell @@ -75,32 +87,32 @@
   ; Context menu handlers  Root: HKCR; Subkey: Directory\shellex\ContextMenuHandlers\TortoiseHgCMenu; Flags: uninsdeletekey; Components: shell -Root: HKCR; Subkey: Directory\shellex\ContextMenuHandlers\TortoiseHgCMenu; ValueType: string; ValueName: ; ValueData: {{B456DBA0-7BF4-478c-937A-05130C2C212E}; Components: shell +Root: HKCR; Subkey: Directory\shellex\ContextMenuHandlers\TortoiseHgCMenu; ValueType: string; ValueName: ; ValueData: {{B456DB9F-7BF4-478c-937A-05130C2C212E}; Components: shell  Root: HKCR32; Subkey: Directory\shellex\ContextMenuHandlers\TortoiseHgCMenu; Check: Is64BitInstallMode; Flags: uninsdeletekey; Components: shell -Root: HKCR32; Subkey: Directory\shellex\ContextMenuHandlers\TortoiseHgCMenu; Check: Is64BitInstallMode; ValueType: string; ValueName: ; ValueData: {{B456DBA0-7BF4-478c-937A-05130C2C212E}; Components: shell +Root: HKCR32; Subkey: Directory\shellex\ContextMenuHandlers\TortoiseHgCMenu; Check: Is64BitInstallMode; ValueType: string; ValueName: ; ValueData: {{B456DB9F-7BF4-478c-937A-05130C2C212E}; Components: shell    Root: HKCR; Subkey: Directory\Background\shellex\ContextMenuHandlers\TortoiseHgCMenu; Flags: uninsdeletekey; Components: shell -Root: HKCR; Subkey: Directory\Background\shellex\ContextMenuHandlers\TortoiseHgCMenu; ValueType: string; ValueName: ; ValueData: {{B456DBA0-7BF4-478c-937A-05130C2C212E}; Components: shell +Root: HKCR; Subkey: Directory\Background\shellex\ContextMenuHandlers\TortoiseHgCMenu; ValueType: string; ValueName: ; ValueData: {{B456DB9F-7BF4-478c-937A-05130C2C212E}; Components: shell  Root: HKCR32; Subkey: Directory\Background\shellex\ContextMenuHandlers\TortoiseHgCMenu; Check: Is64BitInstallMode; Flags: uninsdeletekey; Components: shell -Root: HKCR32; Subkey: Directory\Background\shellex\ContextMenuHandlers\TortoiseHgCMenu; Check: Is64BitInstallMode; ValueType: string; ValueName: ; ValueData: {{B456DBA0-7BF4-478c-937A-05130C2C212E}; Components: shell +Root: HKCR32; Subkey: Directory\Background\shellex\ContextMenuHandlers\TortoiseHgCMenu; Check: Is64BitInstallMode; ValueType: string; ValueName: ; ValueData: {{B456DB9F-7BF4-478c-937A-05130C2C212E}; Components: shell    Root: HKCR; Subkey: Drive\shellex\ContextMenuHandlers\TortoiseHgCMenu; Flags: uninsdeletekey; Components: shell -Root: HKCR; Subkey: Drive\shellex\ContextMenuHandlers\TortoiseHgCMenu; ValueType: string; ValueName: ; ValueData: {{B456DBA0-7BF4-478c-937A-05130C2C212E}; Components: shell +Root: HKCR; Subkey: Drive\shellex\ContextMenuHandlers\TortoiseHgCMenu; ValueType: string; ValueName: ; ValueData: {{B456DB9F-7BF4-478c-937A-05130C2C212E}; Components: shell  Root: HKCR32; Subkey: Drive\shellex\ContextMenuHandlers\TortoiseHgCMenu; Check: Is64BitInstallMode; Flags: uninsdeletekey; Components: shell -Root: HKCR32; Subkey: Drive\shellex\ContextMenuHandlers\TortoiseHgCMenu; Check: Is64BitInstallMode; ValueType: string; ValueName: ; ValueData: {{B456DBA0-7BF4-478c-937A-05130C2C212E}; Components: shell +Root: HKCR32; Subkey: Drive\shellex\ContextMenuHandlers\TortoiseHgCMenu; Check: Is64BitInstallMode; ValueType: string; ValueName: ; ValueData: {{B456DB9F-7BF4-478c-937A-05130C2C212E}; Components: shell    Root: HKCR; Subkey: Folder\shellex\ContextMenuHandlers\TortoiseHgCMenu; Flags: uninsdeletekey; Components: shell -Root: HKCR; Subkey: Folder\shellex\ContextMenuHandlers\TortoiseHgCMenu; ValueType: string; ValueName: ; ValueData: {{B456DBA0-7BF4-478c-937A-05130C2C212E}; Components: shell +Root: HKCR; Subkey: Folder\shellex\ContextMenuHandlers\TortoiseHgCMenu; ValueType: string; ValueName: ; ValueData: {{B456DB9F-7BF4-478c-937A-05130C2C212E}; Components: shell  Root: HKCR32; Subkey: Folder\shellex\ContextMenuHandlers\TortoiseHgCMenu; Check: Is64BitInstallMode; Flags: uninsdeletekey; Components: shell -Root: HKCR32; Subkey: Folder\shellex\ContextMenuHandlers\TortoiseHgCMenu; Check: Is64BitInstallMode; ValueType: string; ValueName: ; ValueData: {{B456DBA0-7BF4-478c-937A-05130C2C212E}; Components: shell +Root: HKCR32; Subkey: Folder\shellex\ContextMenuHandlers\TortoiseHgCMenu; Check: Is64BitInstallMode; ValueType: string; ValueName: ; ValueData: {{B456DB9F-7BF4-478c-937A-05130C2C212E}; Components: shell    Root: HKCR; Subkey: *\shellex\ContextMenuHandlers\TortoiseHgCMenu; Flags: uninsdeletekey; Components: shell -Root: HKCR; Subkey: *\shellex\ContextMenuHandlers\TortoiseHgCMenu; ValueType: string; ValueName: ; ValueData: {{B456DBA0-7BF4-478c-937A-05130C2C212E}; Components: shell +Root: HKCR; Subkey: *\shellex\ContextMenuHandlers\TortoiseHgCMenu; ValueType: string; ValueName: ; ValueData: {{B456DB9F-7BF4-478c-937A-05130C2C212E}; Components: shell  Root: HKCR32; Subkey: *\shellex\ContextMenuHandlers\TortoiseHgCMenu; Check: Is64BitInstallMode; Flags: uninsdeletekey; Components: shell -Root: HKCR32; Subkey: *\shellex\ContextMenuHandlers\TortoiseHgCMenu; Check: Is64BitInstallMode; ValueType: string; ValueName: ; ValueData: {{B456DBA0-7BF4-478c-937A-05130C2C212E}; Components: shell +Root: HKCR32; Subkey: *\shellex\ContextMenuHandlers\TortoiseHgCMenu; Check: Is64BitInstallMode; ValueType: string; ValueName: ; ValueData: {{B456DB9F-7BF4-478c-937A-05130C2C212E}; Components: shell    Root: HKCR; Subkey: InternetShortcut\shellex\ContextMenuHandlers\TortoiseHgCMenu; Flags: uninsdeletekey; Components: shell -Root: HKCR; Subkey: InternetShortcut\shellex\ContextMenuHandlers\TortoiseHgCMenu; ValueType: string; ValueName: ; ValueData: {{B456DBA0-7BF4-478c-937A-05130C2C212E}; Components: shell +Root: HKCR; Subkey: InternetShortcut\shellex\ContextMenuHandlers\TortoiseHgCMenu; ValueType: string; ValueName: ; ValueData: {{B456DB9F-7BF4-478c-937A-05130C2C212E}; Components: shell  Root: HKCR32; Subkey: InternetShortcut\shellex\ContextMenuHandlers\TortoiseHgCMenu; Check: Is64BitInstallMode; Flags: uninsdeletekey; Components: shell -Root: HKCR32; Subkey: InternetShortcut\shellex\ContextMenuHandlers\TortoiseHgCMenu; Check: Is64BitInstallMode; ValueType: string; ValueName: ; ValueData: {{B456DBA0-7BF4-478c-937A-05130C2C212E}; Components: shell +Root: HKCR32; Subkey: InternetShortcut\shellex\ContextMenuHandlers\TortoiseHgCMenu; Check: Is64BitInstallMode; ValueType: string; ValueName: ; ValueData: {{B456DB9F-7BF4-478c-937A-05130C2C212E}; Components: shell  
 
303
304
305
306
 
307
308
309
 
400
401
402
403
404
 
 
 
 
405
406
407
 
420
421
422
 
423
424
425
 
938
939
940
941
 
942
943
944
 
303
304
305
 
306
307
308
309
 
400
401
402
 
 
403
404
405
406
407
408
409
 
422
423
424
425
426
427
428
 
941
942
943
 
944
945
946
947
@@ -303,7 +303,7 @@
  self.update_recent_committers()   committer = os.environ.get('HGUSER') or self.repo.ui.config('ui', 'username')   if committer: - self.update_recent_committers(committer) + self.update_recent_committers(hglib.toutf(committer))   self.committer_cbbox.set_active(0)     adv_hbox.pack_start(gtk.Label(_('Auto-includes:')), False, False, 2) @@ -400,8 +400,10 @@
  return label   self.parent1_label = add_parent()   self.parent2_label = add_parent() - parents_vbox.pack_start(gtk.HSeparator()) - vbox2.pack_start(parents_vbox, False, False) + parents_hbox = gtk.HBox() + parents_hbox.pack_start(parents_vbox, False, False, 5) + vbox2.pack_start(parents_hbox, False, False, 2) + vbox2.pack_start(gtk.HSeparator(), False, False)     self.vpaned = gtk.VPaned()   self.vpaned.pack1(vbox, shrink=False) @@ -420,6 +422,7 @@
      def update_recent_committers(self, name=None): + """ 'name' argument must be in UTF-8. """   if name is not None:   self._mru_committers.add(name)   self._mru_committers.compact() @@ -938,7 +941,7 @@
  self.refresh_complete()   return   - self.update_recent_committers(user) + self.update_recent_committers(hglib.toutf(user))   incs = hglib.fromutf(self.autoinc_entry.get_text())   self.opts['include'] = [i.strip() for i in incs.split(',') if i.strip()]   autopush = self.autopush.get_active()
 
32
33
34
 
35
36
37
 
32
33
34
35
36
37
38
@@ -32,6 +32,7 @@
  dialog = gtk.Dialog(parent=parent, flags=gtk.DIALOG_MODAL,   buttons=buttons)   dialog.set_title(_('TortoiseHg Prompt')) + dialog.set_has_separator(False)   entry = gtk.Entry()   entry.set_text(default or '')   entry.set_visibility(visible)
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
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
 # hgcmd.py - A simple dialog to execute random command for TortoiseHg  #  # Copyright 2007 TK Soh <teekaysoh@gmail.com>  # Copyright 2007 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 gtk  import gobject  import pango  import os  import sys  import threading  import Queue    from tortoisehg.util.i18n import _  from tortoisehg.util import shlib, hglib    from tortoisehg.hgtk import gtklib, hgthread    class CmdDialog(gtk.Dialog):   def __init__(self, cmdline, progressbar=True, text=None):   if type(cmdline) is tuple:   self.cmdlist = list(cmdline)[1:]   cmdline = cmdline[0]   else:   self.cmdlist = []   title = text or ' '.join(cmdline)   if len(title) > 80:   title = hglib.tounicode(title)[:80] + '...'   title = hglib.toutf(title.replace('\n', ' '))   gtk.Dialog.__init__(self, title=title, flags=gtk.DIALOG_MODAL)   self.set_has_separator(False)     gtklib.set_tortoise_icon(self, 'hg.ico')   gtklib.set_tortoise_keys(self)   self.cmdline = cmdline   self.returncode = None   self.hgthread = None     self.set_default_size(520, 400)     self._button_stop = gtk.Button(_('Stop'))   self._button_stop.connect('clicked', self._on_stop_clicked)   self.action_area.pack_start(self._button_stop)     self._button_ok = gtk.Button(_('Close'))   self._button_ok.connect('clicked', self._on_ok_clicked)   self.action_area.pack_start(self._button_ok)     self.connect('thg-accept', self._on_ok_clicked)     self.connect('delete-event', self._delete)   self.connect('response', self._response)     self.pbar = None   if progressbar:   self.last_pbar_update = 0     hbox = gtk.HBox()     self.status_text = gtk.Label()   self.status_text.set_text(title)   self.status_text.set_alignment(0, 0.5)   self.status_text.set_ellipsize(pango.ELLIPSIZE_END)   hbox.pack_start(self.status_text, True, True, 3)     # Create a centering alignment object   align = gtk.Alignment(0.0, 0.0, 1, 0)   hbox.pack_end(align, False, False, 3)   align.show()     # create the progress bar   self.pbar = gtk.ProgressBar()   align.add(self.pbar)   self.pbar.pulse()   self.pbar.show()     self.vbox.pack_start(hbox, False, False, 3)     scrolledwindow = gtk.ScrolledWindow()   scrolledwindow.set_shadow_type(gtk.SHADOW_ETCHED_IN)   scrolledwindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)   self.textview = gtk.TextView(buffer=None)   self.textview.set_editable(False)   self.textview.modify_font(pango.FontDescription('Monospace'))   scrolledwindow.add(self.textview)   self.textbuffer = self.textview.get_buffer()   self.textbuffer.create_tag('error', weight=pango.WEIGHT_HEAVY,   foreground='#900000')     self.vbox.pack_start(scrolledwindow, True, True)   self.connect('map_event', self._on_window_map_event)     self.show_all()     def _on_ok_clicked(self, button):   """ Ok button clicked handler. """   self.response(gtk.RESPONSE_ACCEPT)     def _on_stop_clicked(self, button):   if self.hgthread:   self.hgthread.terminate()     def _delete(self, widget, event):   return True     def _response(self, widget, response_id):   if self.hgthread and self.hgthread.isAlive():   widget.emit_stop_by_name('response')     def _on_window_map_event(self, event, param):   if self.hgthread:   return     # Replace stdout file descriptor with our own pipe   def pollstdout(*args):   while True:   # blocking read of stdout pipe   o = os.read(self.readfd, 1024)   if o:   self.stdoutq.put(o)   else:   break   self.oldstdout = os.dup(sys.__stdout__.fileno())   self.stdoutq = Queue.Queue()   self.readfd, writefd = os.pipe()   os.dup2(writefd, sys.__stdout__.fileno())   thread = threading.Thread(target=pollstdout, args=[])   thread.start()     self.hgthread = hgthread.HgThread(self.cmdline[1:])   self.hgthread.start()   self._button_ok.set_sensitive(False)   self._button_stop.set_sensitive(True)   gobject.timeout_add(10, self.process_queue)     def write(self, msg, append=True):   msg = hglib.toutf(msg)   if append:   enditer = self.textbuffer.get_end_iter()   self.textbuffer.insert(enditer, msg)   else:   self.textbuffer.set_text(msg)     def process_queue(self):   """   Handle all the messages currently in the queue (if any).   """   self.hgthread.process_dialogs()   enditer = self.textbuffer.get_end_iter()   while self.hgthread.getqueue().qsize():   try:   msg = self.hgthread.getqueue().get(0)   self.textbuffer.insert(enditer, hglib.toutf(msg))   self.textview.scroll_to_mark(self.textbuffer.get_insert(), 0)   except Queue.Empty:   pass   while self.hgthread.geterrqueue().qsize():   try:   msg = hglib.toutf(self.hgthread.geterrqueue().get(0))   self.textbuffer.insert_with_tags_by_name(enditer, msg, 'error')   self.textview.scroll_to_mark(self.textbuffer.get_insert(), 0)   except Queue.Empty:   pass   while self.stdoutq.qsize():   try:   msg = hglib.toutf(self.stdoutq.get(0))   self.textbuffer.insert_with_tags_by_name(enditer, msg, 'error')   self.textview.scroll_to_mark(self.textbuffer.get_insert(), 0)   except Queue.Empty:   pass     self.update_progress()   if not self.hgthread.isAlive():   self.returncode = self.hgthread.return_code()   if self.returncode is None:   self.write(_('\n[command interrupted]'))   elif self.returncode == 0 and self.cmdlist:   cmdline = self.cmdlist.pop(0)   text = '\n' + hglib.toutf(' '.join(cmdline)) + '\n'   self.textbuffer.insert(enditer, text)   self.textview.scroll_to_mark(self.textbuffer.get_insert(), 0)   self.hgthread = hgthread.HgThread(cmdline[1:])   self.hgthread.start()   return True   self._button_stop.set_sensitive(False)   self._button_ok.set_sensitive(True)   self._button_ok.grab_focus()   os.dup2(self.oldstdout, sys.__stdout__.fileno())   os.close(self.oldstdout)   return False # Stop polling this function   else:   return True     def update_progress(self):   if not self.pbar:   return # progress bar not enabled     if not self.hgthread.isAlive():   self.pbar.unmap()   else:   # pulse the progress bar every ~100ms   tm = shlib.get_system_times()[4]   if tm - self.last_pbar_update < 0.100:   return   self.last_pbar_update = tm   self.pbar.pulse()     def return_code(self):   if self.hgthread:   return self.hgthread.return_code()   else:   return False    # CmdWidget style constants  STYLE_NORMAL = 'normal' # pbar + embedded log viewer  STYLE_COMPACT = 'compact' # pbar + popup log viewer    class CmdWidget(gtk.VBox):     def __init__(self, style=STYLE_NORMAL, tooltips=None, logsize=None):   """   style: String. Predefined constans of CmdWidget style. Two styles;   STYLE_NORMAL (progress bar + popup log viewer) and   STYLE_COMPACT (progress bar + embedded log viewer) are   availabled. Default: STYLE_NORMAL.   tooltips: Reference. gtk.Tooltips instance to show tooltips of several   buttons. If you omit, it will create a new instance of   gtk.Tooltips. Default: None.   logsize: Tuple or list contains 2 numbers. Specify the size of   embedded log viewer. size[0] = width, size[1] = height.   If you pass -1 as width or height size, it will be change to   *natual* size of the widget. Default: tuple(-1, 180).   """   gtk.VBox.__init__(self)     self.hgthread = None   self.last_pbar_update = 0   self.useraborted = False   self.is_normal = style == STYLE_NORMAL   self.is_compact = style == STYLE_COMPACT     # tooltips   if tooltips is None:   tooltips = gtk.Tooltips()     # log viewer   if self.is_normal:   self.log = CmdLogWidget()   if logsize is None:   logsize = (-1, 180)   self.log.set_size_request(logsize[0], logsize[1])   self.log.size_request()   self.pack_start(self.log)   elif self.is_compact:   self.dlg = CmdLogDialog()   def close_hook(dialog):   self.show_log(False)   return False   self.dlg.set_close_hook(close_hook)   self.log = self.dlg.get_logwidget()   else:   raise _('unknown CmdWidget style: %s') % style     # progress bar box   self.progbox = progbox = gtklib.SlimToolbar(tooltips)   self.pack_start(progbox)     def add_button(stock_id, tooltip, handler, toggle=False):   btn = progbox.append_stock(stock_id, tooltip, toggle)   btn.connect('clicked', handler)   return btn     ## log toggle button   self.log_btn = add_button(gtk.STOCK_JUSTIFY_LEFT,   _('Toggle log window'), self.log_toggled, toggle=True)     ## result frame   self.rframe = gtk.Frame()   progbox.append_widget(self.rframe, expand=True)   self.rframe.set_shadow_type(gtk.SHADOW_IN)   rhbox = gtk.HBox()   self.rframe.add(rhbox)     ### result label   self.rlabel = gtk.Label()   rhbox.pack_end(self.rlabel, True, True, 2)   self.rlabel.set_alignment(0, 0.5)     def after_init():   # result icons   self.icons = {}   def add_icon(name, stock):   img = gtk.Image()   rhbox.pack_start(img, False, False, 2)   img.set_from_stock(stock, gtk.ICON_SIZE_SMALL_TOOLBAR)   self.icons[name] = img   add_icon('succeed', gtk.STOCK_APPLY)   add_icon('error', gtk.STOCK_DIALOG_ERROR)     # progress bar   self.pbar = gtk.ProgressBar()   progbox.append_widget(self.pbar, expand=True)   self.pbar.hide()     # stop & close buttons   if self.is_compact:   self.stop_btn = add_button(gtk.STOCK_STOP,   _('Stop transaction'), self.stop_clicked)   self.close_btn = add_button(gtk.STOCK_CLOSE,   _('Close this'), self.close_clicked)     self.set_buttons(stop=False)   if self.is_normal:   self.show_log(False)   if self.is_compact:   self.set_pbar(False)   gtklib.idle_add_single_call(after_init)     ### public functions ###     def execute(self, cmdline, callback, *args, **kargs):   """   Execute passed command line using 'hgthread'.   When the command terminated, callback function is called   with return code.     cmdline: command line string.   callback: function called after terminated the thread.     def callback(returncode, useraborted, ...)     returncode: See the description of 'hgthread'.   useraborted: Indicates whether the thread is aborted by user.   """   if self.hgthread:   return     # clear previous logs   self.log.clear()     # prepare UI   self.switch_to(working=True)   self.set_buttons(stop=True, close=False)   self.already_opened = self.get_pbar()   if not self.already_opened:   def is_done():   # show progress bar if it's still working   if self.hgthread and self.hgthread.isAlive():   self.set_pbar(True)   return False   gobject.timeout_add(500, is_done)     # thread start   self.hgthread = hgthread.HgThread(cmdline[1:])   self.hgthread.start()   gobject.timeout_add(10, self.process_queue, callback, args, kargs)     def is_alive(self):   """   Return whether the thread is alive.   """   return self.hgthread and self.hgthread.isAlive()     def stop(self):   """   Terminate the thread forcibly.   """   if self.hgthread:   self.useraborted = True   self.hgthread.terminate()   self.set_pbar(True)   self.set_buttons(stop=False, close=True)     def set_result(self, text, style=None):   """   Put text message and icon to the progress bar.     style: String. If passed 'succeed', 'green' or 'ok', green   text and succeed icon will be shown. If passed 'error',   'failed', 'fail' or 'red' are passed, red text and error   icon will be shown.   """   markup = '<span foreground="%s" weight="%s">%%s</span>'   if style in ('succeed', 'green', 'ok'):   markup = markup % ('#007700', 'bold')   icons = {'succeed': True}   elif style in ('error', 'failed', 'fail', 'red'):   markup = markup % ('#880000', 'bold')   icons = {'error': True}   else:   markup = markup % ('#000000', 'normal')   icons = {}   text = gtklib.markup_escape_text(text)   self.rlabel.set_markup(markup % text)   self.set_icons(**icons)     def set_pbar(self, visible):   """   Set visible property of the progress bar box.     visible: if True, the progress bar box is shown.   """   if hasattr(self, 'progbox'):   self.progbox.set_property('visible', visible)     def get_pbar(self):   """   Return 'visible' property of the progress bar box.   If not exists progress bar, it always returns False.   """   if hasattr(self, 'progbox'):   return self.progbox.get_property('visible')   return False     def set_buttons(self, log=None, stop=None, close=None):   """   Set visible properties of buttons on the progress bar box.   If omitted all argments, it does nothing.     log: if True, log button is shown. (default: None)   stop: if True, stop button is shown. (default: None)   close: if True, close button is shown. (default: None)   """   if not log is None and hasattr(self, 'log_btn'):   self.log_btn.set_property('visible', log)   if not stop is None and hasattr(self, 'stop_btn'):   self.stop_btn.set_property('visible', stop)   if not close is None and hasattr(self, 'close_btn'):   self.close_btn.set_property('visible', close)     def show_log(self, visible=True):   """   Show/hide log viewer.   """   if self.is_normal:   self.log.set_property('visible', visible)   elif self.is_compact:   if visible:   if self.dlg.get_property('visible'):   self.dlg.present()   else:   self.dlg.show_all()   else:   self.dlg.hide()   else:   raise _('invalid state')     # change toggle button state   if self.log_btn.get_active() != visible:   self.log_btn.handler_block_by_func(self.log_toggled)   self.log_btn.set_active(visible)   self.log_btn.handler_unblock_by_func(self.log_toggled)     def is_show_log(self):   """   Return visible state of log viewer.   """   if self.is_normal:   return self.log.get_property('visible')   elif self.is_compact:   return self.dlg.get_property('visible')   else:   raise _('invalid state')     ### internal use functions ###     def update_progress(self):   if not self.pbar:   return   if not self.hgthread.isAlive():   self.pbar.set_fraction(0)   else:   # pulse the progress bar every ~100ms   tm = shlib.get_system_times()[4]   if tm - self.last_pbar_update < 0.100:   return   self.last_pbar_update = tm   self.pbar.pulse()     def process_queue(self, callback, args, kargs):   # process queue   self.hgthread.process_dialogs()     # output to buffer   while self.hgthread.getqueue().qsize():   try:   msg = self.hgthread.getqueue().get(0)   self.log.append(hglib.toutf(msg))   except Queue.Empty:   pass   while self.hgthread.geterrqueue().qsize():   try:   msg = self.hgthread.geterrqueue().get(0)   self.log.append(hglib.toutf(msg), error=True)   except Queue.Empty:   pass     # update progress bar   self.update_progress()     # check thread   if not self.hgthread.isAlive():   returncode = self.hgthread.return_code()   if returncode == 0 and not self.already_opened:   self.set_pbar(False)   else:   self.set_pbar(True)   self.switch_to(ready=True)   self.set_buttons(stop=False, close=True)   if returncode is None:   self.log.append(_('\n[command interrupted]'))   if not returncode == 0:   self.show_log()   self.hgthread = None   def call_callback():   callback(returncode, self.useraborted, *args, **kargs)   self.useraborted = False   gtklib.idle_add_single_call(call_callback)   return False # Stop polling this function   else:   return True # Continue polling     def set_icons(self, **kargs):   for name, img in self.icons.items():   visible = kargs.get(name, False)   img.set_property('visible', visible)     def switch_to(self, ready=False, working=False):   if ready:   self.rframe.show()   self.pbar.hide()   elif working:   self.rframe.hide()   self.pbar.show()     ### signal handlers ###     def log_toggled(self, button):   self.show_log(button.get_active())     def stop_clicked(self, button):   self.stop()     def close_clicked(self, button):   self.set_pbar(False)    class CmdLogWidget(gtk.VBox):     def __init__(self):   gtk.VBox.__init__(self)     # scrolled pane   pane = gtk.ScrolledWindow()   pane.set_shadow_type(gtk.SHADOW_ETCHED_IN)   pane.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)   self.add(pane)     # log textview   self.textview = gtk.TextView(buffer=None)   self.textview.set_editable(False)   self.textview.modify_font(pango.FontDescription('Monospace'))   pane.add(self.textview)     # text buffer   self.buffer = self.textview.get_buffer()   self.buffer.create_tag('error', weight=pango.WEIGHT_HEAVY,   foreground='#900000')     ### public functions ###     def append(self, text, error=False):   """   Insert the text to the end of TextView.     text: string you want to append.   error: if True, append text with 'error' tag. (default: False)   """   enditer = self.buffer.get_end_iter()   if error:   self.buffer.insert_with_tags_by_name(enditer, text, 'error')   else:   self.buffer.insert(enditer, text)   self.textview.scroll_to_mark(self.buffer.get_insert(), 0)     def clear(self):   """   Clear all text in TextView.   """   self.buffer.delete(self.buffer.get_start_iter(),   self.buffer.get_end_iter())    class CmdLogDialog(gtk.Window):     def __init__(self, title=_('Command Log')):   gtk.Window.__init__(self, type=gtk.WINDOW_TOPLEVEL)   gtklib.set_tortoise_icon(self, 'hg.ico')   self.set_title(title)   self.set_default_size(320, 240)   self.connect('delete-event', self.delete_event)   + # accelerators + accelgroup = gtk.AccelGroup() + self.add_accel_group(accelgroup) + mod = gtklib.get_thg_modifier() + for key, modifier in (gtk.accelerator_parse(mod+'w'), + gtk.accelerator_parse(mod+'q'), + gtk.accelerator_parse('Escape')): + self.add_accelerator('thg-close', accelgroup, key, + modifier, gtk.ACCEL_VISIBLE) + self.connect('thg-close', self.delete_event) +   # log viewer   self.log = CmdLogWidget()   self.add(self.log)     # change window decorations   self.realize()   if self.window:   self.window.set_decorations(gtk.gdk.DECOR_BORDER | \   gtk.gdk.DECOR_RESIZEH | \   gtk.gdk.DECOR_TITLE | \   gtk.gdk.DECOR_MENU | \   gtk.gdk.DECOR_MINIMIZE)     ### public functions ###     def get_logwidget(self):   """   Return CmdLogWidget instance.   """   return self.log     def set_close_hook(self, hook):   """   Set hook function.     hook: the function called on closing this dialog.     def close_hook(dialog)     where 'dialog' is the instance of CmdLogDialog class.   The hook function should return True or False.   By returning True, you can prevent closing/hiding the dialog.   """   self.close_hook = hook     ### signal handlers ###   - def delete_event(self, widget, event): + def delete_event(self, *args):   if hasattr(self, 'close_hook'):   if self.close_hook(self):   self.hide()   return True
 
19
20
21
22
 
23
24
25
26
 
27
28
29
30
31
 
32
33
34
 
70
71
72
 
 
 
 
 
 
 
 
 
 
 
 
73
74
 
75
76
77
 
84
85
86
87
 
88
89
90
 
129
130
131
132
 
133
134
135
 
19
20
21
 
22
23
24
25
26
27
28
29
 
 
 
30
31
32
33
 
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
 
85
86
87
88
 
95
96
97
 
98
99
100
101
 
140
141
142
 
143
144
145
146
@@ -19,16 +19,15 @@
  """ Dialog to initialize a Mercurial repo """   def __init__(self, repos=[]):   """ Initialize the Dialog """ - gtk.Dialog.__init__(self, title=_('Create a new repository')) + gtk.Dialog.__init__(self, title=_('TortoiseHg Init'))   gtklib.set_tortoise_icon(self, 'menucreaterepos.ico')   gtklib.set_tortoise_keys(self)   self.set_resizable(False)   self.set_has_separator(False) + self.connect('response', self.dialog_response)     # add buttons - createbutton = gtk.Button(_('Create')) - createbutton.connect('clicked', lambda b: self.init()) - self.action_area.pack_end(createbutton) + self.add_button(_('Create'), gtk.RESPONSE_OK)   self.add_button(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE)     self.cwd = os.getcwd() @@ -70,8 +69,20 @@
  except:   pass   + def dialog_response(self, dialog, response_id): + # Create button + if response_id == gtk.RESPONSE_OK: + self.init() + # Cancel button or dialog closing by the user + elif response_id in (gtk.RESPONSE_CLOSE, gtk.RESPONSE_DELETE_EVENT): + return # close dialog + else: + raise _('unexpected response id: %s') % response_id + + self.run() # don't close dialog +   def dest_clicked(self, button): - """ select destination folder to clone """ + """ select destination folder to init """   response = gtklib.NativeFolderSelectDialog(   initial=self.cwd,   title=_('Select Destination Folder')).run() @@ -84,7 +95,7 @@
  dest = hglib.fromutf(self.destentry.get_text())     # verify input - if dest == "": + if dest == '':   dialog.error_dialog(self, _('Destination path is empty'),   _('Please enter the directory path'))   self.destentry.grab_focus() @@ -129,7 +140,7 @@
  dialog.info_dialog(self, _('New repository created'),   _('in directory %s') % hglib.toutf(os.path.abspath(dest)))   - self.response(gtk.RESPONSE_OK) + self.response(gtk.RESPONSE_CLOSE)    def run(ui, *pats, **opts):   return InitDialog(pats)
 
778
779
780
781
 
782
783
784
 
778
779
780
 
781
782
783
784
@@ -778,7 +778,7 @@
    def mq_context_menu(self):   m = gtklib.MenuItems() - cmenu_qimport = create_menu(_('qimport'), self.qimport_rev) + cmenu_qimport = create_menu(_('QImport Revision'), self.qimport_rev)   cmenu_strip = create_menu(_('Strip Revision...'), self.strip_rev)     try:
 
88
89
90
91
92
93
94
95
96
 
97
98
99
 
88
89
90
 
 
 
91
92
 
93
94
95
96
@@ -88,12 +88,9 @@
    # revision input   revbox = gtk.HBox() - lbl = gtk.Label(_('HTTP Port:')) - lbl.set_property('width-chars', 16) - lbl.set_alignment(0, 0.5)   self._port_input = gtk.Entry()   self._port_input.set_text(self.defport) - revbox.pack_start(lbl, False, False) + revbox.pack_start(gtk.Label(_('HTTP Port:')), False, False, 4)   revbox.pack_start(self._port_input, False, False)   vbox.pack_start(revbox, False, False, 2)  
 
19
20
21
 
 
 
22
23
24
25
26
27
 
28
29
30
 
33
34
35
36
37
38
39
40
41
42
43
44
 
 
 
 
45
46
47
 
54
55
56
57
 
 
58
59
60
 
138
139
140
141
142
143
 
 
 
 
 
 
 
 
 
144
 
 
 
145
146
147
 
148
149
150
 
183
184
185
186
 
187
188
189
 
203
204
205
206
 
207
208
209
 
233
234
235
236
 
237
238
239
 
19
20
21
22
23
24
25
26
27
28
 
 
29
30
31
32
 
35
36
37
 
 
 
 
 
 
 
 
 
38
39
40
41
42
43
44
 
51
52
53
 
54
55
56
57
58
 
136
137
138
 
 
 
139
140
141
142
143
144
145
146
147
148
149
150
151
152
 
 
153
154
155
156
 
189
190
191
 
192
193
194
195
 
209
210
211
 
212
213
214
215
 
239
240
241
 
242
243
244
245
@@ -19,12 +19,14 @@
   keep = i18n.keepgettext()   +RESPONSE_ADD = 1 +RESPONSE_REMOVE = 2 +  class TagAddDialog(gtk.Dialog):   """ Dialog to add tag to Mercurial repo """   def __init__(self, repo, tag='', rev=''):   """ Initialize the Dialog """ - gtk.Dialog.__init__(self, - buttons=(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE)) + gtk.Dialog.__init__(self)   gtklib.set_tortoise_keys(self)   self.set_title(_('Tag - %s') % hglib.get_reponame(repo))   self.set_resizable(False) @@ -33,15 +35,10 @@
    self.repo = repo   - # add Add button - addbutton = gtk.Button(_('Add')) - addbutton.connect('clicked', lambda b: self._do_add_tag()) - self.action_area.pack_end(addbutton) - - # add Remove button - removebutton = gtk.Button(_('Remove')) - removebutton.connect('clicked', lambda b: self._do_rm_tag()) - self.action_area.pack_end(removebutton) + # add buttons + self.add_button(_('Add'), RESPONSE_ADD) + self.add_button(_('Remove'), RESPONSE_REMOVE) + self.add_button(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE)     # persistent settings   self.settings = settings.Settings('tagadd') @@ -54,7 +51,8 @@
  self._tagslist = gtk.ListStore(str)   self._taglistbox = gtk.ComboBoxEntry(self._tagslist, 0)   self._tag_input = self._taglistbox.get_child() - self._tag_input.connect('activate', self._taginput_activated) + self._tag_input.connect('activate', + lambda *a: self.response(RESPONSE_ADD))   self._tag_input.set_text(tag)   table.add_row(_('Tag:'), self._taglistbox, padding=False)   @@ -138,13 +136,21 @@
  self._commit_message.grab_focus()     def dialog_response(self, dialog, response_id): - self.store_settings() - if response_id == gtk.RESPONSE_CLOSE \ - or response_id == gtk.RESPONSE_DELETE_EVENT: + # Add button + if response_id == RESPONSE_ADD: + self._do_add_tag() + # Remove button + elif response_id == RESPONSE_REMOVE: + self._do_remove_tag() + # Close button or closed by the user + elif response_id in (gtk.RESPONSE_CLOSE, gtk.RESPONSE_DELETE_EVENT): + self.store_settings()   self.destroy() + return # close dialog + else: + raise _('unexpected response id: %s') % response_id   - def _taginput_activated(self, taginput): - self._do_add_tag() + self.run() # don't close dialog     def _do_add_tag(self):   # gather input data @@ -183,7 +189,7 @@
  traceback.format_exc())   return False   - def _do_rm_tag(self): + def _do_remove_tag(self):   # gather input data   is_local = self._local_tag.get_active()   name = self._tag_input.get_text() @@ -203,7 +209,7 @@
  message = ''     try: - self._rm_hg_tag(name, message, is_local, english=eng_msg) + self._remove_hg_tag(name, message, is_local, english=eng_msg)   dialog.info_dialog(self, _('Tagging completed'),   _('Tag "%s" has been removed') % name)   self._refresh() @@ -233,7 +239,7 @@
    self.repo.tag(name, r, hglib.fromutf(message), local, user, date)   - def _rm_hg_tag(self, name, message, local, user=None, date=None, + def _remove_hg_tag(self, name, message, local, user=None, date=None,   english=False):   if not name in self.repo.tags():   raise util.Abort(_("Tag '%s' does not exist") % name)
 
29
30
31
 
 
32
33
34
35
 
36
37
38
 
170
171
172
 
 
 
173
174
175
 
176
177
178
 
179
180
181
 
185
186
187
 
188
189
 
 
 
 
 
 
 
 
 
 
 
 
190
191
192
193
194
195
196
197
198
199
200
201
202
 
305
306
307
 
 
 
 
308
309
310
 
29
30
31
32
33
34
 
35
36
37
38
39
40
 
172
173
174
175
176
177
178
179
 
180
181
182
183
184
185
186
187
 
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
 
318
319
320
321
322
323
324
325
326
327
@@ -29,10 +29,12 @@
  self.set_title(_('TortoiseHg Taskbar'))     about = gtk.Button(_('About')) + okay = gtk.Button(_('OK')) + cancel = gtk.Button(_('Cancel'))   self.apply = gtk.Button(_('Apply')) - close = gtk.Button(_('Close'))     vbox = gtk.VBox() + vbox.set_border_width(5)   self.add(vbox)     # Create a new notebook, place the position of the tabs @@ -170,12 +172,16 @@
  accelgroup = gtk.AccelGroup()   self.add_accel_group(accelgroup)   + # Padding + vbox.pack_start(gtk.HBox(), False, False, 3) +   # Bottom buttons   bbox = gtk.HBox() - vbox.pack_start(bbox, False, False, 2) + vbox.pack_start(bbox, False, False)     lefthbbox = gtk.HButtonBox()   lefthbbox.set_layout(gtk.BUTTONBOX_START) + lefthbbox.set_spacing(6)   bbox.pack_start(lefthbbox, False, False)     about.connect('clicked', self.about) @@ -185,18 +191,25 @@
    righthbbox = gtk.HButtonBox()   righthbbox.set_layout(gtk.BUTTONBOX_END) + righthbbox.set_spacing(6)   bbox.pack_start(righthbbox, False, False)   + okay.connect('clicked', self.okay_clicked) + key, modifier = gtk.accelerator_parse('Return') + okay.add_accelerator('clicked', accelgroup, key, 0, + gtk.ACCEL_VISIBLE) + righthbbox.pack_start(okay, False, False) + + cancel.connect('clicked', lambda x: self.destroy()) + key, modifier = gtk.accelerator_parse('Escape') + cancel.add_accelerator('clicked', accelgroup, key, 0, + gtk.ACCEL_VISIBLE) + righthbbox.pack_start(cancel, False, False) +   self.apply.connect('clicked', self.apply_clicked)   self.apply.set_sensitive(False)   righthbbox.pack_start(self.apply, False, False)   - close.connect('clicked', lambda x: self.destroy()) - key, modifier = gtk.accelerator_parse('Escape') - close.add_accelerator('clicked', accelgroup, key, 0, - gtk.ACCEL_VISIBLE) - righthbbox.pack_start(close, False, False) -   def add_page(self, notebook, tab):   frame = gtk.Frame()   frame.set_border_width(5) @@ -305,6 +318,10 @@
  def top_clicked(self, button):   self.move_to_other(self.submlist)   + def okay_clicked(self, button): + self.store_shell_configs() + self.destroy() +   def apply_clicked(self, button):   self.store_shell_configs()   button.set_sensitive(False)
 
523
524
525
 
526
527
528
 
523
524
525
526
527
528
529
@@ -523,6 +523,7 @@
  gtk.STOCK_APPLY, gtk.RESPONSE_APPLY))   gtklib.set_tortoise_keys(self)   self._btn_apply = self.action_area.get_children()[0] + self.set_has_separator(False)     self.ui = ui.ui()   try:
Change 1 of 17 Show Entire File win32/​shellext/​CShellExtCMenu.cpp Stacked
renamed from win32/shellext/ContextMenu.cpp
 
1
2
3
4
5
 
7
8
9
 
 
10
11
12
 
339
340
341
342
 
343
344
345
 
346
347
348
 
495
496
497
498
 
499
500
501
 
521
522
523
524
 
525
526
 
527
528
529
530
531
532
 
533
534
535
 
539
540
541
542
 
543
544
545
 
549
550
551
552
 
553
554
555
 
578
579
580
581
 
582
583
584
 
586
587
588
589
 
590
591
592
593
594
 
595
596
597
 
602
603
604
605
 
606
607
608
 
631
632
633
634
 
635
636
637
 
648
649
650
651
 
652
653
654
 
658
659
660
661
 
662
663
664
665
666
667
668
 
669
670
671
 
674
675
676
677
 
678
679
680
 
682
683
684
685
 
686
687
688
 
732
733
734
735
 
736
737
738
 
813
814
815
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
 
2
3
4
 
6
7
8
9
10
11
12
13
 
340
341
342
 
343
344
345
 
346
347
348
349
 
496
497
498
 
499
500
501
502
 
522
523
524
 
525
526
 
527
528
529
530
531
532
 
533
534
535
536
 
540
541
542
 
543
544
545
546
 
550
551
552
 
553
554
555
556
 
579
580
581
 
582
583
584
585
 
587
588
589
 
590
591
592
593
594
 
595
596
597
598
 
603
604
605
 
606
607
608
609
 
632
633
634
 
635
636
637
638
 
649
650
651
 
652
653
654
655
 
659
660
661
 
662
663
664
665
666
667
668
 
669
670
671
672
 
675
676
677
 
678
679
680
681
 
683
684
685
 
686
687
688
689
 
733
734
735
 
736
737
738
739
 
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
@@ -1,5 +1,4 @@
 #include "stdafx.h" -#include "ShellExt.h"  #include "TortoiseUtils.h"  #include "StringUtils.h"  #include "Dirstatecache.h" @@ -7,6 +6,8 @@
 #include "Winstat.h"  #include "InitStatus.h"  #include "SysInfo.h" +#include "ShellExt.h" +#include "CShellExtCMenu.h"  #include <map>     @@ -339,10 +340,10 @@
   // IContextMenu  STDMETHODIMP -CShellExt::QueryContextMenu( +CShellExtCMenu::QueryContextMenu(   HMENU hMenu, UINT indexMenu, UINT idCmdFirst, UINT idCmdLast, UINT uFlags)  { - TDEBUG_TRACE("CShellExt::QueryContextMenu"); + TDEBUG_TRACE("CShellExtCMenu::QueryContextMenu");   InitMenuMaps();     UINT idCmd = idCmdFirst; @@ -495,7 +496,7 @@
  }   }   - TDEBUG_TRACE(" CShellExt::QueryContextMenu: adding main THG menu"); + TDEBUG_TRACE(" CShellExtCMenu::QueryContextMenu: adding main THG menu");   InsertSubMenuItemWithIcon2(hMenu, hSubMenu, indexMenu++, idCmd++,   L"TortoiseHG", "hg.ico");   @@ -521,15 +522,15 @@
     STDMETHODIMP -CShellExt::InvokeCommand(LPCMINVOKECOMMANDINFO lpcmi) +CShellExtCMenu::InvokeCommand(LPCMINVOKECOMMANDINFO lpcmi)  { - TDEBUG_TRACE("CShellExt::InvokeCommand"); + TDEBUG_TRACE("CShellExtCMenu::InvokeCommand");     HRESULT hr = E_INVALIDARG;   if (!HIWORD(lpcmi->lpVerb))   {   UINT idCmd = LOWORD(lpcmi->lpVerb); - TDEBUG_TRACE("CShellExt::InvokeCommand: idCmd = " << idCmd); + TDEBUG_TRACE("CShellExtCMenu::InvokeCommand: idCmd = " << idCmd);   MenuIdCmdMap::iterator iter = MenuIdMap.find(idCmd);   if (iter != MenuIdMap.end())   { @@ -539,7 +540,7 @@
  else   {   TDEBUG_TRACE( - "CShellExt::InvokeCommand: action not found for idCmd " + "CShellExtCMenu::InvokeCommand: action not found for idCmd "   << idCmd   );   } @@ -549,7 +550,7 @@
     STDMETHODIMP -CShellExt::GetCommandString( +CShellExtCMenu::GetCommandString(   UINT_PTR idCmd, UINT uFlags, UINT FAR *reserved,   LPSTR pszName, UINT cchMax)  { @@ -578,7 +579,7 @@
  }     TDEBUG_TRACE( - "CShellExt::GetCommandString: idCmd = " << idCmd + "CShellExtCMenu::GetCommandString: idCmd = " << idCmd   << ", uFlags = " << uFlags << " (" << sflags << ")"   << ", cchMax = " << cchMax   ); @@ -586,12 +587,12 @@
  MenuIdCmdMap::iterator iter = MenuIdMap.find(static_cast<UINT>(idCmd));   if (iter == MenuIdMap.end())   { - TDEBUG_TRACE("CShellExt::GetCommandString: idCmd not found"); + TDEBUG_TRACE("CShellExtCMenu::GetCommandString: idCmd not found");   }   else   {   TDEBUG_TRACE( - "CShellExt::GetCommandString: name = \"" << iter->second.name << "\""); + "CShellExtCMenu::GetCommandString: name = \"" << iter->second.name << "\"");     if (uFlags == GCS_HELPTEXTW)   { @@ -602,7 +603,7 @@
  if (size >= 40)   {   TDEBUG_TRACE( - "CShellExt::GetCommandString: warning:" + "CShellExtCMenu::GetCommandString: warning:"   << " length of help text is " << size   << ", which is not reasonably short (<40)");   } @@ -631,7 +632,7 @@
    if (cchMax < 1)   { - TDEBUG_TRACE("CShellExt::GetCommandString: cchMax = " + TDEBUG_TRACE("CShellExtCMenu::GetCommandString: cchMax = "   << cchMax << " (is <1)");   return res;   } @@ -648,7 +649,7 @@
    size = wcslen(src);   - TDEBUG_TRACEW(L"CShellExt::GetCommandString: res = " << int(res) + TDEBUG_TRACEW(L"CShellExtCMenu::GetCommandString: res = " << int(res)   << L", pszName (wide) = \"" << dest << L"\"");   }   else @@ -658,14 +659,14 @@
    size = strlen(psz);   - TDEBUG_TRACE("CShellExt::GetCommandString: res = " << int(res) + TDEBUG_TRACE("CShellExtCMenu::GetCommandString: res = " << int(res)   << ", pszName = \"" << psz << "\"");   }     if (size > cchMax-1)   {   TDEBUG_TRACE( - "CShellExt::GetCommandString: string was truncated: size = " + "CShellExtCMenu::GetCommandString: string was truncated: size = "   << size << ", cchMax = " << cchMax);   }   @@ -674,7 +675,7 @@
     STDMETHODIMP -CShellExt::HandleMenuMsg(UINT uMsg, WPARAM wParam, LPARAM lParam) +CShellExtCMenu::HandleMenuMsg(UINT uMsg, WPARAM wParam, LPARAM lParam)  {   LRESULT res;   return HandleMenuMsg2(uMsg, wParam, lParam, &res); @@ -682,7 +683,7 @@
     STDMETHODIMP -CShellExt::HandleMenuMsg2( +CShellExtCMenu::HandleMenuMsg2(   UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT* pResult)  {   // A great tutorial on owner drawn menus in shell extension can be found @@ -732,7 +733,7 @@
 }     -void CShellExt::DoHgtk(const std::string &cmd) +void CShellExtCMenu::DoHgtk(const std::string &cmd)  {   std::string dir = GetTHgProgRoot();   if (dir.empty()) @@ -813,3 +814,126 @@
  LaunchCommand(hgcmd, cwd);   InitStatus::check();  } + + +STDMETHODIMP CShellExtCMenu::Initialize( + LPCITEMIDLIST pIDFolder, LPDATAOBJECT pDataObj, HKEY hRegKey) +{ + TCHAR name[MAX_PATH+1]; + + TDEBUG_TRACE("CShellExtCMenu::Initialize"); + TDEBUG_TRACE(" pIDFolder: " << pIDFolder); + TDEBUG_TRACE(" pDataObj: " << pDataObj); + + myFolder.clear(); + myFiles.clear(); + + if (pDataObj) + { + FORMATETC fmt = { CF_HDROP, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL }; + STGMEDIUM stg = { TYMED_HGLOBAL }; + if (SUCCEEDED(pDataObj->GetData(&fmt, &stg)) && stg.hGlobal) + { + HDROP hDrop = (HDROP) GlobalLock(stg.hGlobal); + + if (hDrop) + { + UINT uNumFiles = DragQueryFile(hDrop, 0xFFFFFFFF, NULL, 0); + TDEBUG_TRACE(" hDrop uNumFiles = " << uNumFiles); + for (UINT i = 0; i < uNumFiles; ++i) { + if (DragQueryFile(hDrop, i, name, MAX_PATH) > 0) + { + TDEBUG_TRACE(" DragQueryFile [" << i << "] = " << name); + myFiles.push_back(name); + } + } + } + else + { + TDEBUG_TRACE(" hDrop is NULL "); + } + + GlobalUnlock(stg.hGlobal); + if (stg.pUnkForRelease) + { + IUnknown* relInterface = (IUnknown*) stg.pUnkForRelease; + relInterface->Release(); + } + } + else + { + TDEBUG_TRACE(" pDataObj->GetData failed"); + } + } + + // if a directory background + if (pIDFolder) + { + SHGetPathFromIDList(pIDFolder, name); + TDEBUG_TRACE(" Folder " << name); + myFolder = name; + } + + return NOERROR; +} + + +CShellExtCMenu::CShellExtCMenu(char dummy) : + m_ppszFileUserClickedOn(0) +{ + m_cRef = 0L; + CShellExt::IncDllRef(); +} + + +CShellExtCMenu::~CShellExtCMenu() +{ + CShellExt::DecDllRef(); +} + + +STDMETHODIMP_(ULONG) CShellExtCMenu::AddRef() +{ + ThgCriticalSection cs(CShellExt::GetCriticalSection()); + return ++m_cRef; +} + + +STDMETHODIMP_(ULONG) CShellExtCMenu::Release() +{ + ThgCriticalSection cs(CShellExt::GetCriticalSection()); + if(--m_cRef) + return m_cRef; + delete this; + return 0L; +} + + +STDMETHODIMP CShellExtCMenu::QueryInterface(REFIID riid, LPVOID FAR* ppv) +{ + *ppv = NULL; + if (IsEqualIID(riid, IID_IShellExtInit) || IsEqualIID(riid, IID_IUnknown)) + { + *ppv = (LPSHELLEXTINIT) this; + } + else if (IsEqualIID(riid, IID_IContextMenu)) + { + *ppv = (LPCONTEXTMENU) this; + } + else if (IsEqualIID(riid, IID_IContextMenu2)) + { + *ppv = (IContextMenu2*) this; + } + else if (IsEqualIID(riid, IID_IContextMenu3)) + { + *ppv = (IContextMenu3*) this; + } + + if (*ppv) + { + AddRef(); + return NOERROR; + } + + return E_NOINTERFACE; +}
Change 1 of 1 Show Entire File win32/​shellext/​CShellExtCMenu.h 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
@@ -0,0 +1,45 @@
+#ifndef _CShellExtCMenu_h_ +#define _CShellExtCMenu_h_ + +#include <vector> +#include <string> + + +class CShellExtCMenu: public IContextMenu3, IShellExtInit +{ + ULONG m_cRef; + + LPTSTR* m_ppszFileUserClickedOn; // [MAX_PATH] + std::vector<std::string> myFiles; + std::string myFolder; + + void DoHgtk(const std::string&); + +public: + explicit CShellExtCMenu(char dummy); + ~CShellExtCMenu(); + + // IUnknown + STDMETHODIMP QueryInterface(REFIID riid, LPVOID FAR *ppv); + STDMETHODIMP_(ULONG) AddRef(); + STDMETHODIMP_(ULONG) Release(); + + // IContextMenu3 + STDMETHODIMP QueryContextMenu( + HMENU hMenu, UINT indexMenu, UINT idCmdFirst, UINT idCmdLast, + UINT uFlags); + STDMETHODIMP InvokeCommand(LPCMINVOKECOMMANDINFO lpcmi); + STDMETHODIMP GetCommandString( + UINT_PTR idCmd, UINT uFlags, UINT FAR* reserved,LPSTR pszName, + UINT cchMax); + STDMETHODIMP HandleMenuMsg(UINT uMsg, WPARAM wParam, LPARAM lParam); + STDMETHODIMP HandleMenuMsg2( + UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT* pResult); + + // IShellExtInit + STDMETHODIMP Initialize( + LPCITEMIDLIST pIDFolder, LPDATAOBJECT pDataObj, HKEY hKeyID); +}; + + +#endif
Change 1 of 3 Show Entire File win32/​shellext/​CShellExtOverlay.cpp Stacked
renamed from win32/shellext/IconOverlay.cpp
 
3
4
5
 
6
7
8
9
10
 
11
12
13
 
14
15
16
 
19
20
21
22
 
23
24
25
26
27
28
29
 
30
31
 
32
33
34
 
53
54
55
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
4
5
6
7
8
9
10
 
11
12
13
 
14
15
16
17
 
20
21
22
 
23
24
25
26
27
28
29
 
30
31
 
32
33
34
35
 
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
@@ -3,14 +3,15 @@
 #include "TortoiseUtils.h"  #include "StringUtils.h"  #include "QueryDirstate.h" +#include "CShellExtOverlay.h"    #include <shlwapi.h>     -STDMETHODIMP CShellExt::GetOverlayInfo( +STDMETHODIMP CShellExtOverlay::GetOverlayInfo(   LPWSTR pwszIconFile, int cchMax, int *pIndex, DWORD *pdwFlags)  { - TDEBUG_TRACE("CShellExt::GetOverlayInfo: myTortoiseClass = " << myTortoiseClass); + TDEBUG_TRACE("CShellExtOverlay::GetOverlayInfo: myTortoiseClass = " << myTortoiseClass);   // icons are determined by TortoiseOverlays shim   *pIndex = 0;   *pdwFlags = 0; @@ -19,16 +20,16 @@
 }     -STDMETHODIMP CShellExt::GetPriority(int *pPriority) +STDMETHODIMP CShellExtOverlay::GetPriority(int *pPriority)  {   *pPriority = 1;   return S_OK;  }     -STDMETHODIMP CShellExt::IsMemberOf(LPCWSTR pwszPath, DWORD /* dwAttrib */) +STDMETHODIMP CShellExtOverlay::IsMemberOf(LPCWSTR pwszPath, DWORD /* dwAttrib */)  { - ThgCriticalSection cs(GetCriticalSection()); + ThgCriticalSection cs(CShellExt::GetCriticalSection());     std::string cval;   if (GetRegistryConfig("EnableOverlays", cval) != 0 && cval == "0") @@ -53,3 +54,53 @@
    return S_FALSE;  } + + +CShellExtOverlay::CShellExtOverlay(char tortoiseClass) : + myTortoiseClass(tortoiseClass) +{ + m_cRef = 0L; + CShellExt::IncDllRef(); +} + + +CShellExtOverlay::~CShellExtOverlay() +{ + CShellExt::DecDllRef(); +} + + +STDMETHODIMP_(ULONG) CShellExtOverlay::AddRef() +{ + ThgCriticalSection cs(CShellExt::GetCriticalSection()); + return ++m_cRef; +} + + +STDMETHODIMP_(ULONG) CShellExtOverlay::Release() +{ + ThgCriticalSection cs(CShellExt::GetCriticalSection()); + if(--m_cRef) + return m_cRef; + delete this; + return 0L; +} + + +STDMETHODIMP CShellExtOverlay::QueryInterface(REFIID riid, LPVOID FAR* ppv) +{ + *ppv = NULL; + if (IsEqualIID(riid, IID_IShellIconOverlayIdentifier) + || IsEqualIID(riid, IID_IUnknown) ) + { + *ppv = (IShellIconOverlayIdentifier*) this; + } + + if (*ppv) + { + AddRef(); + return NOERROR; + } + + return E_NOINTERFACE; +}
Change 1 of 1 Show Entire File win32/​shellext/​CShellExtOverlay.h 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
@@ -0,0 +1,27 @@
+#ifndef _CShellExtOverlay_h_ +#define _CShellExtOverlay_h_ + + +class CShellExtOverlay: public IShellIconOverlayIdentifier +{ + ULONG m_cRef; + const char myTortoiseClass; + +public: + explicit CShellExtOverlay(char Class); + ~CShellExtOverlay(); + + // IUnknown + STDMETHODIMP QueryInterface(REFIID riid, LPVOID FAR *ppv); + STDMETHODIMP_(ULONG) AddRef(); + STDMETHODIMP_(ULONG) Release(); + + // IShellIconOverlayIdentifier + STDMETHODIMP GetOverlayInfo( + LPWSTR pwszIconFile, int cchMax, int* pIndex, DWORD* pdwFlags); + STDMETHODIMP GetPriority(int* pPriority); + STDMETHODIMP IsMemberOf(LPCWSTR pwszPath, DWORD dwAttrib); +}; + + +#endif
 
7
8
9
10
11
 
 
12
13
14
 
19
20
21
22
23
 
24
25
26
 
7
8
9
 
 
10
11
12
13
14
 
19
20
21
 
 
22
23
24
25
@@ -7,8 +7,8 @@
   OBJECTS_THGSGELL = $(OBJECTS_DIRSTATE) \   InitStatus.obj \ - ContextMenu.obj \ - IconOverlay.obj \ + CShellExtCMenu.obj \ + CShellExtOverlay.obj \   IconBitmapUtils.obj \   Registry.obj \   ShellExt.obj \ @@ -19,8 +19,7 @@
  Dirstatecache.obj \   DirectoryStatus.obj \   Thgstatus.obj \ - QueryDirstate.obj \ - ThgDebug.obj + QueryDirstate.obj    LIBS = shlwapi.lib gdiplus.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib  DEFFILE = ShellExt.def
 
3
4
5
 
 
 
 
6
7
8
9
10
 
 
11
12
13
 
19
20
21
22
23
24
25
26
 
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
 
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
 
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
 
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
 
25
26
27
 
 
28
29
30
 
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
 
128
129
130
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
131
132
133
 
137
138
139
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
140
141
142
143
144
145
146
 
147
148
 
 
149
150
151
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
@@ -3,11 +3,17 @@
 #include "TortoiseUtils.h"  #include "StringUtils.h"  #include "InitStatus.h" +#include "ThgClassFactory.h" +#include "CShellExtCMenu.h" +#include "CShellExtOverlay.h" +  #include <olectl.h>    #define INITGUID  #include <initguid.h>   +DEFINE_GUID(CLSID_TortoiseHgCmenu, 0xb456db9fL, 0x7bf4, 0x478c, 0x93, 0x7a, 0x5, 0x13, 0xc, 0x2c, 0x21, 0x2e); +  DEFINE_GUID(CLSID_TortoiseHg0, 0xb456dba0L, 0x7bf4, 0x478c, 0x93, 0x7a, 0x5, 0x13, 0xc, 0x2c, 0x21, 0x2e);  DEFINE_GUID(CLSID_TortoiseHg1, 0xb456dba1L, 0x7bf4, 0x478c, 0x93, 0x7a, 0x5, 0x13, 0xc, 0x2c, 0x21, 0x2e);  DEFINE_GUID(CLSID_TortoiseHg2, 0xb456dba2L, 0x7bf4, 0x478c, 0x93, 0x7a, 0x5, 0x13, 0xc, 0x2c, 0x21, 0x2e); @@ -19,8 +25,6 @@
 UINT g_cRefThisDll = 0;  HINSTANCE g_hmodThisDll = NULL;   -HMENU hSubMenu = 0; -  CRITICAL_SECTION g_critical_section;     @@ -75,34 +79,39 @@
  TDEBUG_TRACE("DllGetClassObject clsid = " << WideToMultibyte(pwszShellExt));   *ppvOut = NULL;   - if (IsEqualIID(rclsid, CLSID_TortoiseHg0)) + typedef ThgClassFactory<CShellExtOverlay> FactOvl; + typedef ThgClassFactory<CShellExtCMenu> FactCmenu; + + if (IsEqualIID(rclsid, CLSID_TortoiseHgCmenu))   { - CDllRegSxClassFactory *pcf = - new CDllRegSxClassFactory('C'); // clean + FactCmenu *pcf = new FactCmenu(0); + TDEBUG_TRACE("DllGetClassObject clsname = " << "CLSID_TortoiseHgCmenu"); + return pcf->QueryInterface(riid, ppvOut); + } + else if (IsEqualIID(rclsid, CLSID_TortoiseHg0)) + { + FactOvl *pcf = new FactOvl('C'); // clean   TDEBUG_TRACE("DllGetClassObject clsname = " << "CLSID_TortoiseHg0");   ++InitStatus::inst().unchanged_;   return pcf->QueryInterface(riid, ppvOut);   }   else if (IsEqualIID(rclsid, CLSID_TortoiseHg1))   { - CDllRegSxClassFactory *pcf = - new CDllRegSxClassFactory('A'); // added + FactOvl *pcf = new FactOvl('A'); // added   TDEBUG_TRACE("DllGetClassObject clsname = " << "CLSID_TortoiseHg1");   ++InitStatus::inst().added_;   return pcf->QueryInterface(riid, ppvOut);   }   else if (IsEqualIID(rclsid, CLSID_TortoiseHg2))   { - CDllRegSxClassFactory *pcf = - new CDllRegSxClassFactory('M'); // modified + FactOvl *pcf = new FactOvl('M'); // modified   TDEBUG_TRACE("DllGetClassObject clsname = " << "CLSID_TortoiseHg2");   ++InitStatus::inst().modified_;   return pcf->QueryInterface(riid, ppvOut);   }   else if (IsEqualIID(rclsid, CLSID_TortoiseHg6))   { - CDllRegSxClassFactory *pcf = - new CDllRegSxClassFactory('?'); // not in repo + FactOvl *pcf = new FactOvl('?'); // not in repo   TDEBUG_TRACE("DllGetClassObject clsname = " << "CLSID_TortoiseHg6");   ++InitStatus::inst().notinrepo_;   return pcf->QueryInterface(riid, ppvOut); @@ -119,110 +128,6 @@
   VOID _UnloadResources(VOID)  { - if (hSubMenu) - DestroyMenu(hSubMenu); -} - - -LPCRITICAL_SECTION CDllRegSxClassFactory::GetCriticalSection() -{ - return &g_critical_section; -} - - -CDllRegSxClassFactory::CDllRegSxClassFactory(char classToMake) : - myclassToMake(classToMake) -{ - ThgCriticalSection cs(GetCriticalSection()); - m_cRef = 0L; - g_cRefThisDll++; -} - - -CDllRegSxClassFactory::~CDllRegSxClassFactory() -{ - ThgCriticalSection cs(GetCriticalSection()); - g_cRefThisDll--; -} - - -STDMETHODIMP CDllRegSxClassFactory::QueryInterface( - REFIID riid, LPVOID FAR* ppv) -{ - *ppv = NULL; - - if (IsEqualIID(riid, IID_IUnknown) || IsEqualIID(riid, IID_IClassFactory)) - { - *ppv = (LPCLASSFACTORY) this; - AddRef(); - return NOERROR; - } - - return E_NOINTERFACE; -} - - -STDMETHODIMP_(ULONG) CDllRegSxClassFactory::AddRef() -{ - ThgCriticalSection cs(GetCriticalSection()); - return ++m_cRef; -} - - -STDMETHODIMP_(ULONG) CDllRegSxClassFactory::Release() -{ - ThgCriticalSection cs(GetCriticalSection()); - if (--m_cRef) - return m_cRef; - - delete this; - return 0L; -} - - -STDMETHODIMP CDllRegSxClassFactory::CreateInstance( - LPUNKNOWN pUnkOuter, REFIID riid, LPVOID* ppvObj) -{ - *ppvObj = NULL; - - if (pUnkOuter) - return CLASS_E_NOAGGREGATION; - - LPCSHELLEXT pShellExt = new CShellExt(myclassToMake); - if (NULL == pShellExt) - return E_OUTOFMEMORY; - - return pShellExt->QueryInterface(riid, ppvObj); -} - - -STDMETHODIMP CDllRegSxClassFactory::LockServer(BOOL fLock) -{ - return NOERROR; -} - - -CShellExt::CShellExt(char tortoiseClass) : - myTortoiseClass(tortoiseClass), - m_ppszFileUserClickedOn(0) -{ - ThgCriticalSection cs(GetCriticalSection()); - - m_cRef = 0L; - m_pDataObj = NULL; - - g_cRefThisDll++; -} - - -CShellExt::~CShellExt() -{ - ThgCriticalSection cs(GetCriticalSection()); - - if (m_pDataObj) - m_pDataObj->Release(); - - g_cRefThisDll--;  }     @@ -232,116 +137,15 @@
 }     -STDMETHODIMP CShellExt::QueryInterface(REFIID riid, LPVOID FAR* ppv) -{ - *ppv = NULL; - if (IsEqualIID(riid, IID_IShellExtInit) || IsEqualIID(riid, IID_IUnknown)) - { - *ppv = (LPSHELLEXTINIT) this; - } - else if (IsEqualIID(riid, IID_IContextMenu)) - { - *ppv = (LPCONTEXTMENU) this; - } - else if (IsEqualIID(riid, IID_IContextMenu2)) - { - *ppv = (IContextMenu2*) this; - } - else if (IsEqualIID(riid, IID_IContextMenu3)) - { - *ppv = (IContextMenu3*) this; - } - else if (IsEqualIID(riid, IID_IShellIconOverlayIdentifier)) - { - *ppv = (IShellIconOverlayIdentifier*) this; - } - - if (*ppv) - { - AddRef(); - return NOERROR; - } - - return E_NOINTERFACE; +void CShellExt::IncDllRef() +{ + ThgCriticalSection cs(CShellExt::GetCriticalSection()); + g_cRefThisDll++;  }     -STDMETHODIMP_(ULONG) CShellExt::AddRef() +void CShellExt::DecDllRef()  { - ThgCriticalSection cs(GetCriticalSection()); - return ++m_cRef; + ThgCriticalSection cs(CShellExt::GetCriticalSection()); + g_cRefThisDll--;  } - - -STDMETHODIMP_(ULONG) CShellExt::Release() -{ - ThgCriticalSection cs(GetCriticalSection()); - - if(--m_cRef) - return m_cRef; - - delete this; - return 0L; -} - - -STDMETHODIMP CShellExt::Initialize( - LPCITEMIDLIST pIDFolder, LPDATAOBJECT pDataObj, HKEY hRegKey) -{ - TCHAR name[MAX_PATH+1]; - - TDEBUG_TRACE("CShellExt::Initialize"); - TDEBUG_TRACE(" pIDFolder: " << pIDFolder); - TDEBUG_TRACE(" pDataObj: " << pDataObj); - - myFolder.clear(); - myFiles.clear(); - - if (pDataObj) - { - FORMATETC fmt = { CF_HDROP, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL }; - STGMEDIUM stg = { TYMED_HGLOBAL }; - if (SUCCEEDED(pDataObj->GetData(&fmt, &stg)) && stg.hGlobal) - { - HDROP hDrop = (HDROP) GlobalLock(stg.hGlobal); - - if (hDrop) - { - UINT uNumFiles = DragQueryFile(hDrop, 0xFFFFFFFF, NULL, 0); - TDEBUG_TRACE(" hDrop uNumFiles = " << uNumFiles); - for (UINT i = 0; i < uNumFiles; ++i) { - if (DragQueryFile(hDrop, i, name, MAX_PATH) > 0) - { - TDEBUG_TRACE(" DragQueryFile [" << i << "] = " << name); - myFiles.push_back(name); - } - } - } - else - { - TDEBUG_TRACE(" hDrop is NULL "); - } - - GlobalUnlock(stg.hGlobal); - if (stg.pUnkForRelease) - { - IUnknown* relInterface = (IUnknown*) stg.pUnkForRelease; - relInterface->Release(); - } - } - else - { - TDEBUG_TRACE(" pDataObj->GetData failed"); - } - } - - // if a directory background - if (pIDFolder) - { - SHGetPathFromIDList(pIDFolder, name); - TDEBUG_TRACE(" Folder " << name); - myFolder = name; - } - - return NOERROR; -}
 
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
 
1
2
3
 
 
4
 
 
5
6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
8
9
10
11
12
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
14
15
@@ -1,84 +1,15 @@
 #ifndef _SHELL_EXT_H_  #define _SHELL_EXT_H_   -#include <vector> -#include <string>   - -class CDllRegSxClassFactory: public IClassFactory +class CShellExt  { - protected: - ULONG m_cRef; - const char myclassToMake; - - public: - explicit CDllRegSxClassFactory(char classToMake); - ~CDllRegSxClassFactory(); - - static LPCRITICAL_SECTION GetCriticalSection(); - - STDMETHODIMP QueryInterface(REFIID, LPVOID FAR*); - STDMETHODIMP_(ULONG) AddRef(); - STDMETHODIMP_(ULONG) Release(); - - STDMETHODIMP CreateInstance(LPUNKNOWN, REFIID, LPVOID FAR*); - STDMETHODIMP LockServer(BOOL); +public: + static LPCRITICAL_SECTION GetCriticalSection(); + static void IncDllRef(); + static void DecDllRef();  };   -typedef CDllRegSxClassFactory* LPCSHELLEXTCLASSFACTORY; - - -class CShellExt: - public IContextMenu3, IShellIconOverlayIdentifier, IShellExtInit -{ - const char myTortoiseClass; - - protected: - ULONG m_cRef; - LPDATAOBJECT m_pDataObj; - - LPTSTR* m_ppszFileUserClickedOn; // [MAX_PATH] - std::vector<std::string> myFiles; - std::string myFolder; - - void CShellExt::DoHgtk(const std::string&); - - public: - static LPCRITICAL_SECTION GetCriticalSection(); - - explicit CShellExt(char Class); - ~CShellExt(); - - // IUnknown - STDMETHODIMP QueryInterface(REFIID riid, LPVOID FAR *ppv); - STDMETHODIMP_(ULONG) AddRef(); - STDMETHODIMP_(ULONG) Release(); - - // IContextMenu3 - STDMETHODIMP QueryContextMenu( - HMENU hMenu, UINT indexMenu, UINT idCmdFirst, UINT idCmdLast, - UINT uFlags); - STDMETHODIMP InvokeCommand(LPCMINVOKECOMMANDINFO lpcmi); - STDMETHODIMP GetCommandString( - UINT_PTR idCmd, UINT uFlags, UINT FAR* reserved,LPSTR pszName, - UINT cchMax); - STDMETHODIMP HandleMenuMsg(UINT uMsg, WPARAM wParam, LPARAM lParam); - STDMETHODIMP HandleMenuMsg2( - UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT* pResult); - - // IShellIconOverlayIdentifier - STDMETHODIMP GetOverlayInfo( - LPWSTR pwszIconFile, int cchMax, int* pIndex, DWORD* pdwFlags); - STDMETHODIMP GetPriority(int* pPriority); - STDMETHODIMP IsMemberOf(LPCWSTR pwszPath, DWORD dwAttrib); - - // IShellExtInit - STDMETHODIMP Initialize( - LPCITEMIDLIST pIDFolder, LPDATAOBJECT pDataObj, HKEY hKeyID); - }; - -typedef CShellExt* LPCSHELLEXT; -    class ThgCriticalSection  {
Change 1 of 1 Show Entire File win32/​shellext/​ThgClassFactory.h 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
@@ -0,0 +1,86 @@
+#ifndef _ThgClassFactory_h_ +#define _ThgClassFactory_h_ + +#include "ShellExt.h" + + +template <class T> +class ThgClassFactory: public IClassFactory +{ + ULONG m_cRef; + const char myclassToMake; + +public: + explicit ThgClassFactory(char classToMake) : + myclassToMake(classToMake) + { + CShellExt::IncDllRef(); + m_cRef = 0L; + } + + + ~ThgClassFactory() + { + CShellExt::DecDllRef(); + } + + + STDMETHODIMP QueryInterface( + REFIID riid, LPVOID FAR* ppv) + { + *ppv = NULL; + + if (IsEqualIID(riid, IID_IUnknown) || IsEqualIID(riid, IID_IClassFactory)) + { + *ppv = (LPCLASSFACTORY) this; + AddRef(); + return NOERROR; + } + + return E_NOINTERFACE; + } + + + STDMETHODIMP_(ULONG) AddRef() + { + ThgCriticalSection cs(CShellExt::GetCriticalSection()); + return ++m_cRef; + } + + + STDMETHODIMP_(ULONG) Release() + { + ThgCriticalSection cs(CShellExt::GetCriticalSection()); + if (--m_cRef) + return m_cRef; + + delete this; + return 0L; + } + + + STDMETHODIMP CreateInstance( + LPUNKNOWN pUnkOuter, REFIID riid, LPVOID* ppvObj) + { + *ppvObj = NULL; + + if (pUnkOuter) + return CLASS_E_NOAGGREGATION; + + T *pShellExt = new T(myclassToMake); + if (NULL == pShellExt) + return E_OUTOFMEMORY; + + return pShellExt->QueryInterface(riid, ppvObj); + } + + + STDMETHODIMP LockServer(BOOL fLock) + { + return NOERROR; + } + +}; + + +#endif