summaryrefslogtreecommitdiffstats
path: root/subcmds/sync.py
diff options
context:
space:
mode:
authorRenaud Paquay <rpaquay@google.com>2018-09-27 10:46:58 -0700
committerRenaud Paquay <rpaquay@google.com>2018-10-22 08:16:35 -0700
commitbed8b62345e484b27e048e8f21280c5611f795df (patch)
tree4efc8203f0a092428377ebc3e3494f01fdb9b90c /subcmds/sync.py
parentb3133a31642ea88f0e4fe9c382411d43278dc9e4 (diff)
downloadgit-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 'subcmds/sync.py')
-rw-r--r--subcmds/sync.py26
1 files changed, 13 insertions, 13 deletions
diff --git a/subcmds/sync.py b/subcmds/sync.py
index 943a0264..f6bd983d 100644
--- a/subcmds/sync.py
+++ b/subcmds/sync.py
@@ -474,8 +474,8 @@ later is required to fix a server side protocol bug.
474 # so rmtree works. 474 # so rmtree works.
475 try: 475 try:
476 platform_utils.rmtree(os.path.join(path, '.git')) 476 platform_utils.rmtree(os.path.join(path, '.git'))
477 except OSError: 477 except OSError as e:
478 print('Failed to remove %s' % os.path.join(path, '.git'), file=sys.stderr) 478 print('Failed to remove %s (%s)' % (os.path.join(path, '.git'), str(e)), file=sys.stderr)
479 print('error: Failed to delete obsolete path %s' % path, file=sys.stderr) 479 print('error: Failed to delete obsolete path %s' % path, file=sys.stderr)
480 print(' remove manually, then run sync again', file=sys.stderr) 480 print(' remove manually, then run sync again', file=sys.stderr)
481 return -1 481 return -1
@@ -484,12 +484,12 @@ later is required to fix a server side protocol bug.
484 # another git project 484 # another git project
485 dirs_to_remove = [] 485 dirs_to_remove = []
486 failed = False 486 failed = False
487 for root, dirs, files in os.walk(path): 487 for root, dirs, files in platform_utils.walk(path):
488 for f in files: 488 for f in files:
489 try: 489 try:
490 platform_utils.remove(os.path.join(root, f)) 490 platform_utils.remove(os.path.join(root, f))
491 except OSError: 491 except OSError as e:
492 print('Failed to remove %s' % os.path.join(root, f), file=sys.stderr) 492 print('Failed to remove %s (%s)' % (os.path.join(root, f), str(e)), file=sys.stderr)
493 failed = True 493 failed = True
494 dirs[:] = [d for d in dirs 494 dirs[:] = [d for d in dirs
495 if not os.path.lexists(os.path.join(root, d, '.git'))] 495 if not os.path.lexists(os.path.join(root, d, '.git'))]
@@ -499,14 +499,14 @@ later is required to fix a server side protocol bug.
499 if platform_utils.islink(d): 499 if platform_utils.islink(d):
500 try: 500 try:
501 platform_utils.remove(d) 501 platform_utils.remove(d)
502 except OSError: 502 except OSError as e:
503 print('Failed to remove %s' % os.path.join(root, d), file=sys.stderr) 503 print('Failed to remove %s (%s)' % (os.path.join(root, d), str(e)), file=sys.stderr)
504 failed = True 504 failed = True
505 elif len(os.listdir(d)) == 0: 505 elif len(platform_utils.listdir(d)) == 0:
506 try: 506 try:
507 os.rmdir(d) 507 platform_utils.rmdir(d)
508 except OSError: 508 except OSError as e:
509 print('Failed to remove %s' % os.path.join(root, d), file=sys.stderr) 509 print('Failed to remove %s (%s)' % (os.path.join(root, d), str(e)), file=sys.stderr)
510 failed = True 510 failed = True
511 continue 511 continue
512 if failed: 512 if failed:
@@ -517,8 +517,8 @@ later is required to fix a server side protocol bug.
517 # Try deleting parent dirs if they are empty 517 # Try deleting parent dirs if they are empty
518 project_dir = path 518 project_dir = path
519 while project_dir != self.manifest.topdir: 519 while project_dir != self.manifest.topdir:
520 if len(os.listdir(project_dir)) == 0: 520 if len(platform_utils.listdir(project_dir)) == 0:
521 os.rmdir(project_dir) 521 platform_utils.rmdir(project_dir)
522 else: 522 else:
523 break 523 break
524 project_dir = os.path.dirname(project_dir) 524 project_dir = os.path.dirname(project_dir)