diff options
author | Renaud Paquay <rpaquay@google.com> | 2016-11-01 11:24:03 -0700 |
---|---|---|
committer | David Pursehouse <dpursehouse@collab.net> | 2017-05-29 19:30:34 +0900 |
commit | d5cec5e752821ca2710101b626b3a3ca07fdb7f8 (patch) | |
tree | 4ecee491de2d3d57b4d03f526701c8c06a133b17 /project.py | |
parent | 2e7029116204cf2d6f516e4514091f0b492bc689 (diff) | |
download | git-repo-d5cec5e752821ca2710101b626b3a3ca07fdb7f8.tar.gz |
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
Diffstat (limited to 'project.py')
-rw-r--r-- | project.py | 9 |
1 files changed, 6 insertions, 3 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 |
@@ -277,7 +278,7 @@ class _LinkFile(object): | |||
277 | dest_dir = os.path.dirname(absDest) | 278 | dest_dir = os.path.dirname(absDest) |
278 | if not os.path.isdir(dest_dir): | 279 | if not os.path.isdir(dest_dir): |
279 | os.makedirs(dest_dir) | 280 | os.makedirs(dest_dir) |
280 | os.symlink(relSrc, absDest) | 281 | platform_utils.symlink(relSrc, absDest) |
281 | except IOError: | 282 | except IOError: |
282 | _error('Cannot link file %s to %s', relSrc, absDest) | 283 | _error('Cannot link file %s to %s', relSrc, absDest) |
283 | 284 | ||
@@ -2379,7 +2380,8 @@ class Project(object): | |||
2379 | self.relpath, name) | 2380 | self.relpath, name) |
2380 | continue | 2381 | continue |
2381 | try: | 2382 | try: |
2382 | os.symlink(os.path.relpath(stock_hook, os.path.dirname(dst)), dst) | 2383 | platform_utils.symlink( |
2384 | os.path.relpath(stock_hook, os.path.dirname(dst)), dst) | ||
2383 | except OSError as e: | 2385 | except OSError as e: |
2384 | if e.errno == errno.EPERM: | 2386 | if e.errno == errno.EPERM: |
2385 | raise GitError('filesystem must support symlinks') | 2387 | raise GitError('filesystem must support symlinks') |
@@ -2478,7 +2480,8 @@ class Project(object): | |||
2478 | os.makedirs(src) | 2480 | os.makedirs(src) |
2479 | 2481 | ||
2480 | if name in to_symlink: | 2482 | if name in to_symlink: |
2481 | os.symlink(os.path.relpath(src, os.path.dirname(dst)), dst) | 2483 | platform_utils.symlink( |
2484 | os.path.relpath(src, os.path.dirname(dst)), dst) | ||
2482 | elif copy_all and not os.path.islink(dst): | 2485 | elif copy_all and not os.path.islink(dst): |
2483 | if os.path.isdir(src): | 2486 | if os.path.isdir(src): |
2484 | shutil.copytree(src, dst) | 2487 | shutil.copytree(src, dst) |