Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f6897c7

Browse files
committed
Added additional opcodes to remote progress to make it compatible to newer git versions. This bug existed for quite a while but didn't show up as progress wasn't sent most of the time. All methods that could use a progress will only activate it if a progress is actually given
1 parent ba825ea commit f6897c7

File tree

3 files changed

+26
-16
lines changed

3 files changed

+26
-16
lines changed

git/db/cmd/base.py

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -141,14 +141,17 @@ def get_push_info(repo, remotename_or_url, proc, progress):
141141
finalize_process(proc)
142142
return output
143143

144-
def add_progress(kwargs, git):
144+
def add_progress(kwargs, git, progress):
145145
"""Add the --progress flag to the given kwargs dict if supported by the
146-
git command
146+
git command. If the actual progress in the given progress instance is not
147+
given, we do not request any progress
147148
:return: possibly altered kwargs"""
148-
v = git.version_info
149-
if v[0] > 1 or v[1] > 7 or v[2] > 0 or v[3] > 3:
150-
kwargs['progress'] = True
151-
#END handle --progress
149+
if progress._progress is not None:
150+
v = git.version_info
151+
if v[0] > 1 or v[1] > 7 or v[2] > 0 or v[3] > 3:
152+
kwargs['progress'] = True
153+
#END handle --progress
154+
#END handle progress
152155
return kwargs
153156

154157
#} END utilities
@@ -218,6 +221,10 @@ def _parse_progress_line(self, line):
218221
op_code |= self.COMPRESSING
219222
elif op_name == "Writing objects":
220223
op_code |= self.WRITING
224+
elif op_name == "Receiving objects":
225+
op_code |= self.RECEIVING
226+
elif op_name == "Resolving deltas":
227+
op_code |= self.RESOLVING
221228
else:
222229
raise ValueError("Operation name %r unknown" % op_name)
223230

@@ -527,8 +534,9 @@ def push(self, url, refspecs=None, progress=None, **kwargs):
527534
:param refspecs: single string, RefSpec instance or list of such or None.
528535
:param progress: RemoteProgress derived instance or None
529536
:param **kwargs: Additional arguments to be passed to the git-push process"""
530-
proc = self._git.push(url, refspecs, porcelain=True, as_process=True, **add_progress(kwargs, self.git))
531-
return get_push_info(self, url, proc, CmdRemoteProgress(progress))
537+
progress = CmdRemoteProgress(progress)
538+
proc = self._git.push(url, refspecs, porcelain=True, as_process=True, **add_progress(kwargs, self.git, progress))
539+
return get_push_info(self, url, proc, progress)
532540

533541
def pull(self, url, refspecs=None, progress=None, **kwargs):
534542
"""Fetch and merge the given refspecs.
@@ -537,16 +545,18 @@ def pull(self, url, refspecs=None, progress=None, **kwargs):
537545
:param url: may be a remote name or a url
538546
:param refspecs: see push()
539547
:param progress: see push()"""
540-
proc = self._git.pull(url, refspecs, with_extended_output=True, as_process=True, v=True, **add_progress(kwargs, self.git))
541-
return get_fetch_info_from_stderr(self, proc, CmdRemoteProgress(progress))
548+
progress = CmdRemoteProgress(progress)
549+
proc = self._git.pull(url, refspecs, with_extended_output=True, as_process=True, v=True, **add_progress(kwargs, self.git, progress))
550+
return get_fetch_info_from_stderr(self, proc, progress)
542551

543552
def fetch(self, url, refspecs=None, progress=None, **kwargs):
544553
"""Fetch the latest changes
545554
:param url: may be a remote name or a url
546555
:param refspecs: see push()
547556
:param progress: see push()"""
548-
proc = self._git.fetch(url, refspecs, with_extended_output=True, as_process=True, v=True, **add_progress(kwargs, self.git))
549-
return get_fetch_info_from_stderr(self, proc, CmdRemoteProgress(progress))
557+
progress = CmdRemoteProgress(progress)
558+
proc = self._git.fetch(url, refspecs, with_extended_output=True, as_process=True, v=True, **add_progress(kwargs, self.git, progress))
559+
return get_fetch_info_from_stderr(self, proc, progress)
550560

551561
#} end transport db interface
552562

@@ -750,7 +760,7 @@ def _clone(cls, git, url, path, progress, **kwargs):
750760
# END windows handling
751761

752762
try:
753-
proc = git.clone(url, path, with_extended_output=True, as_process=True, v=True, **add_progress(kwargs, git))
763+
proc = git.clone(url, path, with_extended_output=True, as_process=True, v=True, **add_progress(kwargs, git, progress))
754764
if progress is not None:
755765
digest_process_messages(proc.stderr, progress)
756766
#END digest progress messages

git/db/interface.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,8 +245,8 @@ class RemoteProgress(object):
245245
246246
Subclasses should derive from this type.
247247
"""
248-
_num_op_codes = 5
249-
BEGIN, END, COUNTING, COMPRESSING, WRITING = [1 << x for x in range(_num_op_codes)]
248+
_num_op_codes = 7
249+
BEGIN, END, COUNTING, COMPRESSING, WRITING, RECEIVING, RESOLVING = [1 << x for x in range(_num_op_codes)]
250250
STAGE_MASK = BEGIN|END
251251
OP_MASK = ~STAGE_MASK
252252

git/test/objects/test_submodule.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
class TestRootProgress(RootUpdateProgress):
1616
"""Just prints messages, for now without checking the correctness of the states"""
1717

18-
def update(self, op, index, max_count, message=''):
18+
def update(self, op, index, max_count, message='', input=''):
1919
print message
2020

2121
prog = TestRootProgress()

0 commit comments

Comments
 (0)