Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 0.9, 0.9.1, and 0.9.1.1

merge with stable

Changeset 9d3da274f8a2

Parents 2c2a1a633735

Parents 4e02beaf36d8

by Steve Borho

Changes to 11 files · Browse files at 9d3da274f8a2 Showing diff from parent 2c2a1a633735 4e02beaf36d8 Diff from another changeset...

Change 1 of 2 Show Entire File hggtk/​about.py Stacked
 
53
54
55
56
 
57
58
59
 
60
61
62
 
72
73
74
75
 
76
77
78
 
53
54
55
 
56
57
58
 
59
60
61
62
 
72
73
74
 
75
76
77
78
@@ -53,10 +53,10 @@
    self.set_website("http://bitbucket.org/tortoisehg/stable/")   self.set_name("TortoiseHg") - self.set_version("(version %s)" % version.version()) + self.set_version(_("(version %s)") % version.version())   if hasattr(self, 'set_wrap_license'):   self.set_wrap_license(True) - self.set_copyright("Copyright 2009 TK Soh and others") + self.set_copyright(_("Copyright 2009 TK Soh and others"))     thg_logo = paths.get_tortoise_icon('thg_logo_92x50.png')   thg_icon = paths.get_tortoise_icon('thg_logo.ico') @@ -72,7 +72,7 @@
  license = hgtk.shortlicense.splitlines()[1:]   self.set_license('\n'.join(license))   - self.set_comments("with " + lib_versions + "\n\n" + comment) + self.set_comments(_("with %s") % lib_versions + "\n\n" + comment)   self.set_logo(gtk.gdk.pixbuf_new_from_file(thg_logo))   self.set_icon_from_file(thg_icon)   self.connect('response', self.response)
 
152
153
154
 
 
 
 
 
 
155
156
157
 
161
162
163
164
165
166
 
 
 
 
 
 
 
 
 
 
167
168
169
 
422
423
424
 
 
 
425
426
427
 
434
435
436
 
 
 
437
 
438
 
439
440
441
 
152
153
154
155
156
157
158
159
160
161
162
163
 
167
168
169
 
 
 
170
171
172
173
174
175
176
177
178
179
180
181
182
 
435
436
437
438
439
440
441
442
443
 
