Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit882ebb1

Browse files
uri-canvaByron
authored andcommitted
Take advantage of universal newlines.
1 parentfdb1dc7 commit882ebb1

File tree

1 file changed

+83
-90
lines changed

1 file changed

+83
-90
lines changed

‎git/util.py

Lines changed: 83 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -379,101 +379,94 @@ def _parse_progress_line(self, line):
379379
380380
- Lines that do not contain progress info are stored in :attr:`other_lines`.
381381
- Lines that seem to contain an error (i.e. start with error: or fatal:) are stored
382-
in :attr:`error_lines`.
383-
384-
:return: list(line, ...) list of lines that could not be processed"""
382+
in :attr:`error_lines`."""
385383
# handle
386384
# Counting objects: 4, done.
387-
# Compressing objects: 50% (1/2) \rCompressing objects: 100% (2/2) \rCompressing objects: 100% (2/2), done.
385+
# Compressing objects: 50% (1/2)
386+
# Compressing objects: 100% (2/2)
387+
# Compressing objects: 100% (2/2), done.
388388
self._cur_line=line=line.decode('utf-8')ifisinstance(line,bytes)elseline
389389
iflen(self.error_lines)>0orself._cur_line.startswith(('error:','fatal:')):
390390
self.error_lines.append(self._cur_line)
391-
return []
392-
393-
sub_lines=line.split('\r')
394-
failed_lines= []
395-
forslineinsub_lines:
396-
# find escape characters and cut them away - regex will not work with
397-
# them as they are non-ascii. As git might expect a tty, it will send them
398-
last_valid_index=None
399-
fori,cinenumerate(reversed(sline)):
400-
iford(c)<32:
401-
# its a slice index
402-
last_valid_index=-i-1
403-
# END character was non-ascii
404-
# END for each character in sline
405-
iflast_valid_indexisnotNone:
406-
sline=sline[:last_valid_index]
407-
# END cut away invalid part
408-
sline=sline.rstrip()
409-
410-
cur_count,max_count=None,None
411-
match=self.re_op_relative.match(sline)
412-
ifmatchisNone:
413-
match=self.re_op_absolute.match(sline)
414-
415-
ifnotmatch:
416-
self.line_dropped(sline)
417-
failed_lines.append(sline)
418-
continue
419-
# END could not get match
420-
421-
op_code=0
422-
remote,op_name,percent,cur_count,max_count,message=match.groups()# @UnusedVariable
423-
424-
# get operation id
425-
ifop_name=="Counting objects":
426-
op_code|=self.COUNTING
427-
elifop_name=="Compressing objects":
428-
op_code|=self.COMPRESSING
429-
elifop_name=="Writing objects":
430-
op_code|=self.WRITING
431-
elifop_name=='Receiving objects':
432-
op_code|=self.RECEIVING
433-
elifop_name=='Resolving deltas':
434-
op_code|=self.RESOLVING
435-
elifop_name=='Finding sources':
436-
op_code|=self.FINDING_SOURCES
437-
elifop_name=='Checking out files':
438-
op_code|=self.CHECKING_OUT
439-
else:
440-
# Note: On windows it can happen that partial lines are sent
441-
# Hence we get something like "CompreReceiving objects", which is
442-
# a blend of "Compressing objects" and "Receiving objects".
443-
# This can't really be prevented, so we drop the line verbosely
444-
# to make sure we get informed in case the process spits out new
445-
# commands at some point.
446-
self.line_dropped(sline)
447-
# Note: Don't add this line to the failed lines, as we have to silently
448-
# drop it
449-
self.other_lines.extend(failed_lines)
450-
returnfailed_lines
451-
# END handle op code
452-
453-
# figure out stage
454-
ifop_codenotinself._seen_ops:
455-
self._seen_ops.append(op_code)
456-
op_code|=self.BEGIN
457-
# END begin opcode
458-
459-
ifmessageisNone:
460-
message=''
461-
# END message handling
462-
463-
message=message.strip()
464-
ifmessage.endswith(self.DONE_TOKEN):
465-
op_code|=self.END
466-
message=message[:-len(self.DONE_TOKEN)]
467-
# END end message handling
468-
message=message.strip(self.TOKEN_SEPARATOR)
469-
470-
self.update(op_code,
471-
cur_countandfloat(cur_count),
472-
max_countandfloat(max_count),
473-
message)
474-
# END for each sub line
475-
self.other_lines.extend(failed_lines)
476-
returnfailed_lines
391+
return
392+
393+
# find escape characters and cut them away - regex will not work with
394+
# them as they are non-ascii. As git might expect a tty, it will send them
395+
last_valid_index=None
396+
fori,cinenumerate(reversed(line)):
397+
iford(c)<32:
398+
# its a slice index
399+
last_valid_index=-i-1
400+
# END character was non-ascii
401+
# END for each character in line
402+
iflast_valid_indexisnotNone:
403+
line=line[:last_valid_index]
404+
# END cut away invalid part
405+
line=line.rstrip()
406+
407+
cur_count,max_count=None,None
408+
match=self.re_op_relative.match(line)
409+
ifmatchisNone:
410+
match=self.re_op_absolute.match(line)
411+
412+
ifnotmatch:
413+
self.line_dropped(line)
414+
self.other_lines.append(line)
415+
return
416+
# END could not get match
417+
418+
op_code=0
419+
remote,op_name,percent,cur_count,max_count,message=match.groups()# @UnusedVariable
420+
421+
# get operation id
422+
ifop_name=="Counting objects":
423+
op_code|=self.COUNTING
424+
elifop_name=="Compressing objects":
425+
op_code|=self.COMPRESSING
426+
elifop_name=="Writing objects":
427+
op_code|=self.WRITING
428+
elifop_name=='Receiving objects':
429+
op_code|=self.RECEIVING
430+
elifop_name=='Resolving deltas':
431+
op_code|=self.RESOLVING
432+
elifop_name=='Finding sources':
433+
op_code|=self.FINDING_SOURCES
434+
elifop_name=='Checking out files':
435+
op_code|=self.CHECKING_OUT
436+
else:
437+
# Note: On windows it can happen that partial lines are sent
438+
# Hence we get something like "CompreReceiving objects", which is
439+
# a blend of "Compressing objects" and "Receiving objects".
440+
# This can't really be prevented, so we drop the line verbosely
441+
# to make sure we get informed in case the process spits out new
442+
# commands at some point.
443+
self.line_dropped(line)
444+
# Note: Don't add this line to the other lines, as we have to silently
445+
# drop it
446+
return
447+
# END handle op code
448+
449+
# figure out stage
450+
ifop_codenotinself._seen_ops:
451+
self._seen_ops.append(op_code)
452+
op_code|=self.BEGIN
453+
# END begin opcode
454+
455+
ifmessageisNone:
456+
message=''
457+
# END message handling
458+
459+
message=message.strip()
460+
ifmessage.endswith(self.DONE_TOKEN):
461+
op_code|=self.END
462+
message=message[:-len(self.DONE_TOKEN)]
463+
# END end message handling
464+
message=message.strip(self.TOKEN_SEPARATOR)
465+
466+
self.update(op_code,
467+
cur_countandfloat(cur_count),
468+
max_countandfloat(max_count),
469+
message)
477470

478471
defnew_message_handler(self):
479472
"""

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp