diff options
author | Renaud Paquay <rpaquay@google.com> | 2018-09-27 10:46:58 -0700 |
---|---|---|
committer | Renaud Paquay <rpaquay@google.com> | 2018-10-22 08:16:35 -0700 |
commit | bed8b62345e484b27e048e8f21280c5611f795df (patch) | |
tree | 4efc8203f0a092428377ebc3e3494f01fdb9b90c /project.py | |
parent | b3133a31642ea88f0e4fe9c382411d43278dc9e4 (diff) | |
download | git-repo-bed8b62345e484b27e048e8f21280c5611f795df.tar.gz |
Add support for long paths
* Add more file i/o wrappers in platform_utils to allow using
long paths (length > MAX_PATH) on Windows.
* Paths using the long path syntax ("\\?\" prefix) should never
escape the platform_utils API surface area, so that this
specific syntax is not visible to the rest of the repo code base.
* Forward many calls from os.xxx to platform_utils.xxx in various place
to ensure long paths support, specifically when repo decides to delete
obsolete directories.
* There are more places that need to be converted to support long paths,
this commit is an initial effort to unblock a few common use cases.
* Also, fix remove function to handle directory symlinks
Change-Id: If82ccc408e516e96ff7260be25f8fd2fe3f9571a
Diffstat (limited to 'project.py')
-rwxr-xr-x | project.py | 16 |
1 files changed, 8 insertions, 8 deletions
@@ -103,7 +103,7 @@ def _ProjectHooks(): | |||
103 | if _project_hook_list is None: | 103 | if _project_hook_list is None: |
104 | d = platform_utils.realpath(os.path.abspath(os.path.dirname(__file__))) | 104 | d = platform_utils.realpath(os.path.abspath(os.path.dirname(__file__))) |
105 | d = os.path.join(d, 'hooks') | 105 | d = os.path.join(d, 'hooks') |
106 | _project_hook_list = [os.path.join(d, x) for x in os.listdir(d)] | 106 | _project_hook_list = [os.path.join(d, x) for x in platform_utils.listdir(d)] |
107 | return _project_hook_list | 107 | return _project_hook_list |
108 | 108 | ||
109 | 109 | ||
@@ -253,7 +253,7 @@ class _CopyFile(object): | |||
253 | platform_utils.remove(dest) | 253 | platform_utils.remove(dest) |
254 | else: | 254 | else: |
255 | dest_dir = os.path.dirname(dest) | 255 | dest_dir = os.path.dirname(dest) |
256 | if not os.path.isdir(dest_dir): | 256 | if not platform_utils.isdir(dest_dir): |
257 | os.makedirs(dest_dir) | 257 | os.makedirs(dest_dir) |
258 | shutil.copy(src, dest) | 258 | shutil.copy(src, dest) |
259 | # make the file read-only | 259 | # make the file read-only |
@@ -282,7 +282,7 @@ class _LinkFile(object): | |||
282 | platform_utils.remove(absDest) | 282 | platform_utils.remove(absDest) |
283 | else: | 283 | else: |
284 | dest_dir = os.path.dirname(absDest) | 284 | dest_dir = os.path.dirname(absDest) |
285 | if not os.path.isdir(dest_dir): | 285 | if not platform_utils.isdir(dest_dir): |
286 | os.makedirs(dest_dir) | 286 | os.makedirs(dest_dir) |
287 | platform_utils.symlink(relSrc, absDest) | 287 | platform_utils.symlink(relSrc, absDest) |
288 | except IOError: | 288 | except IOError: |
@@ -302,7 +302,7 @@ class _LinkFile(object): | |||
302 | else: | 302 | else: |
303 | # Entity doesn't exist assume there is a wild card | 303 | # Entity doesn't exist assume there is a wild card |
304 | absDestDir = self.abs_dest | 304 | absDestDir = self.abs_dest |
305 | if os.path.exists(absDestDir) and not os.path.isdir(absDestDir): | 305 | if os.path.exists(absDestDir) and not platform_utils.isdir(absDestDir): |
306 | _error('Link error: src with wildcard, %s must be a directory', | 306 | _error('Link error: src with wildcard, %s must be a directory', |
307 | absDestDir) | 307 | absDestDir) |
308 | else: | 308 | else: |
@@ -750,7 +750,7 @@ class Project(object): | |||
750 | 750 | ||
751 | @property | 751 | @property |
752 | def Exists(self): | 752 | def Exists(self): |
753 | return os.path.isdir(self.gitdir) and os.path.isdir(self.objdir) | 753 | return platform_utils.isdir(self.gitdir) and platform_utils.isdir(self.objdir) |
754 | 754 | ||
755 | @property | 755 | @property |
756 | def CurrentBranch(self): | 756 | def CurrentBranch(self): |
@@ -931,7 +931,7 @@ class Project(object): | |||
931 | quiet: If True then only print the project name. Do not print | 931 | quiet: If True then only print the project name. Do not print |
932 | the modified files, branch name, etc. | 932 | the modified files, branch name, etc. |
933 | """ | 933 | """ |
934 | if not os.path.isdir(self.worktree): | 934 | if not platform_utils.isdir(self.worktree): |
935 | if output_redir is None: | 935 | if output_redir is None: |
936 | output_redir = sys.stdout | 936 | output_redir = sys.stdout |
937 | print(file=output_redir) | 937 | print(file=output_redir) |
@@ -2510,7 +2510,7 @@ class Project(object): | |||
2510 | 2510 | ||
2511 | to_copy = [] | 2511 | to_copy = [] |
2512 | if copy_all: | 2512 | if copy_all: |
2513 | to_copy = os.listdir(gitdir) | 2513 | to_copy = platform_utils.listdir(gitdir) |
2514 | 2514 | ||
2515 | dotgit = platform_utils.realpath(dotgit) | 2515 | dotgit = platform_utils.realpath(dotgit) |
2516 | for name in set(to_copy).union(to_symlink): | 2516 | for name in set(to_copy).union(to_symlink): |
@@ -2529,7 +2529,7 @@ class Project(object): | |||
2529 | platform_utils.symlink( | 2529 | platform_utils.symlink( |
2530 | os.path.relpath(src, os.path.dirname(dst)), dst) | 2530 | os.path.relpath(src, os.path.dirname(dst)), dst) |
2531 | elif copy_all and not platform_utils.islink(dst): | 2531 | elif copy_all and not platform_utils.islink(dst): |
2532 | if os.path.isdir(src): | 2532 | if platform_utils.isdir(src): |
2533 | shutil.copytree(src, dst) | 2533 | shutil.copytree(src, dst) |
2534 | elif os.path.isfile(src): | 2534 | elif os.path.isfile(src): |
2535 | shutil.copy(src, dst) | 2535 | shutil.copy(src, dst) |