diff options
Diffstat (limited to 'project.py')
| -rw-r--r-- | project.py | 19 |
1 files changed, 2 insertions, 17 deletions
| @@ -80,21 +80,6 @@ def _ProjectHooks(): | |||
| 80 | _project_hook_list = map(lambda x: os.path.join(d, x), os.listdir(d)) | 80 | _project_hook_list = map(lambda x: os.path.join(d, x), os.listdir(d)) |
| 81 | return _project_hook_list | 81 | return _project_hook_list |
| 82 | 82 | ||
| 83 | def relpath(dst, src): | ||
| 84 | src = os.path.dirname(src) | ||
| 85 | top = os.path.commonprefix([dst, src]) | ||
| 86 | if top.endswith('/'): | ||
| 87 | top = top[:-1] | ||
| 88 | else: | ||
| 89 | top = os.path.dirname(top) | ||
| 90 | |||
| 91 | tmp = src | ||
| 92 | rel = '' | ||
| 93 | while top != tmp: | ||
| 94 | rel += '../' | ||
| 95 | tmp = os.path.dirname(tmp) | ||
| 96 | return rel + dst[len(top) + 1:] | ||
| 97 | |||
| 98 | 83 | ||
| 99 | class DownloadedChange(object): | 84 | class DownloadedChange(object): |
| 100 | _commit_cache = None | 85 | _commit_cache = None |
| @@ -1697,7 +1682,7 @@ class Project(object): | |||
| 1697 | _error("%s: Not replacing %s hook", self.relpath, name) | 1682 | _error("%s: Not replacing %s hook", self.relpath, name) |
| 1698 | continue | 1683 | continue |
| 1699 | try: | 1684 | try: |
| 1700 | os.symlink(relpath(stock_hook, dst), dst) | 1685 | os.symlink(os.path.relpath(stock_hook, os.path.dirname(dst)), dst) |
| 1701 | except OSError, e: | 1686 | except OSError, e: |
| 1702 | if e.errno == errno.EPERM: | 1687 | if e.errno == errno.EPERM: |
| 1703 | raise GitError('filesystem must support symlinks') | 1688 | raise GitError('filesystem must support symlinks') |
| @@ -1758,7 +1743,7 @@ class Project(object): | |||
| 1758 | src = os.path.join(self.gitdir, name) | 1743 | src = os.path.join(self.gitdir, name) |
| 1759 | dst = os.path.join(dotgit, name) | 1744 | dst = os.path.join(dotgit, name) |
| 1760 | if os.path.islink(dst) or not os.path.exists(dst): | 1745 | if os.path.islink(dst) or not os.path.exists(dst): |
| 1761 | os.symlink(relpath(src, dst), dst) | 1746 | os.symlink(os.path.relpath(src, os.path.dirname(dst)), dst) |
| 1762 | else: | 1747 | else: |
| 1763 | raise GitError('cannot overwrite a local work tree') | 1748 | raise GitError('cannot overwrite a local work tree') |
| 1764 | except OSError, e: | 1749 | except OSError, e: |
