diff --git a/project.py b/project.py index b7295790..00ebb17f 100644 --- a/project.py +++ b/project.py @@ -80,21 +80,6 @@ def _ProjectHooks(): _project_hook_list = map(lambda x: os.path.join(d, x), os.listdir(d)) return _project_hook_list -def relpath(dst, src): - src = os.path.dirname(src) - top = os.path.commonprefix([dst, src]) - if top.endswith('/'): - top = top[:-1] - else: - top = os.path.dirname(top) - - tmp = src - rel = '' - while top != tmp: - rel += '../' - tmp = os.path.dirname(tmp) - return rel + dst[len(top) + 1:] - class DownloadedChange(object): _commit_cache = None @@ -1697,7 +1682,7 @@ class Project(object): _error("%s: Not replacing %s hook", self.relpath, name) continue try: - os.symlink(relpath(stock_hook, dst), dst) + os.symlink(os.path.relpath(stock_hook, os.path.dirname(dst)), dst) except OSError, e: if e.errno == errno.EPERM: raise GitError('filesystem must support symlinks') @@ -1758,7 +1743,7 @@ class Project(object): src = os.path.join(self.gitdir, name) dst = os.path.join(dotgit, name) if os.path.islink(dst) or not os.path.exists(dst): - os.symlink(relpath(src, dst), dst) + os.symlink(os.path.relpath(src, os.path.dirname(dst)), dst) else: raise GitError('cannot overwrite a local work tree') except OSError, e: