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 /project.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 'project.py')
-rw-r--r-- | project.py | 12 |
1 files changed, 6 insertions, 6 deletions
@@ -2299,10 +2299,10 @@ class Project(object): | |||
2299 | print("Retrying clone after deleting %s" % | 2299 | print("Retrying clone after deleting %s" % |
2300 | self.gitdir, file=sys.stderr) | 2300 | self.gitdir, file=sys.stderr) |
2301 | try: | 2301 | try: |
2302 | shutil.rmtree(os.path.realpath(self.gitdir)) | 2302 | platform_utils.rmtree(os.path.realpath(self.gitdir)) |
2303 | if self.worktree and os.path.exists(os.path.realpath | 2303 | if self.worktree and os.path.exists(os.path.realpath |
2304 | (self.worktree)): | 2304 | (self.worktree)): |
2305 | shutil.rmtree(os.path.realpath(self.worktree)) | 2305 | platform_utils.rmtree(os.path.realpath(self.worktree)) |
2306 | return self._InitGitDir(mirror_git=mirror_git, force_sync=False) | 2306 | return self._InitGitDir(mirror_git=mirror_git, force_sync=False) |
2307 | except: | 2307 | except: |
2308 | raise e | 2308 | raise e |
@@ -2344,9 +2344,9 @@ class Project(object): | |||
2344 | self.config.SetString('core.bare', None) | 2344 | self.config.SetString('core.bare', None) |
2345 | except Exception: | 2345 | except Exception: |
2346 | if init_obj_dir and os.path.exists(self.objdir): | 2346 | if init_obj_dir and os.path.exists(self.objdir): |
2347 | shutil.rmtree(self.objdir) | 2347 | platform_utils.rmtree(self.objdir) |
2348 | if init_git_dir and os.path.exists(self.gitdir): | 2348 | if init_git_dir and os.path.exists(self.gitdir): |
2349 | shutil.rmtree(self.gitdir) | 2349 | platform_utils.rmtree(self.gitdir) |
2350 | raise | 2350 | raise |
2351 | 2351 | ||
2352 | def _UpdateHooks(self): | 2352 | def _UpdateHooks(self): |
@@ -2516,7 +2516,7 @@ class Project(object): | |||
2516 | except GitError as e: | 2516 | except GitError as e: |
2517 | if force_sync: | 2517 | if force_sync: |
2518 | try: | 2518 | try: |
2519 | shutil.rmtree(dotgit) | 2519 | platform_utils.rmtree(dotgit) |
2520 | return self._InitWorkTree(force_sync=False, submodules=submodules) | 2520 | return self._InitWorkTree(force_sync=False, submodules=submodules) |
2521 | except: | 2521 | except: |
2522 | raise e | 2522 | raise e |
@@ -2536,7 +2536,7 @@ class Project(object): | |||
2536 | self._CopyAndLinkFiles() | 2536 | self._CopyAndLinkFiles() |
2537 | except Exception: | 2537 | except Exception: |
2538 | if init_dotgit: | 2538 | if init_dotgit: |
2539 | shutil.rmtree(dotgit) | 2539 | platform_utils.rmtree(dotgit) |
2540 | raise | 2540 | raise |
2541 | 2541 | ||
2542 | def _gitdir_path(self, path): | 2542 | def _gitdir_path(self, path): |