summaryrefslogtreecommitdiffstats
path: root/subcmds/forall.py
diff options
context:
space:
mode:
authorDavid Pursehouse <dpursehouse@collab.net>2017-08-30 10:24:03 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2017-08-30 10:24:03 +0000
commitd1ebc89a083f2966f8c65246bb63e2deaadfab62 (patch)
treecd6bd047ba2c7b83a25ba045a48efa95393f7fbe /subcmds/forall.py
parent9ead97bb51f5b1ad1d0a45e0c5442f15e1e38fd7 (diff)
parentad1abcb556bfff2744928a8f29d216aee43fdbe3 (diff)
downloadgit-repo-d1ebc89a083f2966f8c65246bb63e2deaadfab62.tar.gz
Merge changes from topic "windows-support"
* changes: Port os.rename calls to work on Windows Workaround shutil.rmtree limitation on Windows Add support for creating symbolic links on Windows Make "git command" and "forall" work on Windows
Diffstat (limited to 'subcmds/forall.py')
-rw-r--r--subcmds/forall.py29
1 files changed, 9 insertions, 20 deletions
diff --git a/subcmds/forall.py b/subcmds/forall.py
index 07ee8d58..2c12c55f 100644
--- a/subcmds/forall.py
+++ b/subcmds/forall.py
@@ -15,17 +15,16 @@
15 15
16from __future__ import print_function 16from __future__ import print_function
17import errno 17import errno
18import fcntl
19import multiprocessing 18import multiprocessing
20import re 19import re
21import os 20import os
22import select
23import signal 21import signal
24import sys 22import sys
25import subprocess 23import subprocess
26 24
27from color import Coloring 25from color import Coloring
28from command import Command, MirrorSafeCommand 26from command import Command, MirrorSafeCommand
27import platform_utils
29 28
30_CAN_COLOR = [ 29_CAN_COLOR = [
31 'branch', 30 'branch',
@@ -344,35 +343,25 @@ def DoWork(project, mirror, opt, cmd, shell, cnt, config):
344 if opt.project_header: 343 if opt.project_header:
345 out = ForallColoring(config) 344 out = ForallColoring(config)
346 out.redirect(sys.stdout) 345 out.redirect(sys.stdout)
347 class sfd(object):
348 def __init__(self, fd, dest):
349 self.fd = fd
350 self.dest = dest
351 def fileno(self):
352 return self.fd.fileno()
353
354 empty = True 346 empty = True
355 errbuf = '' 347 errbuf = ''
356 348
357 p.stdin.close() 349 p.stdin.close()
358 s_in = [sfd(p.stdout, sys.stdout), 350 s_in = platform_utils.FileDescriptorStreams.create()
359 sfd(p.stderr, sys.stderr)] 351 s_in.add(p.stdout, sys.stdout, 'stdout')
360 352 s_in.add(p.stderr, sys.stderr, 'stderr')
361 for s in s_in:
362 flags = fcntl.fcntl(s.fd, fcntl.F_GETFL)
363 fcntl.fcntl(s.fd, fcntl.F_SETFL, flags | os.O_NONBLOCK)
364 353
365 while s_in: 354 while not s_in.is_done:
366 in_ready, _out_ready, _err_ready = select.select(s_in, [], []) 355 in_ready = s_in.select()
367 for s in in_ready: 356 for s in in_ready:
368 buf = s.fd.read(4096) 357 buf = s.read()
369 if not buf: 358 if not buf:
370 s.fd.close() 359 s.close()
371 s_in.remove(s) 360 s_in.remove(s)
372 continue 361 continue
373 362
374 if not opt.verbose: 363 if not opt.verbose:
375 if s.fd != p.stdout: 364 if s.std_name == 'stderr':
376 errbuf += buf 365 errbuf += buf
377 continue 366 continue
378 367