450
451
452
453
454
455
456
457
458
459
460
461
462
@@ -152,6 +152,12 @@
  if ctx.branch() != 'default':   title_line(_('branch:'), ctx.branch(), 'greybg')   title_line(_('user/date:'), ctx.user() + '\t' + date, 'changeset') + + if len(ctx.parents()) == 2 and self.parent_toggle.get_active(): + parentindex = 1 + else: + parentindex = 0 +   for pctx in ctx.parents():   try:   summary = pctx.description().splitlines()[0] @@ -161,9 +167,16 @@
  change = str(pctx.rev()) + ' : ' + str(pctx)   title = _('parent:')   title += ' ' * (12 - len(title)) - buf.insert_with_tags_by_name(eob, title, 'parent') - buf.insert_with_tags_by_name(eob, change, 'link') - buf.insert_with_tags_by_name(eob, ' ' + summary, 'parent') + + if len(ctx.parents()) == 2 and pctx == ctx.parents()[parentindex]: + buf.insert_with_tags_by_name(eob, title, 'parenthl') + buf.insert_with_tags_by_name(eob, change, 'linkhl') + buf.insert_with_tags_by_name(eob, ' ' + summary, 'parenthl') + else: + buf.insert_with_tags_by_name(eob, title, 'parent') + buf.insert_with_tags_by_name(eob, change, 'link') + buf.insert_with_tags_by_name(eob, ' ' + summary, 'parent') +   buf.insert(eob, "\n")   for cctx in ctx.children():   try: @@ -422,6 +435,9 @@
  paragraph_background='#F0F0F0'))   tag_table.add(make_texttag('parent', foreground='#000090',   paragraph_background='#F0F0F0')) + tag_table.add(make_texttag('parenthl', foreground='#000090', + paragraph_background='#F0F0F0', + weight=pango.WEIGHT_BOLD ))     tag_table.add( make_texttag( 'mono', family='Monospace' ))   tag_table.add( make_texttag( 'blue', foreground='blue' )) @@ -434,8 +450,13 @@
  tag_table.add( make_texttag( 'yellowbg', background='yellow' ))   link_tag = make_texttag( 'link', foreground='blue',   underline=pango.UNDERLINE_SINGLE ) + linkhl_tag = make_texttag( 'linkhl', foreground='blue', + underline=pango.UNDERLINE_SINGLE, + weight=pango.WEIGHT_BOLD )   link_tag.connect('event', self.link_event ) + linkhl_tag.connect('event', self.link_event )   tag_table.add( link_tag ) + tag_table.add( linkhl_tag )     def file_button_release(self, widget, event):   if event.button == 3 and not (event.state & (gtk.gdk.SHIFT_MASK |
Change 1 of 1 Show Entire File hggtk/​commit.py Stacked
 
463
464
465
466
467
468
 
469
470
471
472
473
474
475
 
463
464
465
 
 
 
466
467
 
 
 
468
469
470
@@ -463,13 +463,8 @@
  if dopatch:   try:   pfiles = {} - if patch.patchfile.__bases__: - # Mercurial 1.3 - patch.internalpatch(fp, ui, 1, repo.root, files=pfiles, + patch.internalpatch(fp, ui, 1, repo.root, files=pfiles,   eolmode=None) - else: - # Mercurial 1.2 - patch.internalpatch(fp, ui, 1, repo.root, files=pfiles)   patch.updatedir(ui, repo, pfiles)   except patch.PatchError, err:   s = str(err)
Change 1 of 2 Show Entire File hggtk/​hgshelve.py Stacked
 
429
430
431
432
 
433
434
435
 
501
502
503
504
505
506
507
508
509
 
510
511
512
 
429
430
431
 
432
433
434
435
 
501
502
503
 
 
 
 
 
 
504
505
506
507
@@ -429,7 +429,7 @@
    ? - display help'''   - if not hglib.calliffunc(ui.interactive): + if not ui.interactive():   raise util.Abort(_('shelve can only be run interactively'))     forced = opts['force'] or opts['append'] @@ -501,12 +501,7 @@
  if dopatch:   ui.debug(_('applying patch\n'))   ui.debug(fp.getvalue()) - if patch.patchfile.__bases__: - # Mercurial 1.3 - patch.internalpatch(fp, ui, 1, repo.root, eolmode=None) - else: - # Mercurial 1.2 - patch.internalpatch(fp, ui, 1, repo.root) + patch.internalpatch(fp, ui, 1, repo.root, eolmode=None)   del fp     # 3c. apply filtered patch to clean repo (shelve)
Change 1 of 4 Show Entire File hggtk/​hgthread.py Stacked
 
23
24
25
26
27
28
29
30
31
32
33
 
 
34
35
36
 
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
 
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
 
175
176
177
 
183
184
185
186
 
187
188
189
 
23
24
25
 
 
 
 
 
 
 
 
26
27
28
29
30
 
51
52
53
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
 
139
140
141
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
142
143
144
145
 
151
152
153
 
154
155
 
 
@@ -23,14 +23,8 @@
  main thread to pickup.   '''   def __init__(self, src=None, outputq=None, errorq=None, dialogq=None, - responseq=None, parentui=None): - if parentui: - # Mercurial 1.2 - super(GtkUi, self).__init__(parentui=parentui) - src = parentui - else: - # Mercurial 1.3 - super(GtkUi, self).__init__(src) + responseq=None): + super(GtkUi, self).__init__(src)   if src:   self.outputq = src.outputq   self.errorq = src.errorq @@ -57,27 +51,18 @@
    def prompt(self, msg, choices=None, default="y"):   import re - if not hglib.calliffunc(self.interactive): return default - if isinstance(choices, str): - pat = choices - choices = None - else: - pat = None - while True: - try: - # send request to main thread, await response - self.dialogq.put( (msg, True, choices, default) ) - r = self.responseq.get(True) - if r is None: - raise EOFError - if not r: - return default - if not pat or re.match(pat, r): - return r - else: - self.write(_('unrecognized response\n')) - except EOFError: - raise util.Abort(_('response expected')) + if not self.interactive(): return default + try: + # send request to main thread, await response + self.dialogq.put( (msg, True, choices, default) ) + r = self.responseq.get(True) + if r is None: + raise EOFError + if not r: + return default + return r + except EOFError: + raise util.Abort(_('response expected'))     def getpass(self, prompt=None, default=None):   # send request to main thread, await response @@ -154,24 +139,7 @@
    def run(self):   try: - ret = None - if hasattr(self.ui, 'copy'): - # Mercurial 1.3 - ret = hglib.dispatch._dispatch(self.ui, self.args) - else: - # Mercurial 1.2 - # Some commands create repositories, and thus must create - # new ui() instances. For those, we monkey-patch ui.ui() - # as briefly as possible. - origui = None - if self.args[0] in ('clone', 'init'): - origui = ui.ui - ui.ui = GtkUi - try: - ret = hglib.thgdispatch(self.ui, None, self.args) - finally: - if origui: - ui.ui = origui + ret = hglib.dispatch._dispatch(self.ui, self.args)   if ret:   self.ui.write(_('[command returned code %d]\n') % int(ret))   else: @@ -183,7 +151,5 @@
  self.ui.write_err(_('abort: ') + str(e) + '\n')   except (hglib.RepoError, urllib2.HTTPError), e:   self.ui.write_err(str(e) + '\n') - except Exception, e: + except (Exception, OSError, IOError), e:   self.ui.write_err(str(e) + '\n') - except hglib.WinIOError, e: - self.ui.write_err(str(e) + '\n')
Change 1 of 7 Show Entire File hggtk/​hgtk.py Stacked
 
1
2
3
4
5
 
63
64
65
66
67
 
 
 
68
69
70
 
262
263
264
265
 
266
267
268
269
270
271
272
273
274
275
276
277
278
279
 
280
281
282
 
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
 
393
394
395
396
 
397
398
399
400
401
402
 
403
404
405
 
441
442
443
444
 
445
446
447
 
627
628
629
630
 
631
632
633
 
 
 
1
2
3
 
61
62
63
 
 
64
65
66
67
68
69
 
261
262
263
 
264
265
266
267
268
269
 
 
 
 
 
 
 
 
 
270
271
272
273
 
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
 
387
388
389
 
390
391
392
393
394
395
 
396
397
398
399
 
435
436
437
 
438
439
440
441
 
621
622
623
 
624
625
626
627
@@ -1,5 +1,3 @@
-#!/usr/bin/env python -#  # front-end script for TortoiseHg dialogs  #  # Copyright (C) 2008-9 Steve Borho <steve@borho.org> @@ -63,8 +61,9 @@
  else:   gtkrun(run(u, **opts))   -def portable_fork(): - if 'THG_HGTK_SPAWN' in os.environ or '--nofork' in sys.argv: +def portable_fork(ui): + fork = ui.configbool('tortoisehg', 'hgtkfork', True) + if not fork or 'THG_HGTK_SPAWN' in os.environ or '--nofork' in sys.argv:   return   # Spawn background process and exit   if hasattr(sys, "frozen"): @@ -262,21 +261,13 @@
   def clone(ui, *pats, **opts):   """clone tool""" - portable_fork() + portable_fork(ui)   from hggtk.clone import run   gtkrun(run(ui, *pats, **opts))    def commit(ui, *pats, **opts):   """commit tool""" - ct = ui.config('tortoisehg', 'extcommit', None) - if ct == 'qct': - from mercurial import dispatch as _dispatch - try: - _dispatch.dispatch([ct], *pats) - except SystemExit: - pass - return - portable_fork() + portable_fork(ui)   # move cwd to repo root if repo is merged, so we can show   # all the changed files   repo = hg.repository(ui, path=paths.find_root()) @@ -288,101 +279,104 @@
   def shelve(ui, *pats, **opts):   """shelve/unshelve tool""" - portable_fork() + portable_fork(ui)   from hggtk.thgshelve import run   gtkrun(run(ui, *pats, **opts))    def userconfig(ui, *pats, **opts):   """user configuration editor""" - portable_fork() + portable_fork(ui)   from hggtk.thgconfig import run   opts['repomode'] = False   gtkrun(run(ui, *pats, **opts))    def repoconfig(ui, *pats, **opts):   """repository configuration editor""" - portable_fork() + portable_fork(ui)   from hggtk.thgconfig import run   opts['repomode'] = True   gtkrun(run(ui, *pats, **opts))    def rename(ui, *pats, **opts):   """rename a single file or directory""" - portable_fork() + if not pats or len(pats) > 2: + from hggtk import gdialog + gdialog.Prompt(_('Rename error'), + _('rename takes one or two path arguments'), None).run() + return + portable_fork(ui)   from hggtk.rename import run - if not pats or len(pats) > 2: - raise util.Abort(_('rename takes one or two path arguments'))   gtkrun(run(ui, *pats, **opts))    def guess(ui, *pats, **opts):   """guess previous renames or copies""" - portable_fork() + portable_fork(ui)   from hggtk.guess import run   gtkrun(run(ui, *pats, **opts))    def datamine(ui, *pats, **opts):   """repository search and annotate tool""" - portable_fork() + portable_fork(ui)   from hggtk.datamine import run   gtkrun(run(ui, *pats, **opts))    def hgignore(ui, *pats, **opts):   """ignore filter editor""" - portable_fork() + portable_fork(ui)   from hggtk.hgignore import run   gtkrun(run(ui, *pats, **opts))    def hginit(ui, *pats, **opts):   """repository initialization tool""" - portable_fork() + portable_fork(ui)   from hggtk.hginit import run   gtkrun(run(ui, *pats, **opts))    def log(ui, *pats, **opts):   """changelog viewer""" - portable_fork() + portable_fork(ui)   from hggtk.history import run   gtkrun(run(ui, *pats, **opts))    def merge(ui, *pats, **opts):   """merge tool""" - portable_fork() + portable_fork(ui)   from hggtk.merge import run   gtkrun(run(ui, *pats, **opts))    def recovery(ui, *pats, **opts):   """recover, rollback & verify""" - portable_fork() + portable_fork(ui)   from hggtk.recovery import run   gtkrun(run(ui, *pats, **opts))    def remove(ui, *pats, **opts):   """file status viewer in remove mode""" - portable_fork() + portable_fork(ui)   from hggtk.status import run   gtkrun(run(ui, *pats, **opts))    def revert(ui, *pats, **opts):   """file status viewer in revert mode""" - portable_fork() + portable_fork(ui)   from hggtk.status import run   gtkrun(run(ui, *pats, **opts))    def serve(ui, *pats, **opts):   """web server""" - portable_fork() + portable_fork(ui)   from hggtk.serve import run   gtkrun(run(ui, *pats, **opts))    def status(ui, *pats, **opts): - """file status viewer""" - portable_fork() + """file status & diff viewer""" + portable_fork(ui)   from hggtk.status import run   gtkrun(run(ui, *pats, **opts))    def synch(ui, *pats, **opts):   """repository synchronization tool""" - portable_fork() + portable_fork(ui)   from hggtk.synch import run   cmd = sys.argv[1]   if 'push'.startswith(cmd) or 'outgoing'.startswith(cmd): @@ -393,13 +387,13 @@
   def update(ui, *pats, **opts):   """update/checkout tool""" - portable_fork() + portable_fork(ui)   from hggtk.update import run   gtkrun(run(ui, *pats, **opts))    def vdiff(ui, *pats, **opts):   """launch configured visual diff tool""" - portable_fork() + portable_fork(ui)   from hggtk.visdiff import run   gtkrun(run(ui, *pats, **opts))   @@ -441,7 +435,7 @@
  aliases, i = cmdutil.findcmd(name, table, False)   except hglib.AmbiguousCommand, inst:   select = lambda c: c.lstrip('^').startswith(inst.args[0]) - helplist('list of commands:\n\n', select) + helplist(_('list of commands:\n\n'), select)   return     # synopsis @@ -627,7 +621,7 @@
  "^recovery|rollback|verify": (recovery, [], _('hgtk recovery')),   "^shelve|unshelve": (shelve, [], _('hgtk shelve')),   "^synch|pull|push|incoming|outgoing|email": (synch, [], _('hgtk synch')), - "^status|st": (status, + "^status|st|diff": (status,   [('r', 'rev', [], _('revisions to compare'))],   _('hgtk status [FILE]...')),   "^userconfig": (userconfig, [], _('hgtk userconfig')),
Change 1 of 1 Show Entire File hggtk/​serve.py Stacked
 
291
292
293
294
295
 
296
297
298
 
291
292
293
 
 
294
295
296
297
@@ -291,8 +291,7 @@
  self.stopped = True   util.set_signal_handler()   try: - baseui = (getattr(repo, 'baseui', None) or - getattr(ui, 'parentui', None) or ui) + baseui = repo and repo.baseui or ui   repoui = repo and repo.ui != baseui and repo.ui or None   optlist = ("name templates style address port prefix ipv6"   " accesslog errorlog webdir_conf certificate")
 
55
56
57
58
 
 
 
 
 
 
 
59
60
61
62
63
64
65
66
67
68
69
 
55
56
57
 
58
59
60
61
62
63
64
65
66
67
68
 
 
 
 
69
70
71
@@ -55,15 +55,17 @@
  (_('Bottom Diffs'), 'gtools.diffbottom', ['False', 'True'],   _('Show the diff panel below the file list in status, shelve, and'   ' commit dialogs.' - ' Default: False (show diffs to right of file list)'))) + ' Default: False (show diffs to right of file list)')), + (_('Capture Stderr'), 'tortoisehg.stderrcapt', ['True', 'False'], + _('Redirect stderr to a buffer which is parsed at the end of' + ' the process for runtime errors. Default: True')), + (_('Fork hgtk'), 'tortoisehg.hgtkfork', ['True', 'False'], + _('When running hgtk from the command line, fork a background' + ' process to run graphical dialogs. Default: True')))    _commit_info = (   (_('Username'), 'ui.username', [],   _('Name associated with commits')), - (_('External Commit Tool'), 'tortoisehg.extcommit', ['None', 'qct'], - _('Select commit tool launched by TortoiseHg. (Qct is no longer' - ' distributed as part of TortoiseHG.)' - ' Default: None (use the builtin tool)')),   (_('Summary Line Length'), 'tortoisehg.summarylen', ['0', '70'],   _('Maximum length of the commit message summary line.'   ' If set, TortoiseHG will issue a warning if the'
Change 1 of 1 Show Entire File hggtk/​visdiff.py Stacked
 
238
239
240
241
 
242
243
244
 
238
239
240
 
241
242
243
244
@@ -238,7 +238,7 @@
  stderr=subprocess.PIPE,   stdout=subprocess.PIPE,   stdin=subprocess.PIPE) - except Exception, e: + except (OSError, EnvironmentError), e:   gdialog.Prompt(_('Tool launch failure'),   _('%s : %s') % (self.diffpath, str(e)), None).run()  
Change 1 of 3 Show Entire File hgtk Stacked
 
26
27
28
29
 
30
31
 
32
33
34
 
39
40
41
42
 
 
 
 
43
44
45
46
47
48
 
51
52
53
54
55
56
57
58
59
60
 
61
62
 
26
27
28
 
29
30
31
32
33
34
35
 
40
41
42
 
43
44
45
46
47
48
 
49
50
51
 
54
55
56
 
57
58
59
60
61
 
62
63
64
@@ -26,9 +26,10 @@
 pygtk.require('2.0')  import gtk   -from mercurial import demandimport; +from mercurial import demandimport  demandimport.ignore.append('win32com.shell')  demandimport.enable() +from mercurial import ui  import cStringIO    try: @@ -39,10 +40,12 @@
  sys.stderr.write("(check your install and PYTHONPATH)\n")   sys.exit(-1)   -if 'THGDEBUG' in os.environ: +_ui = ui.ui() +capt = _ui.configbool('tortoisehg', 'stderrcapt', True) + +if not capt or 'THGDEBUG' in os.environ:   sys.exit(hggtk.hgtk.dispatch(sys.argv[1:]))  else: - import cStringIO   mystderr = cStringIO.StringIO()   sys.stderr = mystderr   ret = hggtk.hgtk.dispatch(sys.argv[1:]) @@ -51,12 +54,11 @@
  if l.startswith('Traceback') or l.startswith('TypeError'):   from hggtk.bugreport import run   from hggtk.hgtk import gtkrun - from mercurial import ui   mystderr.seek(0)   error = 'Recoverable runtime error (stderr):\n' + mystderr.read()   opts = {}   opts['cmd'] = ' '.join(sys.argv[1:])   opts['error'] = error - gtkrun(run(ui.ui(), **opts)) + gtkrun(run(_ui, **opts))   break   sys.exit(ret)
Change 1 of 4 Show Entire File thgutil/​hglib.py Stacked
 
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
 
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
 
163
164
165
166
167
168
169
170
 
171
172
173
 
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
 
16
17
18
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
20
21
22
23
24
25
26
27
28
 
94
95
96
 
 
 
 
97
98
99
100
101
 
 
 
 
102
103
104
 
 
 
 
 
 
 
 
 
 
105
106
107
108
109
 
120
121
122
 
 
 
 
 
123
124
125
126
 
128
129
130
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
@@ -16,41 +16,13 @@
 from i18n import _  import paths   -try: - from mercurial.error import RepoError, ParseError, LookupError - from mercurial.error import UnknownCommand, AmbiguousCommand -except ImportError: - from mercurial.cmdutil import UnknownCommand, AmbiguousCommand - from mercurial.repo import RepoError - from mercurial.dispatch import ParseError - from mercurial.revlog import LookupError - -from mercurial import dispatch - -try: - from mercurial import encoding - _encoding = encoding.encoding - _encodingmode = encoding.encodingmode - _fallbackencoding = encoding.fallbackencoding -except ImportError: - _encoding = util._encoding - _encodingmode = util._encodingmode - _fallbackencoding = util._fallbackencoding - -try: - # post 1.1.2 - from mercurial import util - hgversion = util.version() -except AttributeError: - # <= 1.1.2 - from mercurial import version - hgversion = version.get_version() - -try: - from mercurial.util import WinIOError -except: - class WinIOError(Exception): - 'WinIOError stub' +from mercurial.error import RepoError, ParseError, LookupError +from mercurial.error import UnknownCommand, AmbiguousCommand +from mercurial import dispatch, encoding, util +_encoding = encoding.encoding +_encodingmode = encoding.encodingmode +_fallbackencoding = encoding.fallbackencoding +hgversion = util.version()    def toutf(s):   """ @@ -122,31 +94,16 @@
  write args if there are buffers   returns True if the caller shall handle writing   ''' - buffers = getattr(u, '_buffers', None) - if buffers == None: - buffers = u.buffers - if buffers: + if u._buffers:   ui.ui.write(u, *args)   return False   return True   -def calliffunc(f): - return hasattr(f, '__call__') and f() or f - -  def invalidaterepo(repo):   repo.invalidate()   repo.dirstate.invalidate() - if 'mq' in repo.__dict__: #do not create if it did not exist - mq = repo.mq - if hasattr(mq, 'invalidate'): - #Mercurial 1.3 - mq.invalidate() - else: - #Mercurial 1.2 - mqclass = mq.__class__ - repo.mq = mqclass(mq.ui, mq.basepath, mq.path) - + if 'mq' in repo.__dict__: #do not create if it does not exist + repo.mq.invalidate()    def hgcmd_toq(path, q, *args):   ''' @@ -163,11 +120,7 @@
  for a in args:   q.put(str(a))   u = Qui() - if hasattr(ui.ui, 'copy'): - # Mercurial 1.3 - return dispatch._dispatch(u, list(args)) - else: - return thgdispatch(u, path, list(args)) + return dispatch._dispatch(u, list(args))      def displaytime(date): @@ -175,160 +128,3 @@
   def utctime(date):   return time.strftime("%Y-%m-%d %H:%M:%S", time.gmtime(date[0])) - -# the remaining functions are only needed for Mercurial versions < 1.3 -def _earlygetopt(aliases, args): - """Return list of values for an option (or aliases). - - The values are listed in the order they appear in args. - The options and values are removed from args. - """ - try: - argcount = args.index("--") - except ValueError: - argcount = len(args) - shortopts = [opt for opt in aliases if len(opt) == 2] - values = [] - pos = 0 - while pos < argcount: - if args[pos] in aliases: - if pos + 1 >= argcount: - # ignore and let getopt report an error if there is no value - break - del args[pos] - values.append(args.pop(pos)) - argcount -= 2 - elif args[pos][:2] in shortopts: - # short option can have no following space, e.g. hg log -Rfoo - values.append(args.pop(pos)[2:]) - argcount -= 1 - else: - pos += 1 - return values - -_loaded = {} -def thgdispatch(ui, path=None, args=[], nodefaults=True): - ''' - Replicate functionality of mercurial dispatch but force the use - of the passed in ui for all purposes - ''' - - # clear all user-defined command defaults - if nodefaults: - for k, v in ui.configitems('defaults'): - ui.setconfig('defaults', k, '') - - # read --config before doing anything else - # (e.g. to change trust settings for reading .hg/hgrc) - config = _earlygetopt(['--config'], args) - if config: - for section, name, value in dispatch._parseconfig(config): - ui.setconfig(section, name, value) - - # check for cwd - cwd = _earlygetopt(['--cwd'], args) - if cwd: - os.chdir(cwd[-1]) - - # read the local repository .hgrc into a local ui object - path = paths.find_root(path) or "" - if path: - try: - ui.readconfig(os.path.join(path, ".hg", "hgrc")) - except IOError: - pass - - # now we can expand paths, even ones in .hg/hgrc - rpath = _earlygetopt(["-R", "--repository", "--repo"], args) - if rpath: - path = ui.expandpath(rpath[-1]) - - extensions.loadall(ui) - if not hasattr(extensions, 'extensions'): - extensions.extensions = lambda: () # pre-0.9.5, loadall did below - for name, module in extensions.extensions(): - if name in _loaded: - continue - - # setup extensions - extsetup = getattr(module, 'extsetup', None) - if extsetup: - extsetup() - - cmdtable = getattr(module, 'cmdtable', {}) - overrides = [cmd for cmd in cmdtable if cmd in commands.table] - if overrides: - ui.warn(_("extension '%s' overrides commands: %s\n") % - (name, " ".join(overrides))) - commands.table.update(cmdtable) - _loaded[name] = 1 - - # check for fallback encoding - fallback = ui.config('ui', 'fallbackencoding') - if fallback: - _fallbackencoding = fallback - - fullargs = args - cmd, func, args, options, cmdoptions = dispatch._parse(ui, args) - - if options["encoding"]: - _encoding = options["encoding"] - if options["encodingmode"]: - _encodingmode = options["encodingmode"] - if options['verbose'] or options['debug'] or options['quiet']: - ui.setconfig('ui', 'verbose', str(bool(options['verbose']))) - ui.setconfig('ui', 'debug', str(bool(options['debug']))) - ui.setconfig('ui', 'quiet', str(bool(options['quiet']))) - if options['traceback']: - ui.setconfig('ui', 'traceback', 'on') - if options['noninteractive']: - ui.setconfig('ui', 'interactive', 'off') - - if options['help']: - return commands.help_(ui, cmd, options['version']) - elif options['version']: - return commands.version_(ui) - elif not cmd: - return commands.help_(ui, 'shortlist') - - repo = None - if cmd not in commands.norepo.split(): - try: - repo = hg.repository(ui, path=path) - repo.ui = ui - ui.setconfig("bundle", "mainreporoot", repo.root) - if not repo.local(): - raise util.Abort(_("repository '%s' is not local") % path) - except RepoError: - if cmd not in commands.optionalrepo.split(): - if not path: - raise RepoError(_('There is no Mercurial repository here' - ' (.hg not found)')) - raise - d = lambda: func(ui, repo, *args, **cmdoptions) - else: - d = lambda: func(ui, *args, **cmdoptions) - - # run pre-hook, and abort if it fails - ret = hook.hook(ui, repo, "pre-%s" % cmd, False, args=" ".join(fullargs)) - if ret: - return ret - - # Run actual command - try: - ret = d() - except TypeError: - # was this an argument error? - tb = traceback.extract_tb(sys.exc_info()[2]) - if len(tb) != 2: # no - raise - raise ParseError(cmd, _('invalid arguments')) - - # run post-hook, passing command result - hook.hook(ui, repo, "post-%s" % cmd, False, args=" ".join(fullargs), - result = ret) - - if repo: - shlib.update_thgstatus(repo.ui, repo.root, wait=True) - - return ret