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

hgtk: cleanup fork logic

Changeset 53f9750fa12b

Parent e3f56b00872f

by Steve Borho

Changes to 2 files · Browse files at 53f9750fa12b Showing diff from parent e3f56b00872f Diff from another changeset...

Change 1 of 7 Show Entire File hggtk/​hgtk.py Stacked
 
54
55
56
 
57
58
59
60
61
62
 
63
64
65
66
 
 
67
68
 
 
 
69
70
71
 
202
203
204
 
 
205
206
207
 
241
242
243
244
 
 
 
245
246
247
 
260
261
262
263
 
264
265
266
 
275
276
277
278
279
280
 
281
282
283
284
285
286
287
 
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
 
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
 
54
55
56
57
58
59
60
61
62
 
63
64
 
 
 
65
66
67
 
68
69
70
71
72
73
 
204
205
206
207
208
209
210
211
 
245
246
247
 
248
249
250
251
252
253
 
266
267
268
 
269
270
271
272
 
281
282
283
 
284
 
285
286
287
288
 
289
290
291
 
293
294
295
 
296
297
298
299
 
300
 
301
302
303
304
 
305
306
 
307
308
309
310
 
311
312
 
313
314
315
316
 
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
@@ -54,18 +54,20 @@
  opts = {}   opts['cmd'] = ' '.join(sys.argv[1:])   opts['error'] = error + opts['nofork'] = True   if gtkmainalive:   dlg = run(u, **opts)   dlg.display()   dlg.show_all()   else: - gtkrun(run(u, **opts)) + gtkrun(run, u, **opts)   -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: +def portable_fork(ui, opts): + if 'THG_HGTK_SPAWN' in os.environ:   return - if '--repository' in sys.argv or '-R' in sys.argv: + if opts.get('nofork') or opts.get('repository'): + return + if not ui.configbool('tortoisehg', 'hgtkfork', True):   return   # Spawn background process and exit   if hasattr(sys, "frozen"): @@ -202,6 +204,8 @@
  path = ui.expandpath(options['repository'])   cmdoptions['repository'] = path   os.chdir(path) + if options['nofork']: + cmdoptions['nofork'] = True   path = paths.find_root(os.getcwd())   if path:   try: @@ -241,7 +245,9 @@
  if mainwindow.should_live(): return   mainwindow.destroy()   -def gtkrun(win): +def gtkrun(dlgfunc, ui, *args, **opts): + portable_fork(ui, opts) + win = dlgfunc(ui, *args, **opts)   global mainwindow, gtkmainalive   mainwindow = win   if hasattr(win, 'display'): @@ -260,7 +266,7 @@
 def about(ui, *pats, **opts):   """about TortoiseHg"""   from hggtk.about import run - gtkrun(run(ui, *pats, **opts)) + gtkrun(run, ui, *pats, **opts)    def add(ui, *pats, **opts):   """add files""" @@ -275,13 +281,11 @@
   def clone(ui, *pats, **opts):   """clone tool""" - portable_fork(ui)   from hggtk.clone import run - gtkrun(run(ui, *pats, **opts)) + gtkrun(run, ui, *pats, **opts)    def commit(ui, *pats, **opts):   """commit tool""" - 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()) @@ -289,27 +293,24 @@
  os.chdir(repo.root)   pats = []   from hggtk.commit import run - gtkrun(run(ui, *pats, **opts)) + gtkrun(run, ui, *pats, **opts)    def shelve(ui, *pats, **opts):   """shelve/unshelve tool""" - portable_fork(ui)   from hggtk.thgshelve import run - gtkrun(run(ui, *pats, **opts)) + gtkrun(run, ui, *pats, **opts)    def userconfig(ui, *pats, **opts):   """user configuration editor""" - portable_fork(ui)   from hggtk.thgconfig import run   opts['repomode'] = False - gtkrun(run(ui, *pats, **opts)) + gtkrun(run, ui, *pats, **opts)    def repoconfig(ui, *pats, **opts):   """repository configuration editor""" - portable_fork(ui)   from hggtk.thgconfig import run   opts['repomode'] = True - gtkrun(run(ui, *pats, **opts)) + gtkrun(run, ui, *pats, **opts)    def rename(ui, *pats, **opts):   """rename a single file or directory""" @@ -318,98 +319,83 @@
  gdialog.Prompt(_('Rename error'),   _('rename takes one or two path arguments'), None).run()   return - portable_fork(ui)   from hggtk.rename import run - gtkrun(run(ui, *pats, **opts)) + gtkrun(run, ui, *pats, **opts)    def guess(ui, *pats, **opts):   """guess previous renames or copies""" - portable_fork(ui)   from hggtk.guess import run - gtkrun(run(ui, *pats, **opts)) + gtkrun(run, ui, *pats, **opts)    def datamine(ui, *pats, **opts):   """repository search and annotate tool""" - portable_fork(ui)   from hggtk.datamine import run - gtkrun(run(ui, *pats, **opts)) + gtkrun(run, ui, *pats, **opts)    def hgignore(ui, *pats, **opts):   """ignore filter editor""" - portable_fork(ui)   from hggtk.hgignore import run - gtkrun(run(ui, *pats, **opts)) + gtkrun(run, ui, *pats, **opts)    def hginit(ui, *pats, **opts):   """repository initialization tool""" - portable_fork(ui)   from hggtk.hginit import run - gtkrun(run(ui, *pats, **opts)) + gtkrun(run, ui, *pats, **opts)    def log(ui, *pats, **opts):   """changelog viewer""" - portable_fork(ui)   from hggtk.history import run - gtkrun(run(ui, *pats, **opts)) + gtkrun(run, ui, *pats, **opts)    def merge(ui, *pats, **opts):   """merge tool""" - portable_fork(ui)   from hggtk.merge import run - gtkrun(run(ui, *pats, **opts)) + gtkrun(run, ui, *pats, **opts)    def recovery(ui, *pats, **opts):   """recover, rollback & verify""" - portable_fork(ui)   from hggtk.recovery import run - gtkrun(run(ui, *pats, **opts)) + gtkrun(run, ui, *pats, **opts)    def remove(ui, *pats, **opts):   """file status viewer in remove mode""" - portable_fork(ui)   from hggtk.status import run - gtkrun(run(ui, *pats, **opts)) + gtkrun(run, ui, *pats, **opts)    def revert(ui, *pats, **opts):   """file status viewer in revert mode""" - portable_fork(ui)   from hggtk.status import run - gtkrun(run(ui, *pats, **opts)) + gtkrun(run, ui, *pats, **opts)    def serve(ui, *pats, **opts):   """web server""" - portable_fork(ui)   from hggtk.serve import run - gtkrun(run(ui, *pats, **opts)) + gtkrun(run, ui, *pats, **opts)    def status(ui, *pats, **opts):   """file status & diff viewer""" - portable_fork(ui)   from hggtk.status import run - gtkrun(run(ui, *pats, **opts)) + gtkrun(run, ui, *pats, **opts)    def synch(ui, *pats, **opts):   """repository synchronization tool""" - portable_fork(ui)   from hggtk.synch import run   cmd = opts['alias']   if cmd in ('push', 'outgoing', 'email'):   opts['pushmode'] = True   else:   opts['pushmode'] = False - gtkrun(run(ui, *pats, **opts)) + gtkrun(run, ui, *pats, **opts)    def update(ui, *pats, **opts):   """update/checkout tool""" - portable_fork(ui)   from hggtk.update import run - gtkrun(run(ui, *pats, **opts)) + gtkrun(run, ui, *pats, **opts)    def vdiff(ui, *pats, **opts):   """launch configured visual diff tool""" - portable_fork(ui)   from hggtk.visdiff import run - gtkrun(run(ui, *pats, **opts)) + gtkrun(run, ui, *pats, **opts)    ### help management, adapted from mercurial.commands.help_()  def help_(ui, name=None, with_version=False):
Change 1 of 1 Show Entire File hgtk Stacked
 
59
60
61
62
 
 
63
64
 
59
60
61
 
62
63
64
65
@@ -59,6 +59,7 @@
  opts = {}   opts['cmd'] = ' '.join(sys.argv[1:])   opts['error'] = error - gtkrun(run(_ui, **opts)) + opts['nofork'] = True + gtkrun(run, _ui, **opts)   break   sys.exit(ret)