Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 0.4rc1, 0.4rc2, and 0.4rc3

remove obsolete files

* simplemerge is now built into Mercurial
* source installer is dead, was never released
* hgutils/guishell.py is no longer needed

Changeset f6b9025698e8

Parent ef7169f286ec

by Steve Borho

Changes to 8 files · Browse files at f6b9025698e8 Showing diff from parent ef7169f286ec Diff from another changeset...

Change 1 of 2 Show Entire File hgproc.py Stacked
 
7
8
9
10
 
11
12
13
 
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
 
7
8
9
 
10
11
12
13
 
97
98
99
 
 
 
 
 
 
 
 
 
 
100
101
102
@@ -7,7 +7,7 @@
 import os  import sys  from mercurial import ui -from tortoise.thgutil import find_path, get_prog_root, shellquote +from tortoise.thgutil import get_prog_root    # always use hg exe installed with TortoiseHg  thgdir = get_prog_root() @@ -97,16 +97,6 @@
  cmdline.extend(option['files'])   option['cmdline'] = cmdline   - # Failsafe choice for merge tool - if os.environ.get('HGMERGE', None): - pass - elif ui.ui().config('ui', 'merge', None): - pass - else: - path = find_path('simplemerge') or 'simplemerge' - os.environ['HGMERGE'] = '%s -L my -L other' % shellquote(path) - print "override HGMERGE =", os.environ['HGMERGE'] -   global _dialogs   dialog = _dialogs.get(option['hgcmd'], hgcmd)   dialog.run(**option)
