Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 0.8, 0.8.1, and 0.8.2

hgtk: enable forking behavior for GUI commands

The code that guesses the command may need revisiting at
a later date.

Changeset 29a48d45f5b9

Parent feb1ace7e724

by Steve Borho

Changes to one file · Browse files at 29a48d45f5b9 Showing diff from parent feb1ace7e724 Diff from another changeset...

Change 1 of 1 Show Entire File hgtk Stacked
 
13
14
15
16
 
 
 
 
 
 
17
18
 
 
19
20
21
22
23
 
 
 
 
 
 
 
 
 
 
24
25
26
 
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
@@ -13,14 +13,30 @@
  # Spawn background process and exit   if sys.platform[:3] == 'win':   if 'THG_HGTK_SPAWN' not in os.environ: - env = os.environ + if hasattr(sys, "frozen"): + args = sys.argv + else: + args = [sys.executable] + sys.argv + args = ['"%s"' % arg for arg in args] + env = os.environ.copy()   env['THG_HGTK_SPAWN'] = '1' - os.spawnve(os.P_NOWAIT, sys.executable, sys.argv, env) + os.spawnve(os.P_NOWAIT, sys.executable, args, env) + sys.exit(0)   else:   assert hasattr(os, 'fork')   if os.fork():   sys.exit(0)   +nofork = 'version help' # simple interactive commands should not fork +for i, arg in enumerate(sys.argv): + if arg.startswith('hgtk') and len(sys.argv) >= i: + cmd = sys.argv[i+1] + break +else: + cmd = None +if cmd not in nofork.split() and 'HGTK_NOFORK' not in os.environ: + portable_fork() +  if hasattr(sys, "frozen"):   # Prepend C:\Program Files\TortoiseHg\gtk (equiv) to the path   from thgutil import paths