summaryrefslogtreecommitdiffstats
path: root/subcmds
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
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')
-rw-r--r--subcmds/forall.py29
-rw-r--r--subcmds/gitc_delete.py4
-rw-r--r--subcmds/init.py4
-rw-r--r--subcmds/sync.py4
4 files changed, 15 insertions, 26 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
diff --git a/subcmds/gitc_delete.py b/subcmds/gitc_delete.py
index 19caac5a..54f62f46 100644
--- a/subcmds/gitc_delete.py
+++ b/subcmds/gitc_delete.py
@@ -14,10 +14,10 @@
14# limitations under the License. 14# limitations under the License.
15 15
16from __future__ import print_function 16from __future__ import print_function
17import shutil
18import sys 17import sys
19 18
20from command import Command, GitcClientCommand 19from command import Command, GitcClientCommand
20import platform_utils
21 21
22from pyversion import is_python3 22from pyversion import is_python3
23if not is_python3(): 23if not is_python3():
@@ -50,4 +50,4 @@ and all locally downloaded sources.
50 if not response == 'yes': 50 if not response == 'yes':
51 print('Response was not "yes"\n Exiting...') 51 print('Response was not "yes"\n Exiting...')
52 sys.exit(1) 52 sys.exit(1)
53 shutil.rmtree(self.gitc_manifest.gitc_client_dir) 53 platform_utils.rmtree(self.gitc_manifest.gitc_client_dir)
diff --git a/subcmds/init.py b/subcmds/init.py
index 46cdd23a..eeddca06 100644
--- a/subcmds/init.py
+++ b/subcmds/init.py
@@ -17,7 +17,6 @@ from __future__ import print_function
17import os 17import os
18import platform 18import platform
19import re 19import re
20import shutil
21import sys 20import sys
22 21
23from pyversion import is_python3 22from pyversion import is_python3
@@ -35,6 +34,7 @@ from error import ManifestParseError
35from project import SyncBuffer 34from project import SyncBuffer
36from git_config import GitConfig 35from git_config import GitConfig
37from git_command import git_require, MIN_GIT_VERSION 36from git_command import git_require, MIN_GIT_VERSION
37import platform_utils
38 38
39class Init(InteractiveCommand, MirrorSafeCommand): 39class Init(InteractiveCommand, MirrorSafeCommand):
40 common = True 40 common = True
@@ -252,7 +252,7 @@ to update the working directory files.
252 # Better delete the manifest git dir if we created it; otherwise next 252 # Better delete the manifest git dir if we created it; otherwise next
253 # time (when user fixes problems) we won't go through the "is_new" logic. 253 # time (when user fixes problems) we won't go through the "is_new" logic.
254 if is_new: 254 if is_new:
255 shutil.rmtree(m.gitdir) 255 platform_utils.rmtree(m.gitdir)
256 sys.exit(1) 256 sys.exit(1)
257 257
258 if opt.manifest_branch: 258 if opt.manifest_branch:
diff --git a/subcmds/sync.py b/subcmds/sync.py
index 8de730bc..b88c596d 100644
--- a/subcmds/sync.py
+++ b/subcmds/sync.py
@@ -19,7 +19,6 @@ import netrc
19from optparse import SUPPRESS_HELP 19from optparse import SUPPRESS_HELP
20import os 20import os
21import re 21import re
22import shutil
23import socket 22import socket
24import subprocess 23import subprocess
25import sys 24import sys
@@ -73,6 +72,7 @@ from project import Project
73from project import RemoteSpec 72from project import RemoteSpec
74from command import Command, MirrorSafeCommand 73from command import Command, MirrorSafeCommand
75from error import RepoChangedException, GitError, ManifestParseError 74from error import RepoChangedException, GitError, ManifestParseError
75import platform_utils
76from project import SyncBuffer 76from project import SyncBuffer
77from progress import Progress 77from progress import Progress
78from wrapper import Wrapper 78from wrapper import Wrapper
@@ -475,7 +475,7 @@ later is required to fix a server side protocol bug.
475 # working git repository around. There shouldn't be any git projects here, 475 # working git repository around. There shouldn't be any git projects here,
476 # so rmtree works. 476 # so rmtree works.
477 try: 477 try:
478 shutil.rmtree(os.path.join(path, '.git')) 478 platform_utils.rmtree(os.path.join(path, '.git'))
479 except OSError: 479 except OSError:
480 print('Failed to remove %s' % os.path.join(path, '.git'), file=sys.stderr) 480 print('Failed to remove %s' % os.path.join(path, '.git'), file=sys.stderr)
481 print('error: Failed to delete obsolete path %s' % path, file=sys.stderr) 481 print('error: Failed to delete obsolete path %s' % path, file=sys.stderr)