summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Thiel <byronimo@gmail.com>2015-01-20 10:05:25 +0100
committerSebastian Thiel <byronimo@gmail.com>2015-01-20 10:05:25 +0100
commitfe2fbc5913258ef8379852c6d45fcf226b09900b (patch)
tree920bb4c04d634092109c3609e377025e35e45ecf
parent34802014ca0c9546e73292260aab5e4017ffcd9a (diff)
downloadgitpython-fe2fbc5913258ef8379852c6d45fcf226b09900b.tar.gz
Remote.fetch|pull() will not use poll/threads anymore as only stderr is read.
This simplification should improve performance and remove issues like those in #232. NOTE: Debug code is still contained here
-rw-r--r--git/remote.py13
-rw-r--r--git/test/test_remote.py1
2 files changed, 10 insertions, 4 deletions
diff --git a/git/remote.py b/git/remote.py
index 216858c0..5d9cba1b 100644
--- a/git/remote.py
+++ b/git/remote.py
@@ -525,8 +525,10 @@ class Remote(LazyMixin, Iterable):
progress_handler = progress.new_message_handler()
stderr_fetch = open(join(self.repo.git_dir, '%03i_debug_git-python_stderr' % self.fetch_no), 'wb')
- def my_progress_handler(line):
- stderr_fetch.write((line + '\n').encode(defenc))
+ for line in proc.stderr:
+ line = line.decode(defenc)
+ stderr_fetch.write((line).encode(defenc))
+ line = line.rstrip()
for pline in progress_handler(line):
if line.startswith('fatal:'):
raise GitCommandError(("Error when fetching: %s" % line,), 2)
@@ -541,12 +543,13 @@ class Remote(LazyMixin, Iterable):
# end
# We are only interested in stderr here ...
- handle_process_output(proc, None, my_progress_handler, finalize_process)
+ finalize_process(proc)
stderr_fetch.close()
# read head information
import shutil
- shutil.copyfile(join(self.repo.git_dir, 'FETCH_HEAD'), join(self.repo.git_dir, '%03i_debug_git-python_FETCH_HEAD' % self.fetch_no))
+ shutil.copyfile(join(self.repo.git_dir, 'FETCH_HEAD'),
+ join(self.repo.git_dir, '%03i_debug_git-python_FETCH_HEAD' % self.fetch_no))
self.fetch_no += 1
fp = open(join(self.repo.git_dir, 'FETCH_HEAD'), 'rb')
fetch_head_info = [l.decode(defenc) for l in fp.readlines()]
@@ -615,6 +618,7 @@ class Remote(LazyMixin, Iterable):
args = [refspec]
proc = self.repo.git.fetch(self, *args, with_extended_output=True, as_process=True, v=True, **kwargs)
+ proc.stdout.close()
res = self._get_fetch_info_from_stderr(proc, progress or RemoteProgress())
if hasattr(self.repo.odb, 'update_cache'):
self.repo.odb.update_cache()
@@ -630,6 +634,7 @@ class Remote(LazyMixin, Iterable):
:return: Please see 'fetch' method """
kwargs = add_progress(kwargs, self.repo.git, progress)
proc = self.repo.git.pull(self, refspec, with_extended_output=True, as_process=True, v=True, **kwargs)
+ proc.stdout.close()
res = self._get_fetch_info_from_stderr(proc, progress or RemoteProgress())
if hasattr(self.repo.odb, 'update_cache'):
self.repo.odb.update_cache()
diff --git a/git/test/test_remote.py b/git/test/test_remote.py
index 75dc19c5..110f1fa5 100644
--- a/git/test/test_remote.py
+++ b/git/test/test_remote.py
@@ -348,6 +348,7 @@ class TestRemote(TestBase):
new_head = Head.create(rw_repo, "my_new_branch")
progress = TestRemoteProgress()
res = remote.push(new_head, progress)
+ assert len(res) > 0
assert res[0].flags & PushInfo.NEW_HEAD
progress.make_assertion()
self._do_test_push_result(res, remote)