diff options
Diffstat (limited to 'project.py')
| -rw-r--r-- | project.py | 46 |
1 files changed, 35 insertions, 11 deletions
| @@ -46,7 +46,7 @@ if not is_python3(): | |||
| 46 | def _lwrite(path, content): | 46 | def _lwrite(path, content): |
| 47 | lock = '%s.lock' % path | 47 | lock = '%s.lock' % path |
| 48 | 48 | ||
| 49 | fd = open(lock, 'wb') | 49 | fd = open(lock, 'w') |
| 50 | try: | 50 | try: |
| 51 | fd.write(content) | 51 | fd.write(content) |
| 52 | finally: | 52 | finally: |
| @@ -259,10 +259,12 @@ class RemoteSpec(object): | |||
| 259 | def __init__(self, | 259 | def __init__(self, |
| 260 | name, | 260 | name, |
| 261 | url = None, | 261 | url = None, |
| 262 | review = None): | 262 | review = None, |
| 263 | revision = None): | ||
| 263 | self.name = name | 264 | self.name = name |
| 264 | self.url = url | 265 | self.url = url |
| 265 | self.review = review | 266 | self.review = review |
| 267 | self.revision = revision | ||
| 266 | 268 | ||
| 267 | class RepoHook(object): | 269 | class RepoHook(object): |
| 268 | """A RepoHook contains information about a script to run as a hook. | 270 | """A RepoHook contains information about a script to run as a hook. |
| @@ -438,7 +440,8 @@ class RepoHook(object): | |||
| 438 | # and convert to a HookError w/ just the failing traceback. | 440 | # and convert to a HookError w/ just the failing traceback. |
| 439 | context = {} | 441 | context = {} |
| 440 | try: | 442 | try: |
| 441 | execfile(self._script_fullpath, context) | 443 | exec(compile(open(self._script_fullpath).read(), |
| 444 | self._script_fullpath, 'exec'), context) | ||
| 442 | except Exception: | 445 | except Exception: |
| 443 | raise HookError('%s\nFailed to import %s hook; see traceback above.' % ( | 446 | raise HookError('%s\nFailed to import %s hook; see traceback above.' % ( |
| 444 | traceback.format_exc(), self._hook_type)) | 447 | traceback.format_exc(), self._hook_type)) |
| @@ -1657,7 +1660,8 @@ class Project(object): | |||
| 1657 | 1660 | ||
| 1658 | remote = RemoteSpec(self.remote.name, | 1661 | remote = RemoteSpec(self.remote.name, |
| 1659 | url = url, | 1662 | url = url, |
| 1660 | review = self.remote.review) | 1663 | review = self.remote.review, |
| 1664 | revision = self.remote.revision) | ||
| 1661 | subproject = Project(manifest = self.manifest, | 1665 | subproject = Project(manifest = self.manifest, |
| 1662 | name = name, | 1666 | name = name, |
| 1663 | remote = remote, | 1667 | remote = remote, |
| @@ -1702,6 +1706,7 @@ class Project(object): | |||
| 1702 | if command.Wait() != 0: | 1706 | if command.Wait() != 0: |
| 1703 | raise GitError('git archive %s: %s' % (self.name, command.stderr)) | 1707 | raise GitError('git archive %s: %s' % (self.name, command.stderr)) |
| 1704 | 1708 | ||
| 1709 | |||
| 1705 | def _RemoteFetch(self, name=None, | 1710 | def _RemoteFetch(self, name=None, |
| 1706 | current_branch_only=False, | 1711 | current_branch_only=False, |
| 1707 | initial=False, | 1712 | initial=False, |
| @@ -1804,19 +1809,30 @@ class Project(object): | |||
| 1804 | else: | 1809 | else: |
| 1805 | cmd.append('--tags') | 1810 | cmd.append('--tags') |
| 1806 | 1811 | ||
| 1812 | spec = [] | ||
| 1807 | if not current_branch_only: | 1813 | if not current_branch_only: |
| 1808 | # Fetch whole repo | 1814 | # Fetch whole repo |
| 1809 | cmd.append(str((u'+refs/heads/*:') + remote.ToLocal('refs/heads/*'))) | 1815 | spec.append(str((u'+refs/heads/*:') + remote.ToLocal('refs/heads/*'))) |
| 1810 | elif tag_name is not None: | 1816 | elif tag_name is not None: |
| 1811 | cmd.append('tag') | 1817 | spec.append('tag') |
| 1812 | cmd.append(tag_name) | 1818 | spec.append(tag_name) |
| 1813 | else: | 1819 | else: |
| 1814 | branch = self.revisionExpr | 1820 | branch = self.revisionExpr |
| 1815 | if is_sha1: | 1821 | if is_sha1: |
| 1816 | branch = self.upstream | 1822 | branch = self.upstream |
| 1817 | if branch.startswith(R_HEADS): | 1823 | if branch.startswith(R_HEADS): |
| 1818 | branch = branch[len(R_HEADS):] | 1824 | branch = branch[len(R_HEADS):] |
| 1819 | cmd.append(str((u'+refs/heads/%s:' % branch) + remote.ToLocal('refs/heads/%s' % branch))) | 1825 | spec.append(str((u'+refs/heads/%s:' % branch) + remote.ToLocal('refs/heads/%s' % branch))) |
| 1826 | cmd.extend(spec) | ||
| 1827 | |||
| 1828 | shallowfetch = self.config.GetString('repo.shallowfetch') | ||
| 1829 | if shallowfetch and shallowfetch != ' '.join(spec): | ||
| 1830 | GitCommand(self, ['fetch', '--unshallow', name] + shallowfetch.split(), | ||
| 1831 | bare=True, ssh_proxy=ssh_proxy).Wait() | ||
| 1832 | if depth: | ||
| 1833 | self.config.SetString('repo.shallowfetch', ' '.join(spec)) | ||
| 1834 | else: | ||
| 1835 | self.config.SetString('repo.shallowfetch', None) | ||
| 1820 | 1836 | ||
| 1821 | ok = False | 1837 | ok = False |
| 1822 | for _i in range(2): | 1838 | for _i in range(2): |
| @@ -2201,6 +2217,14 @@ class Project(object): | |||
| 2201 | if name in symlink_dirs and not os.path.lexists(src): | 2217 | if name in symlink_dirs and not os.path.lexists(src): |
| 2202 | os.makedirs(src) | 2218 | os.makedirs(src) |
| 2203 | 2219 | ||
| 2220 | # If the source file doesn't exist, ensure the destination | ||
| 2221 | # file doesn't either. | ||
| 2222 | if name in symlink_files and not os.path.lexists(src): | ||
| 2223 | try: | ||
| 2224 | os.remove(dst) | ||
| 2225 | except OSError: | ||
| 2226 | pass | ||
| 2227 | |||
| 2204 | if name in to_symlink: | 2228 | if name in to_symlink: |
| 2205 | os.symlink(os.path.relpath(src, os.path.dirname(dst)), dst) | 2229 | os.symlink(os.path.relpath(src, os.path.dirname(dst)), dst) |
| 2206 | elif copy_all and not os.path.islink(dst): | 2230 | elif copy_all and not os.path.islink(dst): |
| @@ -2321,8 +2345,8 @@ class Project(object): | |||
| 2321 | out = iter(out[:-1].split('\0')) # pylint: disable=W1401 | 2345 | out = iter(out[:-1].split('\0')) # pylint: disable=W1401 |
| 2322 | while out: | 2346 | while out: |
| 2323 | try: | 2347 | try: |
| 2324 | info = out.next() | 2348 | info = next(out) |
| 2325 | path = out.next() | 2349 | path = next(out) |
| 2326 | except StopIteration: | 2350 | except StopIteration: |
| 2327 | break | 2351 | break |
| 2328 | 2352 | ||
| @@ -2348,7 +2372,7 @@ class Project(object): | |||
| 2348 | info = _Info(path, *info) | 2372 | info = _Info(path, *info) |
| 2349 | if info.status in ('R', 'C'): | 2373 | if info.status in ('R', 'C'): |
| 2350 | info.src_path = info.path | 2374 | info.src_path = info.path |
| 2351 | info.path = out.next() | 2375 | info.path = next(out) |
| 2352 | r[info.path] = info | 2376 | r[info.path] = info |
| 2353 | return r | 2377 | return r |
| 2354 | finally: | 2378 | finally: |
