diff options
Diffstat (limited to 'git/remote.py')
-rw-r--r-- | git/remote.py | 36 |
1 files changed, 17 insertions, 19 deletions
diff --git a/git/remote.py b/git/remote.py index 12129460..d35e1fad 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 @@ -177,7 +176,7 @@ class PushInfo(object): split_token = "..." if control_character == " ": split_token = ".." - old_sha, new_sha = summary.split(' ')[0].split(split_token) + old_sha, new_sha = summary.split(' ')[0].split(split_token) # @UnusedVariable # have to use constructor here as the sha usually is abbreviated old_commit = old_sha # END message handling @@ -263,7 +262,7 @@ class FetchInfo(object): # parse lines control_character, operation, local_remote_ref, remote_local_ref, note = match.groups() try: - new_hex_sha, fetch_operation, fetch_note = fetch_line.split("\t") + new_hex_sha, fetch_operation, fetch_note = fetch_line.split("\t") # @UnusedVariable ref_type_name, fetch_note = fetch_note.split(' ', 1) except ValueError: # unpack error raise ValueError("Failed to parse FETCH_HEAD line: %r" % fetch_line) @@ -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 @@ -445,7 +444,7 @@ class Remote(LazyMixin, Iterable): def iter_items(cls, repo): """:return: Iterator yielding Remote objects of the given repository""" for section in repo.config_reader("repository").sections(): - if not section.startswith('remote'): + if not section.startswith('remote '): continue lbound = section.find('"') rbound = section.rfind('"') @@ -626,8 +625,8 @@ class Remote(LazyMixin, Iterable): for pline in progress_handler(line): # END handle special messages for cmd in cmds: - if len(line) > 1 and line[0] == ' ' and line[1] == cmd: - fetch_info_lines.append(line) + if len(pline) > 1 and pline[0] == ' ' and pline[1] == cmd: + fetch_info_lines.append(pline) continue # end find command code # end for each comand code we know @@ -635,13 +634,12 @@ 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 - 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) @@ -657,7 +655,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 @@ -682,7 +680,7 @@ 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_streams=False) except Exception: if len(output) == 0: raise @@ -769,17 +767,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 <http://goo.gl/NPa7st>`_ 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: |