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/remote.py | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'git/remote.py') diff --git a/git/remote.py b/git/remote.py index 4a8a5ee9..19deefb7 100644 --- a/git/remote.py +++ b/git/remote.py @@ -6,7 +6,6 @@ # Module implementing a remote object allowing easy access to git remotes import re -import os from .config import ( SectionConstraint, @@ -32,7 +31,7 @@ from git.util import ( ) from git.cmd import handle_process_output from gitdb.util import join -from git.compat import (defenc, force_text) +from git.compat import (defenc, force_text, is_win) import logging log = logging.getLogger('git.remote') @@ -113,7 +112,7 @@ class PushInfo(object): self._remote = remote self._old_commit_sha = old_commit self.summary = summary - + @property def old_commit(self): return self._old_commit_sha and self._remote.repo.commit(self._old_commit_sha) or None @@ -377,7 +376,7 @@ class Remote(LazyMixin, Iterable): self.repo = repo self.name = name - if os.name == 'nt': + if is_win(): # some oddity: on windows, python 2.5, it for some reason does not realize # that it has the config_writer property, but instead calls __getattr__ # which will not yield the expected results. 'pinging' the members @@ -635,7 +634,7 @@ class Remote(LazyMixin, Iterable): # end if progress.error_lines(): stderr_text = '\n'.join(progress.error_lines()) - + finalize_process(proc, stderr=stderr_text) # read head information @@ -657,7 +656,7 @@ class Remote(LazyMixin, Iterable): fetch_info_lines = fetch_info_lines[:l_fhi] # end truncate correct list # end sanity check + sanitization - + output.extend(FetchInfo._from_line(self.repo, err_line, fetch_line) for err_line, fetch_line in zip(fetch_info_lines, fetch_head_info)) return output @@ -769,17 +768,17 @@ class Remote(LazyMixin, Iterable): :param refspec: see 'fetch' method :param progress: Can take one of many value types: - + * None to discard progress information * A function (callable) that is called with the progress infomation. - + Signature: ``progress(op_code, cur_count, max_count=None, message='')``. - + `Click here `_ for a description of all arguments given to the function. * An instance of a class derived from ``git.RemoteProgress`` that overrides the ``update()`` function. - + :note: No further progress information is returned after push returns. :param kwargs: Additional arguments to be passed to git-push :return: -- 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/remote.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'git/remote.py') diff --git a/git/remote.py b/git/remote.py index 19deefb7..7a7b4840 100644 --- a/git/remote.py +++ b/git/remote.py @@ -376,7 +376,7 @@ class Remote(LazyMixin, Iterable): self.repo = repo self.name = name - if is_win(): + if is_win: # some oddity: on windows, python 2.5, it for some reason does not realize # that it has the config_writer property, but instead calls __getattr__ # which will not yield the expected results. 'pinging' the members -- cgit v1.2.3 From f11fdf1d9d22a198511b02f3ca90146cfa5deb5c Mon Sep 17 00:00:00 2001 From: Kostis Anagnostopoulos Date: Wed, 28 Sep 2016 14:43:47 +0200 Subject: remote, #519: FIX1-of-2 double-decoding push-infos + When `universal_lines==True` (515a6b9ccf8) must tel `handle_process_output` to stop decoding strings. --- git/remote.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'git/remote.py') diff --git a/git/remote.py b/git/remote.py index 7a7b4840..07f5b432 100644 --- a/git/remote.py +++ b/git/remote.py @@ -681,7 +681,8 @@ class Remote(LazyMixin, Iterable): # END for each line try: - handle_process_output(proc, stdout_handler, progress_handler, finalize_process) + handle_process_output(proc, stdout_handler, progress_handler, finalize_process, + decode_stdout=False, decode_stderr=False) except Exception: if len(output) == 0: raise -- cgit v1.2.3 From 44c6d0b368bc1ec6cd0a97b01678b38788c9bd9c Mon Sep 17 00:00:00 2001 From: Kostis Anagnostopoulos Date: Wed, 28 Sep 2016 05:46:50 +0200 Subject: Proc, #519: Rework error-exc msgs & log thread-pumps errors + No WindowsError exception. + Add `test_exc.py` for unicode issues. + Single-arg for decoding-streams in pump-func. --- git/remote.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'git/remote.py') diff --git a/git/remote.py b/git/remote.py index 07f5b432..58238991 100644 --- a/git/remote.py +++ b/git/remote.py @@ -681,8 +681,7 @@ class Remote(LazyMixin, Iterable): # END for each line try: - handle_process_output(proc, stdout_handler, progress_handler, finalize_process, - decode_stdout=False, decode_stderr=False) + handle_process_output(proc, stdout_handler, progress_handler, finalize_process, decode_streams=False) except Exception: if len(output) == 0: raise -- cgit v1.2.3 From 9a521681ff8614beb8e2c566cf3c475baca22169 Mon Sep 17 00:00:00 2001 From: Kostis Anagnostopoulos Date: Sat, 1 Oct 2016 18:20:13 +0200 Subject: io, #519: ALL open() --> with open() + Some cases had restructuring of code. --- git/remote.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'git/remote.py') diff --git a/git/remote.py b/git/remote.py index 58238991..c2ffcc1a 100644 --- a/git/remote.py +++ b/git/remote.py @@ -638,9 +638,8 @@ class Remote(LazyMixin, Iterable): finalize_process(proc, stderr=stderr_text) # read head information - fp = open(join(self.repo.git_dir, 'FETCH_HEAD'), 'rb') - fetch_head_info = [l.decode(defenc) for l in fp.readlines()] - fp.close() + with open(join(self.repo.git_dir, 'FETCH_HEAD'), 'rb') as fp: + fetch_head_info = [l.decode(defenc) for l in fp.readlines()] l_fil = len(fetch_info_lines) l_fhi = len(fetch_head_info) -- cgit v1.2.3