mirror of
https://github.com/Dev-Wiki/git-repo.git
synced 2025-12-14 00:24:05 +08:00
Add support for creating symbolic links on Windows
Replace all calls to os.symlink with platform_utils.symlink. The Windows implementation calls into the CreateSymbolicLinkW Win32 API, as os.symlink is not supported. Separate the Win32 API definitions into a separate module platform_utils_win32 for clarity. Change-Id: I0714c598664c2df93383734e609d948692c17ec5
This commit is contained in:
committed by
David Pursehouse
parent
2e70291162
commit
d5cec5e752
@@ -35,6 +35,7 @@ from git_config import GitConfig, IsId, GetSchemeFromUrl, GetUrlCookieFile, \
|
||||
from error import GitError, HookError, UploadError, DownloadError
|
||||
from error import ManifestInvalidRevisionError
|
||||
from error import NoManifestException
|
||||
import platform_utils
|
||||
from trace import IsTrace, Trace
|
||||
|
||||
from git_refs import GitRefs, HEAD, R_HEADS, R_TAGS, R_PUB, R_M
|
||||
@@ -277,7 +278,7 @@ class _LinkFile(object):
|
||||
dest_dir = os.path.dirname(absDest)
|
||||
if not os.path.isdir(dest_dir):
|
||||
os.makedirs(dest_dir)
|
||||
os.symlink(relSrc, absDest)
|
||||
platform_utils.symlink(relSrc, absDest)
|
||||
except IOError:
|
||||
_error('Cannot link file %s to %s', relSrc, absDest)
|
||||
|
||||
@@ -2379,7 +2380,8 @@ class Project(object):
|
||||
self.relpath, name)
|
||||
continue
|
||||
try:
|
||||
os.symlink(os.path.relpath(stock_hook, os.path.dirname(dst)), dst)
|
||||
platform_utils.symlink(
|
||||
os.path.relpath(stock_hook, os.path.dirname(dst)), dst)
|
||||
except OSError as e:
|
||||
if e.errno == errno.EPERM:
|
||||
raise GitError('filesystem must support symlinks')
|
||||
@@ -2478,7 +2480,8 @@ class Project(object):
|
||||
os.makedirs(src)
|
||||
|
||||
if name in to_symlink:
|
||||
os.symlink(os.path.relpath(src, os.path.dirname(dst)), dst)
|
||||
platform_utils.symlink(
|
||||
os.path.relpath(src, os.path.dirname(dst)), dst)
|
||||
elif copy_all and not os.path.islink(dst):
|
||||
if os.path.isdir(src):
|
||||
shutil.copytree(src, dst)
|
||||
|
||||
Reference in New Issue
Block a user