diff options
Diffstat (limited to 'project.py')
-rw-r--r-- | project.py | 36 |
1 files changed, 21 insertions, 15 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 |
@@ -178,14 +179,16 @@ class ReviewableBranch(object): | |||
178 | draft=False, | 179 | draft=False, |
179 | private=False, | 180 | private=False, |
180 | wip=False, | 181 | wip=False, |
181 | dest_branch=None): | 182 | dest_branch=None, |
183 | validate_certs=True): | ||
182 | self.project.UploadForReview(self.name, | 184 | self.project.UploadForReview(self.name, |
183 | people, | 185 | people, |
184 | auto_topic=auto_topic, | 186 | auto_topic=auto_topic, |
185 | draft=draft, | 187 | draft=draft, |
186 | private=private, | 188 | private=private, |
187 | wip=wip, | 189 | wip=wip, |
188 | dest_branch=dest_branch) | 190 | dest_branch=dest_branch, |
191 | validate_certs=validate_certs) | ||
189 | 192 | ||
190 | def GetPublishedRefs(self): | 193 | def GetPublishedRefs(self): |
191 | refs = {} | 194 | refs = {} |
@@ -281,7 +284,7 @@ class _LinkFile(object): | |||
281 | dest_dir = os.path.dirname(absDest) | 284 | dest_dir = os.path.dirname(absDest) |
282 | if not os.path.isdir(dest_dir): | 285 | if not os.path.isdir(dest_dir): |
283 | os.makedirs(dest_dir) | 286 | os.makedirs(dest_dir) |
284 | os.symlink(relSrc, absDest) | 287 | platform_utils.symlink(relSrc, absDest) |
285 | except IOError: | 288 | except IOError: |
286 | _error('Cannot link file %s to %s', relSrc, absDest) | 289 | _error('Cannot link file %s to %s', relSrc, absDest) |
287 | 290 | ||
@@ -1113,7 +1116,8 @@ class Project(object): | |||
1113 | draft=False, | 1116 | draft=False, |
1114 | private=False, | 1117 | private=False, |
1115 | wip=False, | 1118 | wip=False, |
1116 | dest_branch=None): | 1119 | dest_branch=None, |
1120 | validate_certs=True): | ||
1117 | """Uploads the named branch for code review. | 1121 | """Uploads the named branch for code review. |
1118 | """ | 1122 | """ |
1119 | if branch is None: | 1123 | if branch is None: |
@@ -1138,7 +1142,7 @@ class Project(object): | |||
1138 | branch.remote.projectname = self.name | 1142 | branch.remote.projectname = self.name |
1139 | branch.remote.Save() | 1143 | branch.remote.Save() |
1140 | 1144 | ||
1141 | url = branch.remote.ReviewUrl(self.UserEmail) | 1145 | url = branch.remote.ReviewUrl(self.UserEmail, validate_certs) |
1142 | if url is None: | 1146 | if url is None: |
1143 | raise UploadError('review not configured') | 1147 | raise UploadError('review not configured') |
1144 | cmd = ['push'] | 1148 | cmd = ['push'] |
@@ -2210,7 +2214,7 @@ class Project(object): | |||
2210 | 2214 | ||
2211 | if os.path.exists(tmpPath): | 2215 | if os.path.exists(tmpPath): |
2212 | if curlret == 0 and self._IsValidBundle(tmpPath, quiet): | 2216 | if curlret == 0 and self._IsValidBundle(tmpPath, quiet): |
2213 | os.rename(tmpPath, dstPath) | 2217 | platform_utils.rename(tmpPath, dstPath) |
2214 | return True | 2218 | return True |
2215 | else: | 2219 | else: |
2216 | os.remove(tmpPath) | 2220 | os.remove(tmpPath) |
@@ -2311,10 +2315,10 @@ class Project(object): | |||
2311 | print("Retrying clone after deleting %s" % | 2315 | print("Retrying clone after deleting %s" % |
2312 | self.gitdir, file=sys.stderr) | 2316 | self.gitdir, file=sys.stderr) |
2313 | try: | 2317 | try: |
2314 | shutil.rmtree(os.path.realpath(self.gitdir)) | 2318 | platform_utils.rmtree(os.path.realpath(self.gitdir)) |
2315 | if self.worktree and os.path.exists(os.path.realpath | 2319 | if self.worktree and os.path.exists(os.path.realpath |
2316 | (self.worktree)): | 2320 | (self.worktree)): |
2317 | shutil.rmtree(os.path.realpath(self.worktree)) | 2321 | platform_utils.rmtree(os.path.realpath(self.worktree)) |
2318 | return self._InitGitDir(mirror_git=mirror_git, force_sync=False) | 2322 | return self._InitGitDir(mirror_git=mirror_git, force_sync=False) |
2319 | except: | 2323 | except: |
2320 | raise e | 2324 | raise e |
@@ -2356,9 +2360,9 @@ class Project(object): | |||
2356 | self.config.SetString('core.bare', None) | 2360 | self.config.SetString('core.bare', None) |
2357 | except Exception: | 2361 | except Exception: |
2358 | if init_obj_dir and os.path.exists(self.objdir): | 2362 | if init_obj_dir and os.path.exists(self.objdir): |
2359 | shutil.rmtree(self.objdir) | 2363 | platform_utils.rmtree(self.objdir) |
2360 | if init_git_dir and os.path.exists(self.gitdir): | 2364 | if init_git_dir and os.path.exists(self.gitdir): |
2361 | shutil.rmtree(self.gitdir) | 2365 | platform_utils.rmtree(self.gitdir) |
2362 | raise | 2366 | raise |
2363 | 2367 | ||
2364 | def _UpdateHooks(self): | 2368 | def _UpdateHooks(self): |
@@ -2392,7 +2396,8 @@ class Project(object): | |||
2392 | self.relpath, name) | 2396 | self.relpath, name) |
2393 | continue | 2397 | continue |
2394 | try: | 2398 | try: |
2395 | os.symlink(os.path.relpath(stock_hook, os.path.dirname(dst)), dst) | 2399 | platform_utils.symlink( |
2400 | os.path.relpath(stock_hook, os.path.dirname(dst)), dst) | ||
2396 | except OSError as e: | 2401 | except OSError as e: |
2397 | if e.errno == errno.EPERM: | 2402 | if e.errno == errno.EPERM: |
2398 | raise GitError('filesystem must support symlinks') | 2403 | raise GitError('filesystem must support symlinks') |
@@ -2491,7 +2496,8 @@ class Project(object): | |||
2491 | os.makedirs(src) | 2496 | os.makedirs(src) |
2492 | 2497 | ||
2493 | if name in to_symlink: | 2498 | if name in to_symlink: |
2494 | os.symlink(os.path.relpath(src, os.path.dirname(dst)), dst) | 2499 | platform_utils.symlink( |
2500 | os.path.relpath(src, os.path.dirname(dst)), dst) | ||
2495 | elif copy_all and not os.path.islink(dst): | 2501 | elif copy_all and not os.path.islink(dst): |
2496 | if os.path.isdir(src): | 2502 | if os.path.isdir(src): |
2497 | shutil.copytree(src, dst) | 2503 | shutil.copytree(src, dst) |
@@ -2526,7 +2532,7 @@ class Project(object): | |||
2526 | except GitError as e: | 2532 | except GitError as e: |
2527 | if force_sync: | 2533 | if force_sync: |
2528 | try: | 2534 | try: |
2529 | shutil.rmtree(dotgit) | 2535 | platform_utils.rmtree(dotgit) |
2530 | return self._InitWorkTree(force_sync=False, submodules=submodules) | 2536 | return self._InitWorkTree(force_sync=False, submodules=submodules) |
2531 | except: | 2537 | except: |
2532 | raise e | 2538 | raise e |
@@ -2546,7 +2552,7 @@ class Project(object): | |||
2546 | self._CopyAndLinkFiles() | 2552 | self._CopyAndLinkFiles() |
2547 | except Exception: | 2553 | except Exception: |
2548 | if init_dotgit: | 2554 | if init_dotgit: |
2549 | shutil.rmtree(dotgit) | 2555 | platform_utils.rmtree(dotgit) |
2550 | raise | 2556 | raise |
2551 | 2557 | ||
2552 | def _gitdir_path(self, path): | 2558 | def _gitdir_path(self, path): |