diff options
author | Renaud Paquay <rpaquay@google.com> | 2016-11-03 10:37:53 -0700 |
---|---|---|
committer | David Pursehouse <dpursehouse@collab.net> | 2017-05-29 19:32:31 +0900 |
commit | a65adf74f990eeac0d90011476376c7239cb7af5 (patch) | |
tree | 9278d9ce7c8d68a85dd049ed1ea5b64d84135fc0 /subcmds/sync.py | |
parent | d5cec5e752821ca2710101b626b3a3ca07fdb7f8 (diff) | |
download | git-repo-a65adf74f990eeac0d90011476376c7239cb7af5.tar.gz |
Workaround shutil.rmtree limitation on Windows
By default, shutil.rmtree raises an exception when deleting readonly
files on Windows.
Replace all shutil.rmtree with platform_utils.rmtree, which adds an
error handler to make files read-write when they can't be deleted.
Change-Id: I9cfea9a7b3703fb16a82cf69331540c2c179ed53
Diffstat (limited to 'subcmds/sync.py')
-rw-r--r-- | subcmds/sync.py | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/subcmds/sync.py b/subcmds/sync.py index ef023274..797fc403 100644 --- a/subcmds/sync.py +++ b/subcmds/sync.py | |||
@@ -19,7 +19,6 @@ import netrc | |||
19 | from optparse import SUPPRESS_HELP | 19 | from optparse import SUPPRESS_HELP |
20 | import os | 20 | import os |
21 | import re | 21 | import re |
22 | import shutil | ||
23 | import socket | 22 | import socket |
24 | import subprocess | 23 | import subprocess |
25 | import sys | 24 | import sys |
@@ -73,6 +72,7 @@ from project import Project | |||
73 | from project import RemoteSpec | 72 | from project import RemoteSpec |
74 | from command import Command, MirrorSafeCommand | 73 | from command import Command, MirrorSafeCommand |
75 | from error import RepoChangedException, GitError, ManifestParseError | 74 | from error import RepoChangedException, GitError, ManifestParseError |
75 | import platform_utils | ||
76 | from project import SyncBuffer | 76 | from project import SyncBuffer |
77 | from progress import Progress | 77 | from progress import Progress |
78 | from wrapper import Wrapper | 78 | from wrapper import Wrapper |
@@ -473,7 +473,7 @@ later is required to fix a server side protocol bug. | |||
473 | # working git repository around. There shouldn't be any git projects here, | 473 | # working git repository around. There shouldn't be any git projects here, |
474 | # so rmtree works. | 474 | # so rmtree works. |
475 | try: | 475 | try: |
476 | shutil.rmtree(os.path.join(path, '.git')) | 476 | platform_utils.rmtree(os.path.join(path, '.git')) |
477 | except OSError: | 477 | except OSError: |
478 | print('Failed to remove %s' % os.path.join(path, '.git'), file=sys.stderr) | 478 | print('Failed to remove %s' % os.path.join(path, '.git'), file=sys.stderr) |
479 | print('error: Failed to delete obsolete path %s' % path, file=sys.stderr) | 479 | print('error: Failed to delete obsolete path %s' % path, file=sys.stderr) |