Change 1 of 1 Show Entire File hgutils/​guishell.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
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
@@ -1,155 +0,0 @@
-""" -Execute a Mercurial (Hg) command and show it's output on the Tkinter window. - -Based on the recipe post on ActiveState Programmer Network, titled -'Threads, Tkinter and asynchronous I/O': - - http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/82965 - -Copyright (c) 2007 TK Soh - -email: teekaysoh@yahoo.com - teekaysoh@gmail.com - -""" -import sys, subprocess -from Tkinter import * -import ScrolledText -import threading -import Queue -import time - -class GuiPart: - def __init__(self, master, queue, endCommand): - self.queue = queue - - # === Set up the GUI === - - # show user commands - frame = Frame(master) - frame.pack(side=TOP, fill='x', padx=2, pady=2) - lbl1 = Label(frame, text='Command:') - lbl1.pack(side=LEFT) - self.cmdtext = Text(frame, heigh=1) - self.cmdtext.pack(side=RIGHT, fill='x', expand=1) - - # text widget to display output message from hg commands - self.outtext = ScrolledText.ScrolledText(master) - self.outtext.config(font="Courier 8") - self.outtext.pack(side=TOP, fill='both', expand=1) - - # click this to exit - console = Button(master, text='Close', command=endCommand) - console.pack(pady=5, side=BOTTOM) - - def setCommandText(self, cmd): - self.cmdtext.config(state=NORMAL) - self.cmdtext.insert(END, ' '.join(cmd)) - self.cmdtext.config(state=DISABLED) - - def processIncoming(self): - """ - Handle all the messages currently in the queue (if any). - """ - while self.queue.qsize(): - try: - msg = self.queue.get(0) - - # show hg command output on text widget (readonly) - self.outtext.config(state=NORMAL) - self.outtext.insert(END, str(msg)) - self.outtext.config(state=DISABLED) - except Queue.Empty: - pass - -class ThreadedClient: - """ - Launch the main part of the GUI and the worker thread. periodicCall and - endApplication could reside in the GUI part, but putting them here - means that you have all the thread controls in a single place. - """ - def __init__(self, master, cmd): - """ - Start the GUI and the asynchronous threads. We are in the main - (original) thread of the application, which will later be used by - the GUI. We spawn a new thread for the worker. - """ - self.master = master - self.pop = None - - # Create the queue - self.queue = Queue.Queue() - - # Set up the GUI part - self.gui = GuiPart(master, self.queue, self.endApplication) - self.gui.setCommandText(cmd) - - # Set up the thread to do asynchronous I/O - # More can be made if necessary - self.running = 1 - self.cmdline = cmd - self.thread1 = threading.Thread(target=self.runProgram) - self.thread1.start() - - # Start the periodic call in the GUI to check if the queue contains - # anything - self.periodicCall() - - def periodicCall(self): - """ - Check every 100 ms if there is something new in the queue. - """ - self.gui.processIncoming() - if not self.running: - # This is the brutal stop of the system. You may want to do - # some cleanup before actually shutting it down. - if self.pop and self.pop.poll(): - import os - pid = self.pop.pid - if os.name == 'nt': - import win32api - handle = win32api.OpenProcess(1, 0, pid) - win32api.TerminateProcess(handle, 0) - else: - import signal - os.kill(pid, signal.SIGINT) - print "killed pid: ", pid - import sys - sys.exit(1) - self.master.after(100, self.periodicCall) - - def runProgram(self): - #print "runProgram:", self.cmdline - self.pop = subprocess.Popen(self.cmdline, - shell=True, - stderr=subprocess.STDOUT, - stdout=subprocess.PIPE, - stdin=subprocess.PIPE) - - try: - #print "checking popen" - while self.pop.poll() == None: - #print "reading pop" - out = self.pop.stdout.readline() - if out: self.queue.put(out) - #time.sleep(0.001) - #print "popen closed" - out = self.pop.stdout.read() - if out: self.queue.put(out) - except IOError: - pass - - self.pop = None - #print "done runProgram" - - def endApplication(self): - self.running = 0 - -if __name__ == "__main__": - if len(sys.argv) < 2: - print "need commands" - sys.exit(1) - - root = Tk() - client = ThreadedClient(root, sys.argv[1:]) - root.mainloop()
Change 1 of 1 Show Entire File hgutils/​simplemerge 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
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
@@ -1,562 +0,0 @@
-#!/usr/bin/env python -# Copyright (C) 2004, 2005 Canonical Ltd -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - -# mbp: "you know that thing where cvs gives you conflict markers?" -# s: "i hate that." - -from mercurial import demandimport -demandimport.enable() - -from mercurial import util, mdiff, fancyopts -from mercurial.i18n import _ - - -class CantReprocessAndShowBase(Exception): - pass - - -def warn(message): - sys.stdout.flush() - sys.stderr.write(message) - sys.stderr.flush() - - -def intersect(ra, rb): - """Given two ranges return the range where they intersect or None. - - >>> intersect((0, 10), (0, 6)) - (0, 6) - >>> intersect((0, 10), (5, 15)) - (5, 10) - >>> intersect((0, 10), (10, 15)) - >>> intersect((0, 9), (10, 15)) - >>> intersect((0, 9), (7, 15)) - (7, 9) - """ - assert ra[0] <= ra[1] - assert rb[0] <= rb[1] - - sa = max(ra[0], rb[0]) - sb = min(ra[1], rb[1]) - if sa < sb: - return sa, sb - else: - return None - - -def compare_range(a, astart, aend, b, bstart, bend): - """Compare a[astart:aend] == b[bstart:bend], without slicing. - """ - if (aend-astart) != (bend-bstart): - return False - for ia, ib in zip(xrange(astart, aend), xrange(bstart, bend)): - if a[ia] != b[ib]: - return False - else: - return True - - - - -class Merge3Text(object): - """3-way merge of texts. - - Given strings BASE, OTHER, THIS, tries to produce a combined text - incorporating the changes from both BASE->OTHER and BASE->THIS.""" - def __init__(self, basetext, atext, btext, base=None, a=None, b=None): - self.basetext = basetext - self.atext = atext - self.btext = btext - if base is None: - base = mdiff.splitnewlines(basetext) - if a is None: - a = mdiff.splitnewlines(atext) - if b is None: - b = mdiff.splitnewlines(btext) - self.base = base - self.a = a - self.b = b - - - - def merge_lines(self, - name_a=None, - name_b=None, - name_base=None, - start_marker='<<<<<<<', - mid_marker='=======', - end_marker='>>>>>>>', - base_marker=None, - reprocess=False): - """Return merge in cvs-like form. - """ - self.conflicts = False - newline = '\n' - if len(self.a) > 0: - if self.a[0].endswith('\r\n'): - newline = '\r\n' - elif self.a[0].endswith('\r'): - newline = '\r' - if base_marker and reprocess: - raise CantReprocessAndShowBase() - if name_a: - start_marker = start_marker + ' ' + name_a - if name_b: - end_marker = end_marker + ' ' + name_b - if name_base and base_marker: - base_marker = base_marker + ' ' + name_base - merge_regions = self.merge_regions() - if reprocess is True: - merge_regions = self.reprocess_merge_regions(merge_regions) - for t in merge_regions: - what = t[0] - if what == 'unchanged': - for i in range(t[1], t[2]): - yield self.base[i] - elif what == 'a' or what == 'same': - for i in range(t[1], t[2]): - yield self.a[i] - elif what == 'b': - for i in range(t[1], t[2]): - yield self.b[i] - elif what == 'conflict': - self.conflicts = True - yield start_marker + newline - for i in range(t[3], t[4]): - yield self.a[i] - if base_marker is not None: - yield base_marker + newline - for i in range(t[1], t[2]): - yield self.base[i] - yield mid_marker + newline - for i in range(t[5], t[6]): - yield self.b[i] - yield end_marker + newline - else: - raise ValueError(what) - - - - - - def merge_annotated(self): - """Return merge with conflicts, showing origin of lines. - - Most useful for debugging merge. - """ - for t in self.merge_regions(): - what = t[0] - if what == 'unchanged': - for i in range(t[1], t[2]): - yield 'u | ' + self.base[i] - elif what == 'a' or what == 'same': - for i in range(t[1], t[2]): - yield what[0] + ' | ' + self.a[i] - elif what == 'b': - for i in range(t[1], t[2]): - yield 'b | ' + self.b[i] - elif what == 'conflict': - yield '<<<<\n' - for i in range(t[3], t[4]): - yield 'A | ' + self.a[i] - yield '----\n' - for i in range(t[5], t[6]): - yield 'B | ' + self.b[i] - yield '>>>>\n' - else: - raise ValueError(what) - - - - - - def merge_groups(self): - """Yield sequence of line groups. Each one is a tuple: - - 'unchanged', lines - Lines unchanged from base - - 'a', lines - Lines taken from a - - 'same', lines - Lines taken from a (and equal to b) - - 'b', lines - Lines taken from b - - 'conflict', base_lines, a_lines, b_lines - Lines from base were changed to either a or b and conflict. - """ - for t in self.merge_regions(): - what = t[0] - if what == 'unchanged': - yield what, self.base[t[1]:t[2]] - elif what == 'a' or what == 'same': - yield what, self.a[t[1]:t[2]] - elif what == 'b': - yield what, self.b[t[1]:t[2]] - elif what == 'conflict': - yield (what, - self.base[t[1]:t[2]], - self.a[t[3]:t[4]], - self.b[t[5]:t[6]]) - else: - raise ValueError(what) - - - def merge_regions(self): - """Return sequences of matching and conflicting regions. - - This returns tuples, where the first value says what kind we - have: - - 'unchanged', start, end - Take a region of base[start:end] - - 'same', astart, aend - b and a are different from base but give the same result - - 'a', start, end - Non-clashing insertion from a[start:end] - - Method is as follows: - - The two sequences align only on regions which match the base - and both descendents. These are found by doing a two-way diff - of each one against the base, and then finding the - intersections between those regions. These "sync regions" - are by definition unchanged in both and easily dealt with. - - The regions in between can be in any of three cases: - conflicted, or changed on only one side. - """ - - # section a[0:ia] has been disposed of, etc - iz = ia = ib = 0 - - for zmatch, zend, amatch, aend, bmatch, bend in self.find_sync_regions(): - #print 'match base [%d:%d]' % (zmatch, zend) - - matchlen = zend - zmatch - assert matchlen >= 0 - assert matchlen == (aend - amatch) - assert matchlen == (bend - bmatch) - - len_a = amatch - ia - len_b = bmatch - ib - len_base = zmatch - iz - assert len_a >= 0 - assert len_b >= 0 - assert len_base >= 0 - - #print 'unmatched a=%d, b=%d' % (len_a, len_b) - - if len_a or len_b: - # try to avoid actually slicing the lists - equal_a = compare_range(self.a, ia, amatch, - self.base, iz, zmatch) - equal_b = compare_range(self.b, ib, bmatch, - self.base, iz, zmatch) - same = compare_range(self.a, ia, amatch, - self.b, ib, bmatch) - - if same: - yield 'same', ia, amatch - elif equal_a and not equal_b: - yield 'b', ib, bmatch - elif equal_b and not equal_a: - yield 'a', ia, amatch - elif not equal_a and not equal_b: - yield 'conflict', iz, zmatch, ia, amatch, ib, bmatch - else: - raise AssertionError("can't handle a=b=base but unmatched") - - ia = amatch - ib = bmatch - iz = zmatch - - # if the same part of the base was deleted on both sides - # that's OK, we can just skip it. - - - if matchlen > 0: - assert ia == amatch - assert ib == bmatch - assert iz == zmatch - - yield 'unchanged', zmatch, zend - iz = zend - ia = aend - ib = bend - - - def reprocess_merge_regions(self, merge_regions): - """Where there are conflict regions, remove the agreed lines. - - Lines where both A and B have made the same changes are - eliminated. - """ - for region in merge_regions: - if region[0] != "conflict": - yield region - continue - type, iz, zmatch, ia, amatch, ib, bmatch = region - a_region = self.a[ia:amatch] - b_region = self.b[ib:bmatch] - matches = mdiff.get_matching_blocks(''.join(a_region), - ''.join(b_region)) - next_a = ia - next_b = ib - for region_ia, region_ib, region_len in matches[:-1]: - region_ia += ia - region_ib += ib - reg = self.mismatch_region(next_a, region_ia, next_b, - region_ib) - if reg is not None: - yield reg - yield 'same', region_ia, region_len+region_ia - next_a = region_ia + region_len - next_b = region_ib + region_len - reg = self.mismatch_region(next_a, amatch, next_b, bmatch) - if reg is not None: - yield reg - - - def mismatch_region(next_a, region_ia, next_b, region_ib): - if next_a < region_ia or next_b < region_ib: - return 'conflict', None, None, next_a, region_ia, next_b, region_ib - mismatch_region = staticmethod(mismatch_region) - - - def find_sync_regions(self): - """Return a list of sync regions, where both descendents match the base. - - Generates a list of (base1, base2, a1, a2, b1, b2). There is - always a zero-length sync region at the end of all the files. - """ - - ia = ib = 0 - amatches = mdiff.get_matching_blocks(self.basetext, self.atext) - bmatches = mdiff.get_matching_blocks(self.basetext, self.btext) - len_a = len(amatches) - len_b = len(bmatches) - - sl = [] - - while ia < len_a and ib < len_b: - abase, amatch, alen = amatches[ia] - bbase, bmatch, blen = bmatches[ib] - - # there is an unconflicted block at i; how long does it - # extend? until whichever one ends earlier. - i = intersect((abase, abase+alen), (bbase, bbase+blen)) - if i: - intbase = i[0] - intend = i[1] - intlen = intend - intbase - - # found a match of base[i[0], i[1]]; this may be less than - # the region that matches in either one - assert intlen <= alen - assert intlen <= blen - assert abase <= intbase - assert bbase <= intbase - - asub = amatch + (intbase - abase) - bsub = bmatch + (intbase - bbase) - aend = asub + intlen - bend = bsub + intlen - - assert self.base[intbase:intend] == self.a[asub:aend], \ - (self.base[intbase:intend], self.a[asub:aend]) - - assert self.base[intbase:intend] == self.b[bsub:bend] - - sl.append((intbase, intend, - asub, aend, - bsub, bend)) - - # advance whichever one ends first in the base text - if (abase + alen) < (bbase + blen): - ia += 1 - else: - ib += 1 - - intbase = len(self.base) - abase = len(self.a) - bbase = len(self.b) - sl.append((intbase, intbase, abase, abase, bbase, bbase)) - - return sl - - - - def find_unconflicted(self): - """Return a list of ranges in base that are not conflicted.""" - am = mdiff.get_matching_blocks(self.basetext, self.atext) - bm = mdiff.get_matching_blocks(self.basetext, self.btext) - - unc = [] - - while am and bm: - # there is an unconflicted block at i; how long does it - # extend? until whichever one ends earlier. - a1 = am[0][0] - a2 = a1 + am[0][2] - b1 = bm[0][0] - b2 = b1 + bm[0][2] - i = intersect((a1, a2), (b1, b2)) - if i: - unc.append(i) - - if a2 < b2: - del am[0] - else: - del bm[0] - - return unc - - -# bzr compatible interface, for the tests -class Merge3(Merge3Text): - """3-way merge of texts. - - Given BASE, OTHER, THIS, tries to produce a combined text - incorporating the changes from both BASE->OTHER and BASE->THIS. - All three will typically be sequences of lines.""" - def __init__(self, base, a, b): - basetext = '\n'.join([i.strip('\n') for i in base] + ['']) - atext = '\n'.join([i.strip('\n') for i in a] + ['']) - btext = '\n'.join([i.strip('\n') for i in b] + ['']) - if util.binary(basetext) or util.binary(atext) or util.binary(btext): - raise util.Abort(_("don't know how to merge binary files")) - Merge3Text.__init__(self, basetext, atext, btext, base, a, b) - - -def simplemerge(local, base, other, **opts): - def readfile(filename): - f = open(filename, "rb") - text = f.read() - f.close() - if util.binary(text): - msg = _("%s looks like a binary file.") % filename - if not opts.get('text'): - raise util.Abort(msg) - elif not opts.get('quiet'): - warn(_('warning: %s\n') % msg) - return text - - name_a = local - name_b = other - labels = opts.get('label', []) - if labels: - name_a = labels.pop(0) - if labels: - name_b = labels.pop(0) - if labels: - raise util.Abort(_("can only specify two labels.")) - - localtext = readfile(local) - basetext = readfile(base) - othertext = readfile(other) - - orig = local - local = os.path.realpath(local) - if not opts.get('print'): - opener = util.opener(os.path.dirname(local)) - out = opener(os.path.basename(local), "w", atomictemp=True) - else: - out = sys.stdout - - reprocess = not opts.get('no_minimal') - - m3 = Merge3Text(basetext, localtext, othertext) - for line in m3.merge_lines(name_a=name_a, name_b=name_b, - reprocess=reprocess): - out.write(line) - - if not opts.get('print'): - out.rename() - - if m3.conflicts: - if not opts.get('quiet'): - warn(_("warning: conflicts during merge.\n")) - return 1 - -options = [('L', 'label', [], _('labels to use on conflict markers')), - ('a', 'text', None, _('treat all files as text')), - ('p', 'print', None, - _('print results instead of overwriting LOCAL')), - ('', 'no-minimal', None, - _('do not try to minimize conflict regions')), - ('h', 'help', None, _('display help and exit')), - ('q', 'quiet', None, _('suppress output'))] - -usage = _('''simplemerge [OPTS] LOCAL BASE OTHER - - Simple three-way file merge utility with a minimal feature set. - - Apply to LOCAL the changes necessary to go from BASE to OTHER. - - By default, LOCAL is overwritten with the results of this operation. -''') - -def showhelp(): - sys.stdout.write(usage) - sys.stdout.write('\noptions:\n') - - out_opts = [] - for shortopt, longopt, default, desc in options: - out_opts.append(('%2s%s' % (shortopt and '-%s' % shortopt, - longopt and ' --%s' % longopt), - '%s' % desc)) - opts_len = max([len(opt[0]) for opt in out_opts]) - for first, second in out_opts: - sys.stdout.write(' %-*s %s\n' % (opts_len, first, second)) - -class ParseError(Exception): - """Exception raised on errors in parsing the command line.""" - -def main(argv): - try: - opts = {} - try: - args = fancyopts.fancyopts(argv[1:], options, opts) - except fancyopts.getopt.GetoptError, e: - raise ParseError(e) - if opts['help']: - showhelp() - return 0 - if len(args) != 3: - raise ParseError(_('wrong number of arguments')) - return simplemerge(*args, **opts) - except ParseError, e: - sys.stdout.write("%s: %s\n" % (sys.argv[0], e)) - showhelp() - return 1 - except util.Abort, e: - sys.stderr.write("abort: %s\n" % e) - return 255 - except KeyboardInterrupt: - return 255 - -if __name__ == '__main__': - import sys - import os - sys.exit(main(sys.argv))
Change 1 of 1 Show Entire File installer/​thg_postinstall.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
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
@@ -1,32 +0,0 @@
-# Post-install script for TortoiseHg Windows source installer -# Will run after all the file have been copied in place with '-install' -# and before files have been removed with '-uninstall' - -import os, shutil, sys, subprocess - -# Run tortoisehg.py script to register COM server and set registry key -scrpath = os.path.dirname(sys.argv[0]) # C:\Python25\Scripts -pyexe = os.path.abspath(os.path.join(scrpath, '..', 'python.exe')) -thgpath = os.path.abspath(os.path.join(scrpath, '..', 'share', 'tortoisehg')) -scr = os.path.join(thgpath, 'tortoisehg.py') - -if sys.argv[1] == '-install': - subprocess.call([pyexe, scr, '--register']) - exe = os.path.join(scrpath, 'hg.exe') - bat = os.path.join(scrpath, 'hg.bat') - if os.path.exists(exe): - tgt = os.path.join(thgpath, 'hg.exe') - shutil.copy2(exe, tgt) - file_created(tgt) - exe = os.path.join(scrpath, 'hg-script.py') - tgt = os.path.join(thgpath, 'hg-script.py') - shutil.copy2(exe, tgt) - file_created(tgt) - elif os.path.exists(bat): - tgt = os.path.join(thgpath, 'hg.bat') - shutil.copy2(bat, tgt) - file_created(tgt) - print 'You must restart your machine for changes to take effect.' -elif sys.argv[1] == '-remove': - subprocess.call([pyexe, scr, '--unregister']) - print 'You must restart your machine to complete the uninstallation.'
Change 1 of 1 Show Entire File installer/​tortoisehg.rc 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
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
@@ -1,28 +0,0 @@
-; Configuration file for TortoiseHg Windows COM Server -; This is intended to be copied into your system wide configuration -; directory (C:\Python25\Mercurial\hgrc.d) or to be appended to your -; system wide configuration file (C:\Program Files\Mercurial\Mercurial.ini) - -[tortoisehg] -; -; Favorite commit tool. Options 'qct', 'internal' -commit = qct -; -; Favorite history browser. Options 'hgk', 'hgview' -view = hgk -; -; Visual diff command. Requires extdiff extension to be configured -vdiff = vdiff -; -; Visual editor launched by TortoiseHg to view files -;editor = notepad++ -; -; Color changeset rows in history viewer by author name -authorcolor = False -; -; Specify color for particular person (can be regexp) -; authorcolor.person = color -; -; Number of revisions to parse in a batch. The graphing algorithms in -; the history viewer operate on batches of changesets at a time. -graphlimit = 500
Change 1 of 1 Show Entire File installer/​tracelog.bat Stacked
 
