From 8ea7e265d1549613c12cbe42a2e012527c1a97e4 Mon Sep 17 00:00:00 2001 From: Kostis Anagnostopoulos Date: Sat, 1 Oct 2016 20:14:50 +0200 Subject: repo, cmd: DROP UNEEDED Win path for chcwd & check for '~' homedir + Do not abspath twice when contructing cloned repo. + Add `git.repo.base` logger. --- git/cmd.py | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) (limited to 'git/cmd.py') diff --git a/git/cmd.py b/git/cmd.py index a92b2f3c..f1033dde 100644 --- a/git/cmd.py +++ b/git/cmd.py @@ -42,12 +42,12 @@ from .util import ( ) -execute_kwargs = set(('istream', 'with_keep_cwd', 'with_extended_output', +execute_kwargs = set(('istream', 'with_extended_output', 'with_exceptions', 'as_process', 'stdout_as_string', 'output_stream', 'with_stdout', 'kill_after_timeout', 'universal_newlines', 'shell')) -log = logging.getLogger('git.cmd') +log = logging.getLogger(__name__) log.addHandler(logging.NullHandler()) __all__ = ('Git',) @@ -418,7 +418,6 @@ class Git(LazyMixin): def execute(self, command, istream=None, - with_keep_cwd=False, with_extended_output=False, with_exceptions=True, as_process=False, @@ -441,11 +440,6 @@ class Git(LazyMixin): :param istream: Standard input filehandle passed to subprocess.Popen. - :param with_keep_cwd: - Whether to use the current working directory from os.getcwd(). - The cmd otherwise uses its own working_dir that it has been initialized - with if possible. - :param with_extended_output: Whether to return a (status, stdout, stderr) tuple. @@ -518,10 +512,7 @@ class Git(LazyMixin): log.info(' '.join(command)) # Allow the user to have the command executed in their working dir. - if with_keep_cwd or self._working_dir is None: - cwd = os.getcwd() - else: - cwd = self._working_dir + cwd = self._working_dir or os.getcwd() # Start the process env = os.environ.copy() -- cgit v1.2.3 From 4b586fbb94d5acc6e06980a8a96f66771280beda Mon Sep 17 00:00:00 2001 From: Kostis Anagnostopoulos Date: Tue, 4 Oct 2016 14:29:28 +0200 Subject: daemon, #525: FIX remote urls in config-files + Parse most remote & config-urls \-->/. + Used relative daemon-paths. + Use git-daemon PORT above 10k; on Windows all below need Admin rights. +FIXED git-daemon @with_rw_and_rw_remote_repo(): + test_base.test_with_rw_remote_and_rw_repo() PASS. + test_remote.test_base() now freezes! (so still hidden win_err) + repo_test: minor finally delete test-repos created inside this repo. + util: delete unused `absolute_project_path()`. --- git/cmd.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'git/cmd.py') diff --git a/git/cmd.py b/git/cmd.py index f1033dde..59f17448 100644 --- a/git/cmd.py +++ b/git/cmd.py @@ -186,14 +186,18 @@ class Git(LazyMixin): # Override this value using `Git.USE_SHELL = True` USE_SHELL = False - class AutoInterrupt(object): + @classmethod + def polish_url(cls, url): + return url.replace("\\\\", "\\").replace("\\", "/") + class AutoInterrupt(object): """Kill/Interrupt the stored process instance once this instance goes out of scope. It is used to prevent processes piling up in case iterators stop reading. Besides all attributes are wired through to the contained process object. The wait method was overridden to perform automatic status code checking and possibly raise.""" + __slots__ = ("proc", "args") def __init__(self, proc, args): -- cgit v1.2.3 From 83645971b8e134f45bded528e0e0786819203252 Mon Sep 17 00:00:00 2001 From: Kostis Anagnostopoulos Date: Wed, 12 Oct 2016 21:13:20 +0200 Subject: test, #525: allow disabling freeze errors separately + cmd: use DEVNULL for non PIPEs; no open-file. + TCs: some unitestize-assertions on base & remote TCs. --- git/cmd.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'git/cmd.py') diff --git a/git/cmd.py b/git/cmd.py index 59f17448..aa711168 100644 --- a/git/cmd.py +++ b/git/cmd.py @@ -539,6 +539,9 @@ class Git(LazyMixin): cmd_not_found_exception = OSError # end handle + stdout_sink = (PIPE + if with_stdout + else getattr(subprocess, 'DEVNULL', open(os.devnull, 'wb'))) log.debug("Popen(%s, cwd=%s, universal_newlines=%s, shell=%s)", command, cwd, universal_newlines, shell) try: @@ -548,9 +551,9 @@ class Git(LazyMixin): bufsize=-1, stdin=istream, stderr=PIPE, - stdout=PIPE if with_stdout else open(os.devnull, 'wb'), + stdout=stdout_sink, shell=shell is not None and shell or self.USE_SHELL, - close_fds=(is_posix), # unsupported on windows + close_fds=is_posix, # unsupported on windows universal_newlines=universal_newlines, creationflags=PROC_CREATIONFLAGS, **subprocess_kwargs -- cgit v1.2.3 From 85f38a1bbc8fc4b19ebf2a52a3640b59a5dcf9fe Mon Sep 17 00:00:00 2001 From: Kostis Anagnostopoulos Date: Wed, 12 Oct 2016 23:09:54 +0200 Subject: remote, #525: pump fetch-infos instead of GIL-read stderr + `handle_process_output()` accepts null-finalizer, to pump completely stderr before raising any errors. + test: Enable `TestGit.test_environment()` on Windows (to checks stderr consumption). --- git/cmd.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'git/cmd.py') diff --git a/git/cmd.py b/git/cmd.py index aa711168..ebf2bd75 100644 --- a/git/cmd.py +++ b/git/cmd.py @@ -59,7 +59,8 @@ __all__ = ('Git',) # Documentation ## @{ -def handle_process_output(process, stdout_handler, stderr_handler, finalizer, decode_streams=True): +def handle_process_output(process, stdout_handler, stderr_handler, + finalizer=None, decode_streams=True): """Registers for notifications to lean that process output is ready to read, and dispatches lines to the respective line handlers. This function returns once the finalizer returns @@ -108,10 +109,13 @@ def handle_process_output(process, stdout_handler, stderr_handler, finalizer, de t.start() threads.append(t) + ## FIXME: Why Join?? Will block if `stdin` needs feeding... + # for t in threads: t.join() - return finalizer(process) + if finalizer: + return finalizer(process) def dashify(string): -- cgit v1.2.3 From 5e6827e98c2732863857c0887d5de4138a8ae48b Mon Sep 17 00:00:00 2001 From: Kostis Anagnostopoulos Date: Thu, 13 Oct 2016 00:42:04 +0200 Subject: remote, #525: FIX BUG push-cmd misses error messages + Bug discovered after enabling TC in prev commit and rework of fetch. + remote_tc: unitestize assertions. + util: DEL unused `_mktemp()`. --- git/cmd.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'git/cmd.py') diff --git a/git/cmd.py b/git/cmd.py index ebf2bd75..e3efb25c 100644 --- a/git/cmd.py +++ b/git/cmd.py @@ -247,7 +247,7 @@ class Git(LazyMixin): def __getattr__(self, attr): return getattr(self.proc, attr) - def wait(self, stderr=b''): + def wait(self, stderr=b''): # TODO: Bad choice to mimic `proc.wait()` but with different args. """Wait for the process and return its status code. :param stderr: Previously read value of stderr, in case stderr is already closed. -- cgit v1.2.3 From c8e914eb0dfe6a0eb2de66b6826af5f715aeed6d Mon Sep 17 00:00:00 2001 From: Kostis Anagnostopoulos Date: Fri, 14 Oct 2016 16:50:37 +0200 Subject: cmd, #525: Always include stdout+stderr in exceptions + Ignore `with_extended_output` arg when reaising the exception, keep its behavior when `status==0`. --- git/cmd.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'git/cmd.py') diff --git a/git/cmd.py b/git/cmd.py index e3efb25c..f0757301 100644 --- a/git/cmd.py +++ b/git/cmd.py @@ -649,10 +649,7 @@ class Git(LazyMixin): # END handle debug printing if with_exceptions and status != 0: - if with_extended_output: - raise GitCommandError(command, status, stderr_value, stdout_value) - else: - raise GitCommandError(command, status, stderr_value) + raise GitCommandError(command, status, stderr_value, stdout_value) if isinstance(stdout_value, bytes) and stdout_as_string: # could also be output_stream stdout_value = safe_decode(stdout_value) -- cgit v1.2.3