Kiln » TortoiseHg » WinBuild Read More
Clone URL:  
Pushed to one repository · View In Graph Contained in tip

reconfigure relative paths, source repos are at same level as thg-winbuild

* thg-winbuild now expects to exist as an hg-build subrepo
* hg-main renamed to hg
* dulwich updated to 0.8.0
* cleanup ignore filter

Changeset 8145a2a26fe2

Parent be36d975ec40

by Steve Borho

Changes to 4 files · Browse files at 8145a2a26fe2 Showing diff from parent be36d975ec40 Diff from another changeset...

Change 1 of 1 Show Entire File .hgignore Stacked
 
1
2
3
4
 
5
6
7
8
9
10
 
1
 
2
3
4
5
6
7
8
 
9
@@ -1,10 +1,9 @@
 syntax: glob -output/  misc/ThgShellx??.dll  misc/terminate.exe +misc/cacert.pem  *.pfx  *~  *.pyc  .*.swp -misc/cacert.pem  *key*
Change 1 of 3 Show Entire File README.txt Stacked
 
1
2
3
 
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
 
120
121
122
123
 
124
125
126
 
140
141
142
143
 
 
1
2
 
3
4
5
6
7
 
 
 
 
 
 
 
 
 
 
 
 
8
9
10
 
108
109
110
 
111
112
113
114
 
128
129
130
 
131
@@ -1,22 +1,10 @@
 TortoiseHg and Mercurial installer builder for Windows   -Repository subdirs: +Contents:    contrib/ - Bundled libraries and utilities external to (T)HG  misc/ - Miscellaneous files used to build packages   -Clones (setup.py will create these clones at runtime): - -hg-main - Mercurial repository -thg - TortoiseHg repository -hgfold - case folding conflict detection and resolution extension -keyring - python-keyring-lib -hgkeyring - mercurial keyring extension -perfarce - perforce integration extension -fixfrozenexts - allow 'hg help extensions' to work on Windows -iniparse - allow thg to apply changes to ini (hgrc) files -dulwich - Python interface to git repositories -  === Mercurial Prerequisites ===    - Python 2.6.6 @@ -120,7 +108,7 @@
  http://sourceforge.net/projects/pywin32/   pywin32-216.win32-py2.6.exe   -- comtypes (optional, for BugTraq) +- comtypes (no longer optional)     comtypes-0.6.2.win32.exe from   http://sourceforge.net/projects/comtypes/files/ @@ -140,4 +128,4 @@
   To build x64 packages, you use:   -C:\python26_x64\python.exe setup.py --help +C:\python26x64\python.exe setup.py --help
 
2
3
4
5
 
6
7
 
8
9
10
 
 
11
12
13
 
2
3
4
 
5
6
 
7
8
 
 
9
10
11
12
13
@@ -2,12 +2,12 @@
    hgfold: 0d5ced144f81 https://bitbucket.org/bradobro/hgfold/   perfarce: 31fbf702b844 http://www.kingswood-consulting.co.uk/hg/perfarce/ - keyring: 2b131278feee https://bitbucket.org/kang/python-keyring-lib/ + keyring: 31f21c5c87e0 https://bitbucket.org/kang/python-keyring-lib/   hgkeyring: 476937ac8644 https://bitbucket.org/Mekk/mercurial_keyring/ - dulwich: 48bef37ec98d https://bitbucket.org/abderrahim/dulwich/ + dulwich: ed3596b25fd1 https://bitbucket.org/abderrahim/dulwich/   iniparse: bd83edee7300 https://bitbucket.org/sborho/iniparse/ - zipdoc: cde7b15f4d53 https://bitbucket.org/gobell/hg-zipdoc/ - hgcr-gui: dcc0160aef78 https://bitbucket.org/glimchb/hgcr-gui/ + zipdoc: a2ca45ccfd64 https://bitbucket.org/gobell/hg-zipdoc/ + hgcr-gui: 227f2eee94e6 https://bitbucket.org/glimchb/hgcr-gui/   python-svn: 1.6.13 http://bitbucket.org/tortoisehg/thg/downloads   pygments: 1.4 http://pygments.org/download/   pywin32: 216 http://sourceforge.net/projects/pywin32/
Change 1 of 20 Show Changes Only setup.py Stacked
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
 
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
 
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
 
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
 
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
 
316
317
318
319
320
321
322
323
324
325
326
 
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
 
345
346
 
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
 
367
368
369
370
 
371
372
373
374
375
376
377
378
379
380
 
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
 
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
 
 
 
 
 
 
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
 
