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

Commit6e98416

Browse files
committed
remote,#519: INCOMPLETE FIX-2 double-decoding push-infos
+ Unicode PY2/3 issues fixed also in pump stream func.
1 parent44c6d0b commit6e98416

File tree

3 files changed

+23
-13
lines changed

3 files changed

+23
-13
lines changed

‎git/cmd.py‎

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -88,26 +88,34 @@ def handle_process_output(process, stdout_handler, stderr_handler, finalizer, de
8888
Set it to False if `universal_newline == True` (then streams are in text-mode)
8989
or if decoding must happen later (i.e. for Diffs).
9090
"""
91+
ifdecode_streams:
92+
ZERO=b''
93+
LF=b'\n'
94+
CR=b'\r'
95+
else:
96+
ZERO=u''
97+
LF=u'\n'
98+
CR=u'\r'
9199

92100
def_parse_lines_from_buffer(buf):
93-
line=b''
101+
line=ZERO
94102
bi=0
95103
lb=len(buf)
96104
whilebi<lb:
97-
char=_bchr(buf[bi])
105+
char=buf[bi]
98106
bi+=1
99107

100-
ifcharin (b'\r',b'\n')andline:
101-
yieldbi,line+b'\n'
102-
line=b''
108+
ifcharin (LF,CR)andline:
109+
yieldbi,line+LF
110+
line=ZERO
103111
else:
104112
line+=char
105113
# END process parsed line
106114
# END while file is not done reading
107115
# end
108116

109117
def_read_lines_from_fno(fno,last_buf_list):
110-
buf=os.read(fno,mmap.PAGESIZE)
118+
buf=fno.read(mmap.PAGESIZE)
111119
buf=last_buf_list[0]+buf
112120

113121
bi=0
@@ -192,8 +200,8 @@ def pump_stream(cmdline, name, stream, is_decode, handler):
192200
else:
193201
# poll is preferred, as select is limited to file handles up to 1024 ... . This could otherwise be
194202
# an issue for us, as it matters how many handles our own process has
195-
fdmap= {outfn: (stdout_handler, [b''],decode_streams),
196-
errfn: (stderr_handler, [b''],decode_streams)}
203+
fdmap= {outfn: (process.stdout,stdout_handler, [ZERO],decode_streams),
204+
errfn: (process.stderr,stderr_handler, [ZERO],decode_streams)}
197205

198206
READ_ONLY=select.POLLIN|select.POLLPRI|select.POLLHUP|select.POLLERR# @UndefinedVariable
199207
CLOSED=select.POLLHUP|select.POLLERR# @UndefinedVariable
@@ -217,7 +225,7 @@ def pump_stream(cmdline, name, stream, is_decode, handler):
217225
ifresult&CLOSED:
218226
closed_streams.add(fd)
219227
else:
220-
_dispatch_lines(fd,*fdmap[fd])
228+
_dispatch_lines(*fdmap[fd])
221229
# end handle closed stream
222230
# end for each poll-result tuple
223231

@@ -227,8 +235,8 @@ def pump_stream(cmdline, name, stream, is_decode, handler):
227235
# end endless loop
228236

229237
# Depelete all remaining buffers
230-
forfno,(handler,buf_list,decode)infdmap.items():
231-
_deplete_buffer(fno,handler,buf_list,decode)
238+
forfno,argsinfdmap.items():
239+
_deplete_buffer(*args)
232240
# end for each file handle
233241

234242
forfnoinfdmap.keys():

‎git/exc.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ class CommandError(UnicodeMixin, Exception):
3434
_msg=u"Cmd('%s') failed%s"
3535

3636
def__init__(self,command,status=None,stderr=None,stdout=None):
37-
assertisinstance(command, (tuple,list)),command
37+
ifnotisinstance(command, (tuple,list)):
38+
command=command.split()
3839
self.command=command
3940
self.status=status
4041
ifstatus:

‎git/test/lib/helper.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,8 @@ def remote_repo_creator(self):
301301
try:
302302
gd.proc.kill()
303303
except:
304-
pass## Either it has died (and we're here), or it won't die, again here...
304+
## Either it has died (and we're here), or it won't die, again here...
305+
pass
305306

306307
rw_repo.git.clear_cache()
307308
rw_remote_repo.git.clear_cache()

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2026 Movatter.jp