diff options
author | Kostis Anagnostopoulos <ankostis@gmail.com> | 2016-09-28 01:05:38 +0200 |
---|---|---|
committer | Kostis Anagnostopoulos <ankostis@gmail.com> | 2016-09-28 03:35:38 +0200 |
commit | a5db3d3c49ebe559cb80983d7bb855d4adf1b887 (patch) | |
tree | 8cc2b645e97c5420978ee8fcadc528e878fa99d9 /git/test/test_diff.py | |
parent | 467416356a96148bcb01feb771f6ea20e5215727 (diff) | |
download | gitpython-a5db3d3c49ebe559cb80983d7bb855d4adf1b887.tar.gz |
io, dif: #519: FIX DIFF freeze when reading from GIL
+ CAUSE: In Windows, Diffs freeze while reading Popen streams,
probably buffers smaller; good-thin(TM) in this case because reading a
Popen-proc from the launching-thread freezes GIL. The alternative to
use `proc.communicate()` also relies on big buffers.
+ SOLUTION: Use `cmd.handle_process_output()` to consume Diff-proc
streams.
+ Retroffited `handle_process_output()` code to support also
byte-streams, both Threading(Windows) and Select/Poll (Posix) paths
updated.
- TODO: Unfortunately, `Diff._index_from_patch_format()` still slurps
input; need to re-phrase header-regexes linewise to resolve it.
Diffstat (limited to 'git/test/test_diff.py')
-rw-r--r-- | git/test/test_diff.py | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/git/test/test_diff.py b/git/test/test_diff.py index a8960297..d34d84e3 100644 --- a/git/test/test_diff.py +++ b/git/test/test_diff.py @@ -79,7 +79,7 @@ class TestDiff(TestBase): def test_list_from_string_new_mode(self): output = StringProcessAdapter(fixture('diff_new_mode')) - diffs = Diff._index_from_patch_format(self.rorepo, output.stdout) + diffs = Diff._index_from_patch_format(self.rorepo, output) self._assert_diff_format(diffs) assert_equal(1, len(diffs)) @@ -87,7 +87,7 @@ class TestDiff(TestBase): def test_diff_with_rename(self): output = StringProcessAdapter(fixture('diff_rename')) - diffs = Diff._index_from_patch_format(self.rorepo, output.stdout) + diffs = Diff._index_from_patch_format(self.rorepo, output) self._assert_diff_format(diffs) assert_equal(1, len(diffs)) @@ -102,7 +102,7 @@ class TestDiff(TestBase): assert isinstance(str(diff), str) output = StringProcessAdapter(fixture('diff_rename_raw')) - diffs = Diff._index_from_raw_format(self.rorepo, output.stdout) + diffs = Diff._index_from_raw_format(self.rorepo, output) self.assertEqual(len(diffs), 1) diff = diffs[0] self.assertIsNotNone(diff.renamed_file) @@ -113,7 +113,7 @@ class TestDiff(TestBase): def test_diff_of_modified_files_not_added_to_the_index(self): output = StringProcessAdapter(fixture('diff_abbrev-40_full-index_M_raw_no-color')) - diffs = Diff._index_from_raw_format(self.rorepo, output.stdout) + diffs = Diff._index_from_raw_format(self.rorepo, output) self.assertEqual(len(diffs), 1, 'one modification') self.assertEqual(len(list(diffs.iter_change_type('M'))), 1, 'one modification') @@ -126,7 +126,7 @@ class TestDiff(TestBase): ) def test_binary_diff(self, case): method, file_name = case - res = method(None, StringProcessAdapter(fixture(file_name)).stdout) + res = method(None, StringProcessAdapter(fixture(file_name))) self.assertEqual(len(res), 1) self.assertEqual(len(list(res.iter_change_type('M'))), 1) if res[0].diff: @@ -137,7 +137,7 @@ class TestDiff(TestBase): def test_diff_index(self): output = StringProcessAdapter(fixture('diff_index_patch')) - res = Diff._index_from_patch_format(None, output.stdout) + res = Diff._index_from_patch_format(None, output) self.assertEqual(len(res), 6) for dr in res: self.assertTrue(dr.diff.startswith(b'@@'), dr) @@ -149,7 +149,7 @@ class TestDiff(TestBase): def test_diff_index_raw_format(self): output = StringProcessAdapter(fixture('diff_index_raw')) - res = Diff._index_from_raw_format(None, output.stdout) + res = Diff._index_from_raw_format(None, output) self.assertIsNotNone(res[0].deleted_file) self.assertIsNone(res[0].b_path,) @@ -171,7 +171,7 @@ class TestDiff(TestBase): def test_diff_unsafe_paths(self): output = StringProcessAdapter(fixture('diff_patch_unsafe_paths')) - res = Diff._index_from_patch_format(None, output.stdout) + res = Diff._index_from_patch_format(None, output) # The "Additions" self.assertEqual(res[0].b_path, u'path/ starting with a space') @@ -207,12 +207,12 @@ class TestDiff(TestBase): for fixture_name in fixtures: diff_proc = StringProcessAdapter(fixture(fixture_name)) - Diff._index_from_patch_format(self.rorepo, diff_proc.stdout) + Diff._index_from_patch_format(self.rorepo, diff_proc) # END for each fixture def test_diff_with_spaces(self): data = StringProcessAdapter(fixture('diff_file_with_spaces')) - diff_index = Diff._index_from_patch_format(self.rorepo, data.stdout) + diff_index = Diff._index_from_patch_format(self.rorepo, data) self.assertIsNone(diff_index[0].a_path, repr(diff_index[0].a_path)) self.assertEqual(diff_index[0].b_path, u'file with spaces', repr(diff_index[0].b_path)) |