From 410cf1ec4a9906ffe7eb96b4aa559ce4dd2962d4 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Tue, 7 Jun 2011 19:02:56 +0200 Subject: The --progress flag will now automatically be used if possible when doing any push or fetch operation --- git/db/cmd/base.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'git') diff --git a/git/db/cmd/base.py b/git/db/cmd/base.py index 78adbc6e..cbf4e29b 100644 --- a/git/db/cmd/base.py +++ b/git/db/cmd/base.py @@ -141,6 +141,16 @@ def get_push_info(repo, remotename_or_url, proc, progress): finalize_process(proc) return output +def add_progress(kwargs, git): + """Add the --progress flag to the given kwargs dict if supported by the + git command + :return: possibly altered kwargs""" + v = git.version_info + if v[0] > 1 or v[1] > 7 or v[2] > 0 or v[3] > 3: + kwargs['progress'] = True + #END handle --progress + return kwargs + #} END utilities class CmdRemoteProgress(RemoteProgress): @@ -517,7 +527,7 @@ class CmdTransportMixin(TransportDB): :param refspecs: single string, RefSpec instance or list of such or None. :param progress: RemoteProgress derived instance or None :param **kwargs: Additional arguments to be passed to the git-push process""" - proc = self._git.push(url, refspecs, porcelain=True, as_process=True, **kwargs) + proc = self._git.push(url, refspecs, porcelain=True, as_process=True, **add_progress(kwargs, self.git)) return get_push_info(self, url, proc, CmdRemoteProgress(progress)) def pull(self, url, refspecs=None, progress=None, **kwargs): @@ -527,7 +537,7 @@ class CmdTransportMixin(TransportDB): :param url: may be a remote name or a url :param refspecs: see push() :param progress: see push()""" - proc = self._git.pull(url, refspecs, with_extended_output=True, as_process=True, v=True, **kwargs) + proc = self._git.pull(url, refspecs, with_extended_output=True, as_process=True, v=True, **add_progress(kwargs, self.git)) return get_fetch_info_from_stderr(self, proc, CmdRemoteProgress(progress)) def fetch(self, url, refspecs=None, progress=None, **kwargs): @@ -535,7 +545,7 @@ class CmdTransportMixin(TransportDB): :param url: may be a remote name or a url :param refspecs: see push() :param progress: see push()""" - proc = self._git.fetch(url, refspecs, with_extended_output=True, as_process=True, v=True, **kwargs) + proc = self._git.fetch(url, refspecs, with_extended_output=True, as_process=True, v=True, **add_progress(kwargs, self.git)) return get_fetch_info_from_stderr(self, proc, CmdRemoteProgress(progress)) #} end transport db interface @@ -740,7 +750,7 @@ class CmdHighLevelRepository(HighLevelRepository): # END windows handling try: - proc = git.clone(url, path, with_extended_output=True, as_process=True, v=True, **kwargs) + proc = git.clone(url, path, with_extended_output=True, as_process=True, v=True, **add_progress(kwargs, git)) if progress is not None: digest_process_messages(proc.stderr, progress) #END digest progress messages -- cgit v1.2.1