summaryrefslogtreecommitdiffstats
path: root/project.py
diff options
context:
space:
mode:
Diffstat (limited to 'project.py')
-rw-r--r--project.py26
1 files changed, 24 insertions, 2 deletions
diff --git a/project.py b/project.py
index 3643762e..382650fb 100644
--- a/project.py
+++ b/project.py
@@ -2760,9 +2760,31 @@ class Project(object):
2760 symlink_dirs += self.working_tree_dirs 2760 symlink_dirs += self.working_tree_dirs
2761 to_symlink = symlink_files + symlink_dirs 2761 to_symlink = symlink_files + symlink_dirs
2762 for name in set(to_symlink): 2762 for name in set(to_symlink):
2763 dst = platform_utils.realpath(os.path.join(destdir, name)) 2763 # Try to self-heal a bit in simple cases.
2764 dst_path = os.path.join(destdir, name)
2765 src_path = os.path.join(srcdir, name)
2766
2767 if name in self.working_tree_dirs:
2768 # If the dir is missing under .repo/projects/, create it.
2769 if not os.path.exists(src_path):
2770 os.makedirs(src_path)
2771
2772 elif name in self.working_tree_files:
2773 # If it's a file under the checkout .git/ and the .repo/projects/ has
2774 # nothing, move the file under the .repo/projects/ tree.
2775 if not os.path.exists(src_path) and os.path.isfile(dst_path):
2776 platform_utils.rename(dst_path, src_path)
2777
2778 # If the path exists under the .repo/projects/ and there's no symlink
2779 # under the checkout .git/, recreate the symlink.
2780 if name in self.working_tree_dirs or name in self.working_tree_files:
2781 if os.path.exists(src_path) and not os.path.exists(dst_path):
2782 platform_utils.symlink(
2783 os.path.relpath(src_path, os.path.dirname(dst_path)), dst_path)
2784
2785 dst = platform_utils.realpath(dst_path)
2764 if os.path.lexists(dst): 2786 if os.path.lexists(dst):
2765 src = platform_utils.realpath(os.path.join(srcdir, name)) 2787 src = platform_utils.realpath(src_path)
2766 # Fail if the links are pointing to the wrong place 2788 # Fail if the links are pointing to the wrong place
2767 if src != dst: 2789 if src != dst:
2768 _error('%s is different in %s vs %s', name, destdir, srcdir) 2790 _error('%s is different in %s vs %s', name, destdir, srcdir)