diff options
Diffstat (limited to 'project.py')
| -rw-r--r-- | project.py | 25 |
1 files changed, 14 insertions, 11 deletions
| @@ -35,6 +35,7 @@ from git_config import GitConfig, IsId, GetSchemeFromUrl, GetUrlCookieFile, \ | |||
| 35 | from error import GitError, HookError, UploadError, DownloadError | 35 | from error import GitError, HookError, UploadError, DownloadError |
| 36 | from error import ManifestInvalidRevisionError | 36 | from error import ManifestInvalidRevisionError |
| 37 | from error import NoManifestException | 37 | from error import NoManifestException |
| 38 | import platform_utils | ||
| 38 | from trace import IsTrace, Trace | 39 | from trace import IsTrace, Trace |
| 39 | 40 | ||
| 40 | from git_refs import GitRefs, HEAD, R_HEADS, R_TAGS, R_PUB, R_M | 41 | from git_refs import GitRefs, HEAD, R_HEADS, R_TAGS, R_PUB, R_M |
| @@ -62,7 +63,7 @@ def _lwrite(path, content): | |||
| 62 | fd.close() | 63 | fd.close() |
| 63 | 64 | ||
| 64 | try: | 65 | try: |
| 65 | os.rename(lock, path) | 66 | platform_utils.rename(lock, path) |
| 66 | except OSError: | 67 | except OSError: |
| 67 | os.remove(lock) | 68 | os.remove(lock) |
| 68 | raise | 69 | raise |
| @@ -281,7 +282,7 @@ class _LinkFile(object): | |||
| 281 | dest_dir = os.path.dirname(absDest) | 282 | dest_dir = os.path.dirname(absDest) |
| 282 | if not os.path.isdir(dest_dir): | 283 | if not os.path.isdir(dest_dir): |
| 283 | os.makedirs(dest_dir) | 284 | os.makedirs(dest_dir) |
| 284 | os.symlink(relSrc, absDest) | 285 | platform_utils.symlink(relSrc, absDest) |
| 285 | except IOError: | 286 | except IOError: |
| 286 | _error('Cannot link file %s to %s', relSrc, absDest) | 287 | _error('Cannot link file %s to %s', relSrc, absDest) |
| 287 | 288 | ||
| @@ -2210,7 +2211,7 @@ class Project(object): | |||
| 2210 | 2211 | ||
| 2211 | if os.path.exists(tmpPath): | 2212 | if os.path.exists(tmpPath): |
| 2212 | if curlret == 0 and self._IsValidBundle(tmpPath, quiet): | 2213 | if curlret == 0 and self._IsValidBundle(tmpPath, quiet): |
| 2213 | os.rename(tmpPath, dstPath) | 2214 | platform_utils.rename(tmpPath, dstPath) |
| 2214 | return True | 2215 | return True |
| 2215 | else: | 2216 | else: |
| 2216 | os.remove(tmpPath) | 2217 | os.remove(tmpPath) |
| @@ -2311,10 +2312,10 @@ class Project(object): | |||
| 2311 | print("Retrying clone after deleting %s" % | 2312 | print("Retrying clone after deleting %s" % |
| 2312 | self.gitdir, file=sys.stderr) | 2313 | self.gitdir, file=sys.stderr) |
| 2313 | try: | 2314 | try: |
| 2314 | shutil.rmtree(os.path.realpath(self.gitdir)) | 2315 | platform_utils.rmtree(os.path.realpath(self.gitdir)) |
| 2315 | if self.worktree and os.path.exists(os.path.realpath | 2316 | if self.worktree and os.path.exists(os.path.realpath |
| 2316 | (self.worktree)): | 2317 | (self.worktree)): |
| 2317 | shutil.rmtree(os.path.realpath(self.worktree)) | 2318 | platform_utils.rmtree(os.path.realpath(self.worktree)) |
| 2318 | return self._InitGitDir(mirror_git=mirror_git, force_sync=False) | 2319 | return self._InitGitDir(mirror_git=mirror_git, force_sync=False) |
| 2319 | except: | 2320 | except: |
| 2320 | raise e | 2321 | raise e |
| @@ -2356,9 +2357,9 @@ class Project(object): | |||
| 2356 | self.config.SetString('core.bare', None) | 2357 | self.config.SetString('core.bare', None) |
| 2357 | except Exception: | 2358 | except Exception: |
| 2358 | if init_obj_dir and os.path.exists(self.objdir): | 2359 | if init_obj_dir and os.path.exists(self.objdir): |
| 2359 | shutil.rmtree(self.objdir) | 2360 | platform_utils.rmtree(self.objdir) |
| 2360 | if init_git_dir and os.path.exists(self.gitdir): | 2361 | if init_git_dir and os.path.exists(self.gitdir): |
| 2361 | shutil.rmtree(self.gitdir) | 2362 | platform_utils.rmtree(self.gitdir) |
| 2362 | raise | 2363 | raise |
| 2363 | 2364 | ||
| 2364 | def _UpdateHooks(self): | 2365 | def _UpdateHooks(self): |
| @@ -2392,7 +2393,8 @@ class Project(object): | |||
| 2392 | self.relpath, name) | 2393 | self.relpath, name) |
| 2393 | continue | 2394 | continue |
| 2394 | try: | 2395 | try: |
| 2395 | os.symlink(os.path.relpath(stock_hook, os.path.dirname(dst)), dst) | 2396 | platform_utils.symlink( |
| 2397 | os.path.relpath(stock_hook, os.path.dirname(dst)), dst) | ||
| 2396 | except OSError as e: | 2398 | except OSError as e: |
| 2397 | if e.errno == errno.EPERM: | 2399 | if e.errno == errno.EPERM: |
| 2398 | raise GitError('filesystem must support symlinks') | 2400 | raise GitError('filesystem must support symlinks') |
| @@ -2491,7 +2493,8 @@ class Project(object): | |||
| 2491 | os.makedirs(src) | 2493 | os.makedirs(src) |
| 2492 | 2494 | ||
| 2493 | if name in to_symlink: | 2495 | if name in to_symlink: |
| 2494 | os.symlink(os.path.relpath(src, os.path.dirname(dst)), dst) | 2496 | platform_utils.symlink( |
| 2497 | os.path.relpath(src, os.path.dirname(dst)), dst) | ||
| 2495 | elif copy_all and not os.path.islink(dst): | 2498 | elif copy_all and not os.path.islink(dst): |
| 2496 | if os.path.isdir(src): | 2499 | if os.path.isdir(src): |
| 2497 | shutil.copytree(src, dst) | 2500 | shutil.copytree(src, dst) |
| @@ -2526,7 +2529,7 @@ class Project(object): | |||
| 2526 | except GitError as e: | 2529 | except GitError as e: |
| 2527 | if force_sync: | 2530 | if force_sync: |
| 2528 | try: | 2531 | try: |
| 2529 | shutil.rmtree(dotgit) | 2532 | platform_utils.rmtree(dotgit) |
| 2530 | return self._InitWorkTree(force_sync=False, submodules=submodules) | 2533 | return self._InitWorkTree(force_sync=False, submodules=submodules) |
| 2531 | except: | 2534 | except: |
| 2532 | raise e | 2535 | raise e |
| @@ -2546,7 +2549,7 @@ class Project(object): | |||
| 2546 | self._CopyAndLinkFiles() | 2549 | self._CopyAndLinkFiles() |
| 2547 | except Exception: | 2550 | except Exception: |
| 2548 | if init_dotgit: | 2551 | if init_dotgit: |
| 2549 | shutil.rmtree(dotgit) | 2552 | platform_utils.rmtree(dotgit) |
| 2550 | raise | 2553 | raise |
| 2551 | 2554 | ||
| 2552 | def _gitdir_path(self, path): | 2555 | def _gitdir_path(self, path): |
