Mercurial > hg
comparison mercurial/posix.py @ 22245:234e4c24b980
platform: implement readpipe()
Reading all available data from a pipe has a platform-dependent
implementation.
This patch establishes platform.readpipe() by copying the
inline implementation in sshpeer.readerr(). The implementations
for POSIX and Windows are currently identical. The POSIX
implementation will be changed in a subsequent patch.
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Fri, 15 Aug 2014 20:02:18 -0700 |
parents | a6014018ec28 |
children | 331cbf088c4c |
comparison
equal
deleted
inserted
replaced
22244:172036d60b22 | 22245:234e4c24b980 |
---|---|
565 return st and stat.S_ISLNK(st.st_mode) | 565 return st and stat.S_ISLNK(st.st_mode) |
566 | 566 |
567 def statisexec(st): | 567 def statisexec(st): |
568 '''check whether a stat result is an executable file''' | 568 '''check whether a stat result is an executable file''' |
569 return st and (st.st_mode & 0100 != 0) | 569 return st and (st.st_mode & 0100 != 0) |
570 | |
571 def readpipe(pipe): | |
572 """Read all available data from a pipe.""" | |
573 chunks = [] | |
574 while True: | |
575 size = os.fstat(pipe.fileno()).st_size | |
576 if not size: | |
577 break | |
578 | |
579 s = pipe.read(size) | |
580 if not s: | |
581 break | |
582 chunks.append(s) |