diff options
author | Barry Scott <barry@barrys-emacs.org> | 2016-05-28 13:23:18 +0100 |
---|---|---|
committer | Barry Scott <barry@barrys-emacs.org> | 2016-05-28 13:23:18 +0100 |
commit | d255f4c8fd905d1cd12bd42b542953d54ac8a8c3 (patch) | |
tree | faffbb7ad5eb0d21ff0920791842aa7446332e1c | |
parent | b4492c7965cd8e3c5faaf28b2a6414b04984720b (diff) | |
parent | c5077dac4c7680c925f4c5e792eeb3c296a3b4c4 (diff) | |
download | gitpython-d255f4c8fd905d1cd12bd42b542953d54ac8a8c3.tar.gz |
Merge remote-tracking branch 'upstream/master'
-rw-r--r-- | .travis.yml | 4 | ||||
-rw-r--r-- | doc/source/intro.rst | 3 | ||||
-rw-r--r-- | git/cmd.py | 13 | ||||
-rw-r--r-- | git/remote.py | 37 |
4 files changed, 40 insertions, 17 deletions
diff --git a/.travis.yml b/.travis.yml index 5c01b3fd..99ecd4aa 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,10 +1,14 @@ language: python python: + - "2.6" - "2.7" - "3.3" - "3.4" - "3.5" # - "pypy" - won't work as smmap doesn't work (see gitdb/.travis.yml for details) +matrix: + allow_failures: + - python: "2.6" git: # a higher depth is needed for most of the tests - must be high enough to not actually be shallow # as we clone our own repository in the process diff --git a/doc/source/intro.rst b/doc/source/intro.rst index 647323c4..6c4e50f5 100644 --- a/doc/source/intro.rst +++ b/doc/source/intro.rst @@ -14,7 +14,8 @@ Requirements ============ * `Python`_ 2.7 or newer - Since GitPython 2.0.0 + Since GitPython 2.0.0. Please note that python 2.6 is still reasonably well supported, but might + deteriorate over time. * `Git`_ 1.7.0 or newer It should also work with older versions, but it may be that some operations involving remotes will not work as expected. @@ -13,7 +13,7 @@ import threading import errno import mmap -from collections import OrderedDict +from git.odict import OrderedDict from contextlib import contextmanager import signal @@ -44,7 +44,8 @@ from git.compat import ( execute_kwargs = ('istream', 'with_keep_cwd', 'with_extended_output', 'with_exceptions', 'as_process', 'stdout_as_string', - 'output_stream', 'with_stdout', 'kill_after_timeout') + 'output_stream', 'with_stdout', 'kill_after_timeout', + 'universal_newlines') log = logging.getLogger('git.cmd') log.addHandler(logging.NullHandler()) @@ -487,6 +488,7 @@ class Git(LazyMixin): stdout_as_string=True, kill_after_timeout=None, with_stdout=True, + universal_newlines=False, **subprocess_kwargs ): """Handles executing the command on the shell and consumes and returns @@ -541,7 +543,9 @@ class Git(LazyMixin): specify may not be the same ones. :param with_stdout: If True, default True, we open stdout on the created process - + :param universal_newlines: + if True, pipes will be opened as text, and lines are split at + all known line endings. :param kill_after_timeout: To specify a timeout in seconds for the git command, after which the process should be killed. This will have no effect if as_process is set to True. It is @@ -605,9 +609,10 @@ class Git(LazyMixin): bufsize=-1, stdin=istream, stderr=PIPE, - stdout=with_stdout and PIPE or open(os.devnull, 'wb'), + stdout=PIPE if with_stdout else open(os.devnull, 'wb'), shell=self.USE_SHELL, close_fds=(os.name == 'posix'), # unsupported on windows + universal_newlines=universal_newlines, **subprocess_kwargs ) except cmd_not_found_exception as err: diff --git a/git/remote.py b/git/remote.py index 320d4e56..0afb4ad3 100644 --- a/git/remote.py +++ b/git/remote.py @@ -20,8 +20,6 @@ from .refs import ( SymbolicReference, TagReference ) - - from git.util import ( LazyMixin, Iterable, @@ -34,7 +32,10 @@ from git.util import ( ) from git.cmd import handle_process_output from gitdb.util import join -from git.compat import defenc +from git.compat import (defenc, force_text) +import logging + +log = logging.getLogger('git.remote') __all__ = ('RemoteProgress', 'PushInfo', 'FetchInfo', 'Remote') @@ -568,8 +569,8 @@ class Remote(LazyMixin, Iterable): progress_handler = progress.new_message_handler() - for line in proc.stderr.readlines(): - line = line.decode(defenc) + for line in proc.stderr: + line = force_text(line) for pline in progress_handler(line): if line.startswith('fatal:') or line.startswith('error:'): raise GitCommandError(("Error when fetching: %s" % line,), 2) @@ -589,11 +590,21 @@ class Remote(LazyMixin, Iterable): fetch_head_info = [l.decode(defenc) for l in fp.readlines()] fp.close() - # NOTE: We assume to fetch at least enough progress lines to allow matching each fetch head line with it. l_fil = len(fetch_info_lines) l_fhi = len(fetch_head_info) - assert l_fil >= l_fhi, "len(%s) <= len(%s)" % (l_fil, l_fhi) - + if l_fil != l_fhi: + msg = "Fetch head lines do not match lines provided via progress information\n" + msg += "length of progress lines %i should be equal to lines in FETCH_HEAD file %i\n" + msg += "Will ignore extra progress lines or fetch head lines." + msg %= (l_fil, l_fhi) + log.debug(msg) + if l_fil < l_fhi: + fetch_head_info = fetch_head_info[:l_fil] + else: + 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 @@ -673,8 +684,8 @@ class Remote(LazyMixin, Iterable): else: args = [refspec] - proc = self.repo.git.fetch(self, *args, as_process=True, with_stdout=False, v=True, - **kwargs) + proc = self.repo.git.fetch(self, *args, as_process=True, with_stdout=False, + universal_newlines=True, v=True, **kwargs) res = self._get_fetch_info_from_stderr(proc, progress) if hasattr(self.repo.odb, 'update_cache'): self.repo.odb.update_cache() @@ -692,7 +703,8 @@ class Remote(LazyMixin, Iterable): # No argument refspec, then ensure the repo's config has a fetch refspec. self._assert_refspec() kwargs = add_progress(kwargs, self.repo.git, progress) - proc = self.repo.git.pull(self, refspec, with_stdout=False, as_process=True, v=True, **kwargs) + proc = self.repo.git.pull(self, refspec, with_stdout=False, as_process=True, + universal_newlines=True, v=True, **kwargs) res = self._get_fetch_info_from_stderr(proc, progress) if hasattr(self.repo.odb, 'update_cache'): self.repo.odb.update_cache() @@ -733,7 +745,8 @@ class Remote(LazyMixin, Iterable): If the operation fails completely, the length of the returned IterableList will be null.""" kwargs = add_progress(kwargs, self.repo.git, progress) - proc = self.repo.git.push(self, refspec, porcelain=True, as_process=True, **kwargs) + proc = self.repo.git.push(self, refspec, porcelain=True, as_process=True, + universal_newlines=True, **kwargs) return self._get_push_info(proc, progress) @property |