Skip to content

Commit 0dd56ad

Browse files
committed
1)pump git-daemon stderr 2)nojoin pumps, 3)no submodules
1 parent 3910abf commit 0dd56ad

File tree

4 files changed

+29
-35
lines changed

4 files changed

+29
-35
lines changed

git/__init__.py

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,24 +15,6 @@
1515
__version__ = 'git'
1616

1717

18-
#{ Initialization
19-
def _init_externals():
20-
"""Initialize external projects by putting them into the path"""
21-
if __version__ == 'git':
22-
sys.path.insert(0, osp.join(osp.dirname(__file__), 'ext', 'gitdb'))
23-
24-
try:
25-
import gitdb
26-
except ImportError:
27-
raise ImportError("'gitdb' could not be found in your PYTHONPATH")
28-
# END verify import
29-
30-
#} END initialization
31-
32-
#################
33-
_init_externals()
34-
#################
35-
3618
#{ Imports
3719

3820
from git.config import GitConfigParser # @NoMove @IgnorePep8

git/cmd.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
## @{
6262

6363
def handle_process_output(process, stdout_handler, stderr_handler,
64-
finalizer=None, decode_streams=True):
64+
finalizer=None, decode_streams=True, nojoin=False):
6565
"""Registers for notifications to lean that process output is ready to read, and dispatches lines to
6666
the respective line handlers.
6767
This function returns once the finalizer returns
@@ -112,8 +112,9 @@ def pump_stream(cmdline, name, stream, is_decode, handler):
112112

113113
## FIXME: Why Join?? Will block if `stdin` needs feeding...
114114
#
115-
for t in threads:
116-
t.join()
115+
if not nojoin:
116+
for t in threads:
117+
t.join()
117118

118119
if finalizer:
119120
return finalizer(process)
@@ -580,8 +581,9 @@ def execute(self, command,
580581
stdout_sink = (PIPE
581582
if with_stdout
582583
else getattr(subprocess, 'DEVNULL', open(os.devnull, 'wb')))
583-
log.debug("Popen(%s, cwd=%s, universal_newlines=%s, shell=%s)",
584-
command, cwd, universal_newlines, shell)
584+
import subprocess as sb
585+
log.debug("Popen(%s, cwd=%s, universal_newlines=%s, shell=%s,\n_active=%s)",
586+
command, cwd, universal_newlines, shell, sb._active)
585587
try:
586588
proc = Popen(command,
587589
env=env,

git/remote.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -686,14 +686,18 @@ def stdout_handler(line):
686686
# If an error happens, additional info is given which we parse below.
687687
pass
688688

689-
handle_process_output(proc, stdout_handler, progress_handler, finalizer=None, decode_streams=False)
689+
stdout, stderr = proc.communicate()
690+
for l in stderr.split('\n'):
691+
if l:
692+
progress_handler(l)
690693
stderr_text = progress.error_lines and '\n'.join(progress.error_lines) or ''
691-
try:
692-
proc.wait(stderr=stderr_text)
693-
except Exception:
694-
if not output:
695-
raise
696-
elif stderr_text:
694+
for l in stdout.split('\n'):
695+
stdout_handler(l)
696+
status = proc.proc.wait()
697+
if status and not output:
698+
raise GitCommandError(getattr(proc, 'args', ''), status, stderr, stdout)
699+
else:
700+
if stderr_text:
697701
log.warning("Error lines received while fetching: %s", stderr_text)
698702

699703
return output

git/test/lib/helper.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ def git_daemon_launched(base_path, ip, port):
169169
'--enable=receive-pack',
170170
'--listen=%s' % ip,
171171
'--port=%s' % port,
172+
'--timeout=10',
172173
'--base-path=%s' % base_path,
173174
base_path]
174175
gd = Git().execute(daemon_cmd, as_process=True)
@@ -179,6 +180,9 @@ def git_daemon_launched(base_path, ip, port):
179180
port=port,
180181
base_path=base_path,
181182
as_process=True)
183+
from git.cmd import handle_process_output
184+
import functools as fnt
185+
handle_process_output(gd, fnt.partial(print, 'GDout>>>'), fnt.partial(print, 'GDerr>>>'), nojoin=True)
182186
# yes, I know ... fortunately, this is always going to work if sleep time is just large enough
183187
time.sleep(0.5 * (1 + is_win))
184188
except Exception as ex:
@@ -286,13 +290,15 @@ def remote_repo_creator(self):
286290
rw_repo.git.ls_remote(d_remote)
287291

288292
with cwd(rw_repo.working_dir):
293+
ok = False
289294
try:
290295
return func(self, rw_repo, rw_daemon_repo)
291-
except:
292-
log.info("Keeping repos after failure: \n rw_repo_dir: %s \n rw_daemon_repo_dir: %s",
293-
rw_repo_dir, rw_daemon_repo_dir)
294-
rw_repo_dir = rw_daemon_repo_dir = None
295-
raise
296+
ok = True
297+
finally:
298+
if not ok:
299+
log.info("Keeping repos after failure: \n rw_repo_dir: %s \n rw_daemon_repo_dir: %s",
300+
rw_repo_dir, rw_daemon_repo_dir)
301+
rw_repo_dir = rw_daemon_repo_dir = None
296302

297303
finally:
298304
rw_repo.git.clear_cache()

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy