You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# the BSD License: http://www.opensource.org/licenses/bsd-license.php
6
6
from __future__ importprint_function
7
7
8
+
importcontextlib
8
9
fromfunctoolsimportwraps
9
10
importio
10
11
importlogging
@@ -16,7 +17,7 @@
16
17
importunittest
17
18
18
19
fromgit.compatimportstring_types, is_win, PY3
19
-
fromgit.utilimportrmtree
20
+
fromgit.utilimportrmtree, cwd
20
21
21
22
importos.pathasosp
22
23
@@ -151,32 +152,67 @@ def repo_creator(self):
151
152
returnargument_passer
152
153
153
154
154
-
deflaunch_git_daemon(base_path, ip, port):
155
-
fromgitimportGit
156
-
ifis_win:
157
-
## On MINGW-git, daemon exists in .\Git\mingw64\libexec\git-core\,
158
-
# but if invoked as 'git daemon', it detaches from parent `git` cmd,
159
-
# and then CANNOT DIE!
160
-
# So, invoke it as a single command.
161
-
## Cygwin-git has no daemon. But it can use MINGW's.
162
-
#
163
-
daemon_cmd= ['git-daemon',
164
-
'--enable=receive-pack',
165
-
'--listen=%s'%ip,
166
-
'--port=%s'%port,
167
-
'--base-path=%s'%base_path,
168
-
base_path]
169
-
gd=Git().execute(daemon_cmd, as_process=True)
170
-
else:
171
-
gd=Git().daemon(base_path,
172
-
enable='receive-pack',
173
-
listen=ip,
174
-
port=port,
175
-
base_path=base_path,
176
-
as_process=True)
177
-
# yes, I know ... fortunately, this is always going to work if sleep time is just large enough
178
-
time.sleep(0.5)
179
-
returngd
155
+
@contextlib.contextmanager
156
+
defgit_daemon_launched(base_path, ip, port):
157
+
fromgitimportGit# Avoid circular deps.
158
+
159
+
gd=None
160
+
try:
161
+
ifis_win:
162
+
## On MINGW-git, daemon exists in .\Git\mingw64\libexec\git-core\,
163
+
# but if invoked as 'git daemon', it detaches from parent `git` cmd,
164
+
# and then CANNOT DIE!
165
+
# So, invoke it as a single command.
166
+
## Cygwin-git has no daemon. But it can use MINGW's.
167
+
#
168
+
daemon_cmd= ['git-daemon',
169
+
'--enable=receive-pack',
170
+
'--listen=%s'%ip,
171
+
'--port=%s'%port,
172
+
'--base-path=%s'%base_path,
173
+
base_path]
174
+
gd=Git().execute(daemon_cmd, as_process=True)
175
+
else:
176
+
gd=Git().daemon(base_path,
177
+
enable='receive-pack',
178
+
listen=ip,
179
+
port=port,
180
+
base_path=base_path,
181
+
as_process=True)
182
+
# yes, I know ... fortunately, this is always going to work if sleep time is just large enough
183
+
time.sleep(0.5* (1+is_win))
184
+
185
+
yield
186
+
187
+
exceptExceptionasex:
188
+
msg=textwrap.dedent("""
189
+
Launching git-daemon failed due to: %s
190
+
Probably test will fail subsequently.
191
+
192
+
BUT you may start *git-daemon* manually with this command:"
0 commit comments