1
2
3
4
5
6
7
8
 
 
 
 
 
 
 
 
 
@@ -1,8 +0,0 @@
-@echo off -rem =""" -python -x %~f0 %* -exit 0 -""" -# -------------------- Python section -------------------- -from hggtk import tracelog -tracelog.run()
Change 1 of 3 Show Entire File setup.py Stacked
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
 
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
 
73
74
75
 
99
100
101
102
 
103
104
105
 
1
2
 
3
4
5
6
7
 
 
 
 
8
9
10
 
48
49
50
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
51
52
53
54
 
78
79
80
 
81
82
83
84
@@ -1,15 +1,10 @@
 # setup.py  # A distutils setup script to register TortoiseHg COM server -#    # To build stand-alone package, use 'python setup.py py2exe' then use  # InnoSetup to build the installer. By default, the installer will be  # created as dist\Output\setup.exe.   -# To build a source installer for use with the Mercurial NSI -# installer, use -# 'python setup.py bdist_wininst --install-script=thg_postinstall.py' -  import time  import sys  import os @@ -53,23 +48,7 @@
  "icon_resources": [(1, "icons/tortoise/python.ico")]}   ]   extra['com_server'] = ["tortoisehg"] - extra['console'] = ["contrib/hg", "hgutils/simplemerge"] - -elif 'bdist_msi' in sys.argv or 'bdist_wininst' in sys.argv: - # C:\Python25\share\tortoisehg\icons\... - _data_files = [(os.path.join('share/tortoisehg', root), - [os.path.join(root, file_) for file_ in files]) - for root, dirs, files in os.walk('icons')] - - # C:\Python25\share\tortoisehg\*.bat, *.py - _data_files.append(('share/tortoisehg', - ['hgproc.py', 'hgproc.bat', 'tortoisehg.py'])) - - # C:\Python25\mercurial\hgrc.d\tortoisehg.rc - _data_files.append(('mercurial/hgrc.d', ['installer/tortoisehg.rc'])) - - # C:\Python25\Scripts\tracelog.bat, thg_postinstall.py - extra['scripts'] = ['installer/tracelog.bat', 'installer/thg_postinstall.py'] + extra['console'] = ["contrib/hg"]    opts = {   "py2exe" : { @@ -99,7 +78,7 @@
  url='http://tortoisehg.sourceforge.net',   description='Windows shell extension for Mercurial VCS',   license='GNU GPL2', - packages=['tortoise', 'hggtk'], + packages=['tortoise', 'hggtk', 'hggtk.vis', 'hggtk.iniparse'],   data_files = _data_files,   options=opts,   **extra
Change 1 of 1 Show Entire File simplemerge.bat Stacked
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
@@ -1,20 +0,0 @@
-:: -:: Win32 batch file to handle to merge with simplemerge for developement of TortoiseHg -:: - -@echo off -setlocal - -:: Look in the registry for TortoiseHg location -for /f "skip=2 tokens=3*" %%A in ( - '"reg query "HKEY_LOCAL_MACHINE\SOFTWARE\TortoiseHg" /ve 2> nul"' ) do set TortoisePath=%%B -if "%TortoisePath%"=="" (goto :notfound) else (goto :merge) - -:merge -python "%TortoisePath%\hgutils\simplemerge" %* -goto end - -:notfound -echo hgproc: cannot find TortoiseHg location in the registry. - -:end