659
660
661
662
663
664
665
666
667
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
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
 """Generate binary installer for Mercurial or TortoiseHg    Usage: setup.py [OPTIONS]    Options:   -h --help Print this message and exit   --pull Pull from upstream, implied by stable and unstable targets   --nopull Disable pull for all targets   --config Show build configuration and exit   -f --force-hg Force the build-hg directory to be recloned   -F --force-thg Force the build-thg directory to be recloned   -c --clean Clean all build remnants   --thg-release Build a TortoiseHg release package   --thg-stable Build a TortoiseHg nightly stable package   --thg-unstable Build a TortoiseHg nightly unstable package   --thg-doc Only build TortoiseHg documentation in tortoisehg/   --hg-release Build a Mercurial release package   --hg-stable Build a Mercurial nightly stable package   --hg-unstable Build a Mercurial nightly unstable package   --all Build all four nightly targets   --cert <file> Sign output using the specified cert file (pfx)   --only-msi Only build new msi packages (implies nopull)  """    #### Package Respins ####  # TortoiseHg 0.9.2-1 used mercurial.iss from changeset 275690997c5f  # TortoiseHg 1.1.1 used Mercurial revision 6f44bd4cc4f2, tag -l 1.6.1023    import os  import sys  import datetime  import subprocess  import fileinput  import getopt  import re  import shutil  import uuid  import urllib2  import getpass  import hashlib    from distutils.spawn import find_executable    installenv = os.environ  win7sdk = None  sdkenvs = {}    # default to TortoiseHg nightly stable build config  hgbranch = 'stable'  hgtag = 'tip'  thgbranch = 'stable'  thgtag = 'tip'  forcehg = False  forcethg = False  buildhg = False  builddoc = False  buildthg = False  dopull = None  showconfig = False  cert = None  all = False  onlymsi = False  sslcertfile = 'misc/cacert.pem'    URL = { - 'hg-main' : 'http://selenic.com/repo/hg/', + 'hg' : 'http://selenic.com/repo/hg/',   'cacert.pem': 'http://curl.haxx.se/ca/cacert.pem',   'perfarce' : 'http://www.kingswood-consulting.co.uk/hg/perfarce/',   'thg' : 'https://bitbucket.org/tortoisehg/thg/',   'hgfold' : 'https://bitbucket.org/bradobro/hgfold/',   'zipdoc' : 'https://bitbucket.org/gobell/hg-zipdoc/',   'keyring' : 'https://bitbucket.org/kang/python-keyring-lib/',   'hgkeyring' : 'https://bitbucket.org/Mekk/mercurial_keyring/',   'dulwich' : 'https://bitbucket.org/abderrahim/dulwich/',   'iniparse' : 'https://bitbucket.org/sborho/iniparse/',   'hgcr-gui' : 'https://bitbucket.org/glimchb/hgcr-gui/',   }    extensions = [   'hgfold',   'perfarce',   'keyring',   'hgkeyring',   'dulwich',   'iniparse',   'zipdoc',   'hgcr-gui',   ]   -thg_source_repos = ['thg', 'hg-main'] + extensions +thg_source_repos = ['thg', 'hg'] + extensions    extfiles = {   'hgfold': ['hgfold/fold.py'],   'zipdoc': ['zipdoc/zipdoc.py'],   'perfarce': ['perfarce/perfarce.py'],   'hgkeyring': ['hgkeyring/mercurial_keyring.py'],   'hgcr-gui': ['hgcr-gui/hgcr-gui-qt.py'],   }    # Extensions which require PYTHONPATH insertion  path_extensions = ('dulwich', 'keyring', 'iniparse')    # Specify the exact revision to ship for given extension  extversions = {   'iniparse': 'bd83edee7300ce0a4fdddc3eddf743dc6ea98602', # 0.4 - 'dulwich' : '48bef37ec98db39dca1a80669303fd8f5c6608e1', # 0.7.1 + 'dulwich' : 'ed3596b25fd1039b880c2f46cb38202a6289be95', # 0.8.0  }    # Extensions which require compiled C++ Python extensions  compiled_extensions = ('dulwich', 'keyring')    locales = ('cs', 'da', 'de', 'es', 'fr', 'it', 'ja', 'pt', 'pt_BR',   'ru', 'uk', 'zh_CN')    import platform  if platform.architecture()[0] == '64bit':   arch = 'x64'  else:   arch = 'x86'   -def checkrepo(name, ver=''): - if os.path.isdir(name): - return - run(r'hg clone -U %s file:%s' % (URL[name], name)) - run(r'hg update -R %s %s' % (name, ver)) - -  def run(cmd, cwd='.', hide=False, env=installenv):   if not hide:   print cwd + "> " + cmd   try:   subprocess.check_call(cmd, shell=True, cwd=cwd, env=env)   except subprocess.CalledProcessError:   if hide:   raise StandardError("subprocess.CalledProcessError was raised")   else:   raise    def run_python(cmd, cwd='.', hide=False, env=installenv):   cmd = ' '.join([sys.executable, cmd])   run(cmd, cwd, hide, env)    sdkenv_vars = ('include', 'lib', 'mssdk', 'path', 'regkeypath', 'sdksetupdir',   'sdktools', 'targetos', 'vcinstalldir', 'vcroot', 'vsregkeypath')    def get_pruned_env(arch):   # Remove folders from %PATH% that contain QtCore4.dll, unless it is the   # PyQt4\bin folder for the executing Python environment   prefix = sys.exec_prefix.lower() + os.sep   deletions = []   fenv = get_sdkenv(arch).copy()   path = fenv.get('PATH', '').split(os.pathsep)   for dir in path:   if dir.lower().startswith(prefix):   continue   if os.path.exists(os.path.join(dir, 'QtCore4.dll')):   deletions.append(dir)   for dir in deletions:   print 'removing', dir, 'from PATH'   path.remove(dir)   fenv['PATH'] = os.pathsep.join(path)   return fenv    def get_sdkenv(arch):   if arch in sdkenvs:   return sdkenvs[arch]   p = subprocess.Popen(r'cmd /e:on /v:on /c call "%s\Bin\SetEnv.cmd" /xp /%s /release && set' %   (win7sdk, arch),   shell=False,   stdout=subprocess.PIPE,   stderr=subprocess.PIPE)   out, err = p.communicate()   newenv = {}   for line in out.splitlines():   if '=' in line:   k, v = line.split('=', 1)   if k.lower() in sdkenv_vars:   newenv[k.upper()] = v   env = installenv.copy()   env.update(newenv)   sdkenvs[arch] = env   return env    def lasttag(reponame, branch):   "return latest tag that lives on specified branch"   cmd = ('hg', '--repository', reponame, 'log',   '--rev', 'tagged() and branch(%s)' % branch,   '--template={tags}$')   p = subprocess.Popen(cmd,   stdin=subprocess.PIPE,   stdout=subprocess.PIPE,   shell=False)   stdout_text, stderr_text = p.communicate('')   # use -2 to ignore trailing blank output   return stdout_text.split('$')[-2]    def repoversion(verfile):   globals = {}   execfile(verfile, globals)   return globals.get('version', 'unknown')    def windowsversion(name, version):   extra = None   if '+' in version:   version, extra = version.split('+', 1)     v = [int(x) for x in version.split('.')]   while len(v) < 3:   v.append(0)   major, minor, periodic = v[:3]     if extra != None:   tagdistance = int(extra.split('-', 1)[0])   periodic *= 1000   if 'unstable' in name:   periodic += tagdistance + 500   else:   periodic += tagdistance + 100     return [str(x) for x in (major, minor, periodic)]    def pipetofile(cmdlist, outfile, cwd):   print '> ', ' '.join(cmdlist), '>', outfile   p = subprocess.Popen( cmdlist,   stdin=subprocess.PIPE,   stdout=subprocess.PIPE,   shell=False,   cwd=cwd)   out, err = p.communicate('')   fp = open(outfile, 'wb')   fp.write(out)   fp.close    def candle(file, sourcedir=None, cwd='.', defines=None):   args = []   if sourcedir:   args.append('-dSourceDir="%s"' % sourcedir)   if defines:   args += ['-d%s="%s"' % item for item in defines]   run(r'candle -nologo "%s" %s' % (file, ' '.join(args)), cwd)    def light(output, cwd, *files):   run(r'light -nologo -ext WixUIExtension -sw1076 -spdb -o %s %s' %   (output, ' '.join(f + '.wixobj' for f in files)), cwd)    def generate_hgext_index(branch):   """Generate list of extensions under hgext/"""   run(r'del build-hg\hgext\__index__.*')   run_python(r'setup.py build_hgextindex', 'build-hg')    def build_hg(force, branch, tag, arch):   if onlymsi:   return     if force or not os.path.exists('build-hg'):   run(r'if exist build-hg rmdir /s /q build-hg') - run(r'hg clone file:hg-main -u %s file:build-hg' % branch) + run(r'hg clone file:../hg -u %s file:build-hg' % branch)   else:   run(r'hg -R build-hg pull')   run(r'hg -R build-hg update ' + branch)   if tag == 'tip':   run(r'hg -R build-hg update')   else:   run(r'hg -R build-hg update ' + tag)     # Clear files added by previous installer runs   run(r'hg -R build-hg --config extensions.purge= purge --all')   run(r'copy misc\setup.cfg build-hg')   run_python(r'setup.py --version', 'build-hg')   run_python(r'setup.py build_py -c -d . build_mo', 'build-hg')   run_python(r'setup.py build_ext -i', 'build-hg', env=get_sdkenv(arch))     generate_hgext_index(branch)     # Build man pages   pipetofile((sys.executable, 'gendoc.py'),   'build-hg/doc/hg.1.gendoc.txt',   'build-hg/doc')     cmd = 'runrst html'   cmdtemplate = r'%s --link-stylesheet --stylesheet-path style.css %s %s'   manfiles = ('hg.1.txt', 'hgignore.5.txt', 'hgrc.5.txt')   for man in manfiles:   outfile = man[:-3] + 'html'   run_python(cmdtemplate % (cmd, man, outfile), 'build-hg/doc')    pwd = None  if '--cert' in sys.argv:   # Seed the password at startup   pwd = getpass.getpass('password for signing: ')    def sign(file, desc, cwd):   global pwd   while True:   try:   if not pwd:   pwd = getpass.getpass('password for signing: ')   run(r'..\misc\sign.cmd %s %s %s "%s"' % (cert, pwd, file, desc),   cwd, hide=True)   return   except StandardError:   pwd = None      def build_hg_installer(name, arch):   version = repoversion('build-hg/mercurial/__version__.py')   comments = 'Installs Mercurial version %s' % version   version = '.'.join(windowsversion(name, version))   if not onlymsi:   run_python(r'setup.py py2exe -b3', 'build-hg', env=get_sdkenv(arch))   if cert is not None:   print "signing using cert '%s'" % (cert,)   desc = '%s %s' % (name, version)   sign(r'dist\hg.exe', desc, 'build-hg') - package = r'..\output\%s-%s-%s.msi' % (name, version, arch) + package = r'..\..\output\%s-%s-%s.msi' % (name, version, arch)   wixobj = [   (r'..\build-hg\contrib\wix\help.wxs', r'..\build-hg\mercurial\help'),   (r'..\build-hg\contrib\wix\templates.wxs', r'..\build-hg\mercurial\templates'),   (r'..\build-hg\contrib\wix\locale.wxs', r'..\build-hg\mercurial\locale'),   (r'..\build-hg\contrib\wix\i18n.wxs', r'..\build-hg\i18n'),   (r'..\build-hg\contrib\wix\doc.wxs', r'..\build-hg\doc'),   (r'..\build-hg\contrib\wix\dist.wxs', r'..\build-hg\dist'),   (r'..\build-hg\contrib\wix\contrib.wxs', r'..\build-hg\contrib')]   for file, sourcedir in wixobj:   candle(file, sourcedir=sourcedir, cwd='build-hg', defines=[('Platform', arch)]) - candle(r'..\hg-main\contrib\wix\mercurial.wxs', cwd='build-hg', defines=[ + candle(r'..\build-hg\contrib\wix\mercurial.wxs', cwd='build-hg', defines=[   ('Platform', arch),   ('Version', version),   ('Comments', comments),   ('VCRedistSrcDir', win7sdk + r'\Redist\VC')])   light(package, 'build-hg', 'help', 'templates', 'locale', 'i18n', 'doc',   'contrib', 'dist', 'mercurial')   if cert is not None:   print "signing using cert '%s'" % (cert,)   desc = '%s %s' % (name, version)   sign(package, desc, 'build-hg')    def build_thg(force, branch, tag, name, productid, arch):   if onlymsi:   return     if force or not os.path.exists('build-thg'):   run(r'if exist build-thg rmdir /s /q build-thg') - run(r'hg clone file:thg -u %s file:build-thg' % branch) + run(r'hg clone file:../thg -u %s file:build-thg' % branch)   else: - run(r'hg pull ../thg', 'build-thg') + run(r'hg pull ../../thg', 'build-thg')   run(r'hg update ' + branch, 'build-thg')   if tag == 'tip':   run(r'hg update', 'build-thg')   else:   run(r'hg update ' + tag, 'build-thg')     # Clear files added by previous installer runs   run(r'hg -R build-thg --config extensions.purge= purge --all')     run_python(r'setup.py --version', 'build-thg')   # Build locales   run_python(r'setup.py build_mo', 'build-thg')   # Build cmenu translation registry files   run_python(r'reggen.py', 'build-thg/win32')   # Use build helpers from win32   run(r'copy win32\config.py tortoisehg\util', 'build-thg')   run(r'copy win32\setup.cfg .', 'build-thg')   # Copy bundled Mercurial extensions into build-hg/hgext   for ext in extensions:   for loc in extfiles.get(ext, []): + loc = '../' + loc   if os.path.exists(loc):   shutil.copy(loc, 'build-hg/hgext')   if ext == 'hgcr-gui': - shutil.copy('hgcr-gui/hgcr.ui', 'build-thg/tortoisehg/hgqt') + shutil.copy('../hgcr-gui/hgcr.ui', 'build-thg/tortoisehg/hgqt')     generate_hgext_index(branch)     # Build docs   run(r'build chm', 'build-thg/doc')   run(r'build pdf', 'build-thg/doc')     # compile all Mercurial extensions that have C++ Python extensions   for ext in extensions:   if ext in compiled_extensions: + ext = '../' + ext   run(r'hg --config extensions.purge= purge --all', ext)   run_python(r'setup.py build_ext -i', ext, env=get_sdkenv(arch))     # Build x64 and x86 shell extensions   hgversion = repoversion('build-hg/mercurial/__version__.py')   hgperiodic = windowsversion(name, hgversion)[2]   thgversion = repoversion('build-thg/tortoisehg/util/__version__.py')   v = windowsversion(name, thgversion)   if 'stable' in name:   v.append(hgperiodic)   thgversion = '.'.join(v)   a, b, c, d = v   else:   thgversion = '.'.join(v)   a, b, c = v     def compile_shell_ext(arch):   print '*************** %s ******************' % arch   env = get_sdkenv(arch).copy()   env['DEBUG'] = '1'   env['THG_PLATFORM'] = arch   env['THG_EXTRA_CPPFLAGS'] = '/DTHG_PRODUCT_ID=%s' % productid   env['THG_EXTRA_RCFLAGS'] = (   '/dTHG_VERSION_FIRST=%s /dTHG_VERSION_SECOND=%s /dTHG_VERSION_THIRD=%s /dTHG_PRODUCT_ID="%s"' %   (a, b, c, productid))   targetdir = r'build-thg\win32'   builddir = targetdir + r'\shellext'   run('nmake.exe /nologo /f Makefile.nmake clean', builddir, env=env)   run('nmake.exe /nologo /f Makefile.nmake', builddir, env=env)   for file in ('ThgShell%s.dll', 'terminate-%s.exe', 'terminate-%s.dll'):   f = file % arch   try:   shutil.copy(builddir + '\\' + f, targetdir)   except IOError:   print "warning: skipped copying nonexistent '%s'" % f   pass     if cert is not None:   print "signing using cert '%s'" % (cert,)   package = r'win32\ThgShell%s.dll' % arch   desc = "%s %s %s shell extension" % (name, arch, thgversion)   sign(package, desc, 'build-thg')     if arch == 'x86':   compile_shell_ext(arch)   else:   compile_shell_ext('x86')   compile_shell_ext('x64')      def build_thg_docs():   run(r'build clean', r'thg\doc')   run(r'build chm', r'thg\doc')   run(r'build pdf', r'thg\doc')      def build_thg_installer(name, productid, arch):   if not onlymsi:   run(r'if exist dist rmdir /s /q dist', 'build-thg')   run_python(r'setup.py py2exe -b3', 'build-thg', env=get_pruned_env(arch))     path = os.path.join(sys.exec_prefix, 'lib', 'site-packages', 'PyQt4')   binpath = os.path.join(path, 'bin')   if os.path.exists(binpath):   path = binpath   for f in ('qscintilla2.dll', 'QtSvg4.dll', 'QtXml4.dll'):   p = os.path.join(path, f)   run(r'copy %s dist' % p, r'build-thg')     hgversion = repoversion('build-hg/mercurial/__version__.py')   hgperiodic = windowsversion(name, hgversion)[2]   longthgversion = repoversion('build-thg/tortoisehg/util/__version__.py')   v = windowsversion(name, longthgversion)   if 'stable' in name:   v.append(hgperiodic)   thgversion = '.'.join(v)     if not onlymsi and cert is not None:   print "signing using cert '%s'" % (cert,)   desc = 'TortoiseHg %s' % thgversion   for exe in ('hg', 'thg', 'thgw', 'TortoiseHgOverlayServer'):   package = r'dist\%s.exe' % exe   if os.path.exists('build-thg\\' + package):   sign(package, desc, 'build-thg')     wixobj = [   (r'..\misc\diff-scripts.wxs', r'..\contrib\diff-scripts'),   (r'win32\wix\dist.wxs', r'dist'),   (r'win32\wix\icons.wxs', r'dist/icons'),   (r'win32\wix\thg-locale.wxs', r'locale'),   (r'win32\wix\thg-i18n.wxs', r'i18n'),   (r'win32\wix\cmenu-i18n.wxs', r'win32'),   (r'win32\wix\help.wxs', r'..\build-hg\mercurial\help'),   (r'win32\wix\templates.wxs', r'..\build-hg\mercurial\templates'),   (r'win32\wix\locale.wxs', r'..\build-hg\mercurial\locale'),   (r'win32\wix\i18n.wxs', r'..\build-hg\i18n'),   (r'win32\wix\doc.wxs', r'..\build-hg\doc'),   (r'win32\wix\contrib.wxs', r'..\build-hg\contrib')]   defs = [('Platform', arch)]   for file, sourcedir in wixobj:   candle(file, sourcedir=sourcedir, cwd='build-thg', defines=defs)   - package = "..\output\%s-%s" % (name, thgversion) + package = r"..\..\output\%s-%s" % (name, thgversion)   commentsfmt = 'Installs TortoiseHg %s, Mercurial %s on %s'   comments = commentsfmt % (longthgversion, hgversion, arch)   productid = productid.lower()   defines = [('Version', thgversion),   ('ProductId', productid),   ('Platform', arch),   ('Comments', comments),   ('VCRedistSrcDir', win7sdk + r'\Redist\VC')]   candle(r'win32\wix\tortoisehg.wxs', cwd='build-thg', defines=defines)   m = hashlib.sha1()   m.update(comments)   m.update(productid)   msifile = '%s-%s-%s.msi' % (package, arch, m.hexdigest()[:12])   light(msifile, 'build-thg', 'help', 'templates', 'locale', 'i18n',   'doc', 'contrib', 'diff-scripts', 'icons', 'thg-locale',   'dist', 'thg-i18n', 'cmenu-i18n', 'tortoisehg')   if cert is not None:   print "signing using cert '%s'" % (cert,)   desc = '%s %s %s' % (name, arch, thgversion)   sign(msifile, desc, 'build-thg')      def try_paths(paths):   for env in ('ProgramFiles', 'ProgramFiles(x86)', 'ProgramW6432'):   if env not in installenv: continue   prefix = installenv[env]   for file in paths:   candidate = prefix + file   if os.path.exists(candidate):   return candidate   else:   return None      def verify_hg_env():   global installenv   global win7sdk     win7sdk = try_paths([r'\Microsoft SDKs\Windows\v7.0\Bin'])   if not win7sdk:   print 'Unable to find Microsoft Windows SDK 7.0, please install'   sys.exit(1)   win7sdk = win7sdk[:-4]     try:   from mercurial import hg, ui, util   except ImportError:   print 'Mercurial must be installed as Python source.'   print 'You can get this from http://bitbucket.org/tortoisehg/thg-winbuild/downloads/'   print 'Look for a package like: mercurial-1.6.2.win32-py2.6.exe\n'   print 'Or simply build it yourself.'   sys.exit(1)     try:   import py2exe   except ImportError:   print 'Unable to find py2exe'   print 'http://sourceforge.net/projects/py2exe/'   sys.exit(1)     try:   import win32api   except ImportError:   print 'Unable to find pywin32'   print 'http://sourceforge.net/projects/pywin32/'   sys.exit(1)     path = installenv.get('PATH', '').split(os.pathsep)   scrpath = sys.exec_prefix + os.sep + 'Scripts'   path.append(scrpath)     if not os.path.exists(os.path.join(scrpath, 'rst2html.py')):   print 'Unable to find rst2html'   print 'easy_install docutils'   sys.exit(1)     msgfmt = find_executable('msgfmt')   if not msgfmt:   found = try_paths([r'\GnuWin32\bin\msgfmt.exe'])   if found:   path.append(os.path.dirname(found))   else: - print 'Unable to find msgfmt. Please download from' - print 'http://gnuwin32.sourceforge.net/packages/gettext.htm' - sys.exit(1) + if os.path.exists(r'\MinGW\bin\msgfmt.exe'): + path.append(r'\MinGW\bin') + else: + print 'Unable to find msgfmt. Please download from' + print 'http://gnuwin32.sourceforge.net/packages/gettext.htm' + sys.exit(1)     if 'WIX' in installenv:   path.append(installenv['WIX'] + 'bin')   else:   print 'Unable to find WIX. Please download from'   print 'http://sourceforge.net/projects/wix/files/'   sys.exit(1)     installenv['HGPLAIN'] = '1'   installenv['PATH'] = os.pathsep.join(path)   installenv['DISTUTILS_USE_SDK'] = '1'   installenv['hhc_compiler'] = 'hhc.exe'    def verify_doc_env():   global installenv     try:   from mercurial import hg, ui, util   except ImportError:   print 'Mercurial must be installed as Python source.'   print 'You can get this from http://bitbucket.org/tortoisehg/thg-winbuild/downloads/'   print 'Look for a package like: mercurial-1.6.2.win32-py2.6.exe\n'   print 'Or simply build it yourself.'   sys.exit(1)     path = installenv.get('PATH', '').split(os.pathsep)   scrpath = os.path.dirname(sys.executable) + os.sep + 'Scripts'   path.append(scrpath)     # Find HTML Help compiler, add to path   hhc = find_executable('hhc')   if not hhc:   found = try_paths([r'\HTML Help Workshop\hhc.exe'])   if found:   path.append(os.path.dirname(found))   else:   print 'Unable to find HTML Help Workshop'   print 'http://go.microsoft.com/fwlink/?LinkId=14188'   sys.exit(1)   # Find MiKTex, add to path   pdflatex = find_executable('pdflatex')   if not pdflatex:   found = try_paths([r'\MiKTeX 2.7\miktex\bin\Pdflatex.exe',   r'\MiKTeX 2.8\miktex\bin\Pdflatex.exe'])   if found:   path.append(os.path.dirname(found))   else:   print 'Unable to find MiKTeX'   print 'http://miktex.org/2.8/setup'   sys.exit(1)   # Verify sphinx   if not os.path.exists(os.path.join(scrpath, 'sphinx-build.exe')):   print 'Unable to find sphinx'   print 'easy_install sphinx'   sys.exit(1)   installenv['PATH'] = os.pathsep.join(path)      def verify_thg_env():   global installenv     try:   from mercurial import hg, ui, util   except ImportError:   print 'Mercurial must be installed as Python source.'   print 'You can get this from http://bitbucket.org/tortoisehg/thg-winbuild/downloads/'   print 'Look for a package like: mercurial-1.6.2.win32-py2.6.exe\n'   print 'Or simply build it yourself.'   sys.exit(1)     try:   import comtypes   except ImportError:   print 'comtypes not found'   print 'download and install comtypes-0.6.2.win32.exe from'   print 'http://sourceforge.net/projects/comtypes/files/'   sys.exit(1)     try:   from svn import core   except ImportError:   print 'svn bindings not found'   print 'See README for download location and install instructions'   sys.exit(1)     oldpath = os.environ.get('PYTHONPATH', '').split(os.pathsep)   path = ['../build-hg']   for ext in extensions:   if ext in path_extensions: - path.append('../' + ext) + path.append('../../' + ext)   path.extend(oldpath)   installenv['PYTHONPATH'] = os.pathsep.join(path)    def usage(code, msg=''):   print >> sys.stderr, __doc__   if msg:   print >> sys.stderr, msg   sys.exit(code)    if len(sys.argv) < 2:   usage(0)    try:   opts, args = getopt.getopt(sys.argv[1:], 'hcfF',   ['clean', 'forcehg', 'forcethg',   'thg-release', 'thg-stable', 'thg-unstable', 'thg-doc',   'hg-release', 'hg-stable', 'hg-unstable',   'pull', 'nopull', 'config', 'all', 'cert=', 'only-msi'])  except getopt.error, msg:   usage(1, msg)    # parse options (first pass)  for opt, arg in opts:   if opt == '--cert':   cert = os.path.abspath(arg)    # parse options (second pass)  for opt, arg in opts:   if opt in ('-h', '--help'):   usage(0)   elif opt in ('-f', '--force-hg'):   forcehg = True   elif opt in ('-F', '--force-thg'):   forcethg = True   elif opt in ('-c', '--clean'):   run(r'if exist build-hg rmdir /s /q build-hg')   run(r'if exist build-thg rmdir /s /q build-thg')   if os.path.exists(sslcertfile):   os.unlink(sslcertfile)   sys.exit(0)   elif opt == '--thg-doc': - checkrepo('thg')   builddoc = True   elif opt == '--thg-release': - for r in thg_source_repos: - checkrepo(r)   if dopull is None:   dopull = True   buildthg = True   thgbranch = 'stable'   thgtag = lasttag('thg', 'stable')   hgbranch = 'stable' - hgtag = lasttag('hg-main', 'stable') + hgtag = lasttag('hg', 'stable')   packagename = 'tortoisehg'   elif opt == '--thg-stable': - for r in thg_source_repos: - checkrepo(r)   if dopull is None:   dopull = True   buildthg = True   thgbranch = 'stable'   thgtag = 'tip'   hgbranch = 'stable'   hgtag = 'tip'   packagename = 'tortoisehg-stable'   elif opt == '--thg-unstable': - for r in thg_source_repos: - checkrepo(r)   if dopull is None:   dopull = True   buildthg = True   thgbranch = 'default'   thgtag = 'tip'   hgbranch = 'default'   hgtag = 'tip'   packagename = 'tortoisehg-unstable'   elif opt == '--hg-release': - checkrepo('hg-main')   buildhg = True   hgbranch = 'stable' - hgtag = lasttag('hg-main', 'stable') + hgtag = lasttag('hg', 'stable')   packagename = 'mercurial'   elif opt == '--hg-stable': - checkrepo('hg-main')   if dopull is None:   dopull = True   buildhg = True   hgbranch = 'stable'   hgtag = 'tip'   packagename = 'mercurial-stable'   elif opt == '--hg-unstable': - checkrepo('hg-main')   if dopull is None:   dopull = True   buildhg = True   hgbranch = 'default'   hgtag = 'tip'   packagename = 'mercurial-unstable'   elif opt == '--pull':   dopull = True   elif opt == '--nopull':   dopull = False   elif opt == '--config':   showconfig = True   elif opt == '--only-msi':   onlymsi = True   elif opt == '--all': - for r in thg_source_repos: - checkrepo(r)   all = True   onlymsi = False   if dopull is None:   dopull = True    print 'Build config:'  print '[tortoisehg] branch=%s, tag=%s' % (thgbranch, thgtag)  print '[mercurial] branch=%s, tag=%s\n' % (hgbranch, hgtag)    if showconfig:   sys.exit(0)    if not os.path.exists(sslcertfile) or all:   print 'fetching cacert.pem from', URL['cacert.pem']   contents = urllib2.urlopen(URL['cacert.pem']).read()   file(sslcertfile, 'wb').write(contents)   -if not os.path.isdir('output'): - run(r'mkdir output') -  if dopull and not onlymsi: - run(r'hg -R hg-main pull') + run(r'hg -R ../hg pull')   if buildthg or all: - run(r'hg -R thg pull') + run(r'hg -R ../thg pull')   from mercurial import ui, hg   out = 'extension-versions.txt'   f = open(out, 'w')   f.write('Extensions/modules included in this TortoiseHg package:\n\n')   for ext in extensions: - run(r'hg -R %s pull' % ext) + run(r'hg -R ../%s pull' % ext)   if ext in extversions: - run(r'hg update %s' % extversions[ext], ext) + run(r'hg update -R ../%s %s' % (ext, extversions[ext]))   else: - run(r'hg update', ext) - repo = hg.repository(ui.ui(), path=ext) + run(r'hg update -R ../' + ext) + repo = hg.repository(ui.ui(), path='../'+ext)   f.write('%12s:\t%s\t%s\n' % (ext, str(repo['.']), URL[ext]))   try:   from svn import core   ver = '%d.%d.%d' % (core.SVN_VER_MAJOR, core.SVN_VER_MINOR, core.SVN_VER_MICRO)   url = 'http://bitbucket.org/tortoisehg/thg/downloads'   f.write('%12s:\t%-12s\t%s\n' % ('python-svn', ver, url))   except ImportError:   pass   try:   import pygments   ver = pygments.__version__   url = 'http://pygments.org/download/'   f.write('%12s:\t%-12s\t%s\n' % ('pygments', ver, url))   except ImportError:   pass   pywin32file = sys.prefix + r'\lib\site-packages\pywin32.version.txt'   if os.path.exists(pywin32file):   ver = open(pywin32file, 'r').read().strip()   url = 'http://sourceforge.net/projects/pywin32/'   f.write('%12s:\t%-12s\t%s\n' % ('pywin32', ver, url)) - repo = hg.repository(ui.ui(), path='.') - f.write('\n\nBuilt with thg-winbuild revision %s\n' % str(repo['.']))   f.close()    if all:   verify_hg_env()   verify_doc_env()   verify_thg_env()   run(r'title Building hg-stable...')   build_hg(True, 'stable', 'tip', arch)   build_hg_installer('mercurial-stable', arch)   run(r'title Building hg-unstable...')   build_hg(False, 'default', 'tip', arch)   build_hg_installer('mercurial-unstable', arch)   run(r'title Building thg-stable...')   productid = str(uuid.uuid4()).upper()   build_hg(False, 'stable', 'tip', arch)   build_thg(True, 'stable', 'tip', 'tortoisehg-stable', productid, arch)   build_thg_installer('tortoisehg-stable', productid, arch)   run(r'title Building thg-unstable...')   productid = str(uuid.uuid4()).upper()   build_hg(False, 'default', 'tip', arch)   build_thg(True, 'default', 'tip', 'tortoisehg-unstable', productid, arch)   build_thg_installer('tortoisehg-unstable', productid, arch)  elif builddoc:   verify_doc_env()   build_thg_docs()  elif buildhg:   verify_hg_env()   build_hg(forcehg, hgbranch, hgtag, arch)   build_hg_installer(packagename, arch)  elif buildthg:   verify_hg_env()   verify_doc_env()   verify_thg_env()   build_hg(forcehg, hgbranch, hgtag, arch)   productid = str(uuid.uuid4()).upper()   build_thg(forcethg, thgbranch, thgtag, packagename, productid, arch)   build_thg_installer(packagename, productid, arch)