From 7bbaac26906863b9a09158346218457befb2821a Mon Sep 17 00:00:00 2001 From: Kostis Anagnostopoulos Date: Mon, 26 Sep 2016 12:32:28 +0200 Subject: test, #519: Popen() universal_newlin.es NoWindow in Winfoes + More win-fixes: + Do not check unicode files in < py3. + util, #519: x4 timeout of lock-file blocking, failing in Appveyor. --- git/index/fun.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'git/index/fun.py') diff --git a/git/index/fun.py b/git/index/fun.py index 4dd32b19..6026e232 100644 --- a/git/index/fun.py +++ b/git/index/fun.py @@ -12,9 +12,11 @@ from stat import ( from io import BytesIO import os +import sys import subprocess from git.util import IndexFileSHA1Writer +from git.cmd import Git from git.exc import ( UnmergedEntriesError, HookExecutionError @@ -74,7 +76,9 @@ def run_commit_hook(name, index): stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=index.repo.working_dir, - close_fds=(os.name == 'posix')) + close_fds=(os.name == 'posix'), + universal_newlines=True, + creationflags=Git.CREATE_NO_WINDOW if sys.platform == 'win32' else 0,) stdout, stderr = cmd.communicate() cmd.stdout.close() cmd.stderr.close() -- cgit v1.2.3 From 45f8f20bdf1447fbfebd19a07412d337626ed6b0 Mon Sep 17 00:00:00 2001 From: Kostis Anagnostopoulos Date: Mon, 26 Sep 2016 19:42:42 +0200 Subject: Win, #519: FIX WinHangs: Popen() CREATE_NEW_PROCESS_GROUP to allow kill + FIXED most hangs BUT no more `git-daemon` un-killable! + Use logger for utils to replace stray print(). --- git/index/fun.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'git/index/fun.py') diff --git a/git/index/fun.py b/git/index/fun.py index 6026e232..818847a2 100644 --- a/git/index/fun.py +++ b/git/index/fun.py @@ -12,11 +12,10 @@ from stat import ( from io import BytesIO import os -import sys import subprocess from git.util import IndexFileSHA1Writer -from git.cmd import Git +from git.cmd import PROC_CREATIONFLAGS from git.exc import ( UnmergedEntriesError, HookExecutionError @@ -78,7 +77,7 @@ def run_commit_hook(name, index): cwd=index.repo.working_dir, close_fds=(os.name == 'posix'), universal_newlines=True, - creationflags=Git.CREATE_NO_WINDOW if sys.platform == 'win32' else 0,) + creationflags=PROC_CREATIONFLAGS,) stdout, stderr = cmd.communicate() cmd.stdout.close() cmd.stderr.close() -- cgit v1.2.3 From f495e94028bfddc264727ffc464cd694ddd05ab8 Mon Sep 17 00:00:00 2001 From: Kostis Anagnostopoulos Date: Mon, 26 Sep 2016 20:41:41 +0200 Subject: src, #519: collect all is_() calls --- git/index/fun.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'git/index/fun.py') diff --git a/git/index/fun.py b/git/index/fun.py index 818847a2..98e2d3a0 100644 --- a/git/index/fun.py +++ b/git/index/fun.py @@ -43,7 +43,8 @@ from gitdb.typ import str_tree_type from git.compat import ( defenc, force_text, - force_bytes + force_bytes, + is_posix, ) S_IFGITLINK = S_IFLNK | S_IFDIR # a submodule @@ -75,7 +76,7 @@ def run_commit_hook(name, index): stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=index.repo.working_dir, - close_fds=(os.name == 'posix'), + close_fds=(is_posix()), universal_newlines=True, creationflags=PROC_CREATIONFLAGS,) stdout, stderr = cmd.communicate() -- cgit v1.2.3 From 618e6259ef03a4b25415bae31a7540ac5eb2e38a Mon Sep 17 00:00:00 2001 From: Kostis Anagnostopoulos Date: Mon, 26 Sep 2016 22:20:33 +0200 Subject: test, #519: Try appveyor advice for never-ending builds + see http://help.appveyor.com/discussions/problems/5334-nosetests-finsih-bu-build-stuck-and-next-job-dealys-to-start + Use `io.DEFAULT_BUFFER_SIZE`. + test_commit: replace asserts with unittest-asserts. - TRY Popen() NO universal_newlines: NO, reverted in next commits. + [travisci skip] --- git/index/fun.py | 1 - 1 file changed, 1 deletion(-) (limited to 'git/index/fun.py') diff --git a/git/index/fun.py b/git/index/fun.py index 98e2d3a0..64312300 100644 --- a/git/index/fun.py +++ b/git/index/fun.py @@ -77,7 +77,6 @@ def run_commit_hook(name, index): stderr=subprocess.PIPE, cwd=index.repo.working_dir, close_fds=(is_posix()), - universal_newlines=True, creationflags=PROC_CREATIONFLAGS,) stdout, stderr = cmd.communicate() cmd.stdout.close() -- cgit v1.2.3 From e61439b3018b0b9a8eb43e59d0d7cf32041e2fed Mon Sep 17 00:00:00 2001 From: Kostis Anagnostopoulos Date: Tue, 27 Sep 2016 16:05:58 +0200 Subject: src: constify is_() calls + TCs: unittest-asserts for git-tests. --- git/index/fun.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'git/index/fun.py') diff --git a/git/index/fun.py b/git/index/fun.py index 64312300..1e931b7c 100644 --- a/git/index/fun.py +++ b/git/index/fun.py @@ -76,7 +76,7 @@ def run_commit_hook(name, index): stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=index.repo.working_dir, - close_fds=(is_posix()), + close_fds=(is_posix), creationflags=PROC_CREATIONFLAGS,) stdout, stderr = cmd.communicate() cmd.stdout.close() -- cgit v1.2.3 From 4cede2368aa980e30340f0ed0a1906d65fe1046c Mon Sep 17 00:00:00 2001 From: Kostis Anagnostopoulos Date: Tue, 27 Sep 2016 17:09:41 +0200 Subject: Win, #519: Ensure fixtures & bashscript checked-out eol=lf + FIX all Diff TCs. --- git/index/fun.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'git/index/fun.py') diff --git a/git/index/fun.py b/git/index/fun.py index 1e931b7c..80db46b1 100644 --- a/git/index/fun.py +++ b/git/index/fun.py @@ -76,7 +76,7 @@ def run_commit_hook(name, index): stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=index.repo.working_dir, - close_fds=(is_posix), + close_fds=is_posix, creationflags=PROC_CREATIONFLAGS,) stdout, stderr = cmd.communicate() cmd.stdout.close() -- cgit v1.2.3 From cf2335af23fb693549d6c4e72b65f97afddc5f64 Mon Sep 17 00:00:00 2001 From: Kostis Anagnostopoulos Date: Wed, 28 Sep 2016 01:47:49 +0200 Subject: Win, hook, #519: Consume Hook Popen-proc out of GIL + HookException thrown on Popen, and were missed on Windows. + No SHELL on Popen?? + Minor fixes: + Try harder to delete trees - no remorses. + Simplify exception reprs. + Unittest-ize test_index assertions. --- git/index/fun.py | 39 ++++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 17 deletions(-) (limited to 'git/index/fun.py') diff --git a/git/index/fun.py b/git/index/fun.py index 80db46b1..0179625a 100644 --- a/git/index/fun.py +++ b/git/index/fun.py @@ -14,8 +14,8 @@ from io import BytesIO import os import subprocess -from git.util import IndexFileSHA1Writer -from git.cmd import PROC_CREATIONFLAGS +from git.util import IndexFileSHA1Writer, finalize_process +from git.cmd import PROC_CREATIONFLAGS, handle_process_output from git.exc import ( UnmergedEntriesError, HookExecutionError @@ -71,21 +71,26 @@ def run_commit_hook(name, index): env = os.environ.copy() env['GIT_INDEX_FILE'] = index.path env['GIT_EDITOR'] = ':' - cmd = subprocess.Popen(hp, - env=env, - stdout=subprocess.PIPE, - stderr=subprocess.PIPE, - cwd=index.repo.working_dir, - close_fds=is_posix, - creationflags=PROC_CREATIONFLAGS,) - stdout, stderr = cmd.communicate() - cmd.stdout.close() - cmd.stderr.close() - - if cmd.returncode != 0: - stdout = force_text(stdout, defenc) - stderr = force_text(stderr, defenc) - raise HookExecutionError(hp, cmd.returncode, stdout, stderr) + try: + cmd = subprocess.Popen(hp, + env=env, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + cwd=index.repo.working_dir, + close_fds=is_posix, + creationflags=PROC_CREATIONFLAGS,) + except Exception as ex: + raise HookExecutionError(hp, ex) + else: + stdout = [] + stderr = [] + handle_process_output(cmd, stdout.append, stderr.append, finalize_process) + stdout = ''.join(stdout) + stderr = ''.join(stderr) + if cmd.returncode != 0: + stdout = force_text(stdout, defenc) + stderr = force_text(stderr, defenc) + raise HookExecutionError(hp, cmd.returncode, stdout, stderr) # end handle return code -- cgit v1.2.3 From 395955609dfd711cc4558e2b618450f3514b28c1 Mon Sep 17 00:00:00 2001 From: Kostis Anagnostopoulos Date: Thu, 29 Sep 2016 01:07:41 +0200 Subject: FIX hook TC on PY3+Win & indeterministic lock timing. + Cannot `index.path` into ENV, it is bytes! + The hook TC never runs on linux! + Unblock removal of odbfile in perf-large streams TC. + Attempt to unblock removal of submodule file by intensive cleaning. more unblock files --- git/index/fun.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'git/index/fun.py') diff --git a/git/index/fun.py b/git/index/fun.py index 0179625a..74ac929e 100644 --- a/git/index/fun.py +++ b/git/index/fun.py @@ -41,10 +41,13 @@ from .util import ( from gitdb.base import IStream from gitdb.typ import str_tree_type from git.compat import ( + PY3, defenc, force_text, force_bytes, is_posix, + safe_encode, + safe_decode, ) S_IFGITLINK = S_IFLNK | S_IFDIR # a submodule @@ -69,7 +72,7 @@ def run_commit_hook(name, index): return env = os.environ.copy() - env['GIT_INDEX_FILE'] = index.path + env['GIT_INDEX_FILE'] = safe_decode(index.path) if PY3 else safe_encode(index.path) env['GIT_EDITOR'] = ':' try: cmd = subprocess.Popen(hp, -- cgit v1.2.3