summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--manifest_xml.py9
-rw-r--r--project.py16
2 files changed, 21 insertions, 4 deletions
diff --git a/manifest_xml.py b/manifest_xml.py
index 3c43295e..db7a9286 100644
--- a/manifest_xml.py
+++ b/manifest_xml.py
@@ -768,8 +768,11 @@ https://gerrit.googlesource.com/git-repo/+/HEAD/docs/manifest-format.md
768 768
769 @property 769 @property
770 def is_multimanifest(self): 770 def is_multimanifest(self):
771 """Whether this is a multimanifest checkout""" 771 """Whether this is a multimanifest checkout.
772 return bool(self.outer_client.submanifests) 772
773 This is safe to use as long as the outermost manifest XML has been parsed.
774 """
775 return bool(self._outer_client._submanifests)
773 776
774 @property 777 @property
775 def is_submanifest(self): 778 def is_submanifest(self):
@@ -1679,7 +1682,7 @@ https://gerrit.googlesource.com/git-repo/+/HEAD/docs/manifest-format.md
1679 # We allow people to mix git worktrees & non-git worktrees for now. 1682 # We allow people to mix git worktrees & non-git worktrees for now.
1680 # This allows for in situ migration of repo clients. 1683 # This allows for in situ migration of repo clients.
1681 if os.path.exists(gitdir) or not self.UseGitWorktrees: 1684 if os.path.exists(gitdir) or not self.UseGitWorktrees:
1682 objdir = os.path.join(self.subdir, 'project-objects', namepath) 1685 objdir = os.path.join(self.repodir, 'project-objects', namepath)
1683 else: 1686 else:
1684 use_git_worktrees = True 1687 use_git_worktrees = True
1685 gitdir = os.path.join(self.repodir, 'worktrees', namepath) 1688 gitdir = os.path.join(self.repodir, 'worktrees', namepath)
diff --git a/project.py b/project.py
index b7ed6f33..faa6b32b 100644
--- a/project.py
+++ b/project.py
@@ -49,6 +49,9 @@ MAXIMUM_RETRY_SLEEP_SEC = 3600.0
49# +-10% random jitter is added to each Fetches retry sleep duration. 49# +-10% random jitter is added to each Fetches retry sleep duration.
50RETRY_JITTER_PERCENT = 0.1 50RETRY_JITTER_PERCENT = 0.1
51 51
52# Whether to use alternates.
53# TODO(vapier): Remove knob once behavior is verified.
54_ALTERNATES = os.environ.get('REPO_USE_ALTERNATES') == '1'
52 55
53def _lwrite(path, content): 56def _lwrite(path, content):
54 lock = '%s.lock' % path 57 lock = '%s.lock' % path
@@ -460,7 +463,7 @@ class RemoteSpec(object):
460 463
461class Project(object): 464class Project(object):
462 # These objects can be shared between several working trees. 465 # These objects can be shared between several working trees.
463 shareable_dirs = ['hooks', 'objects', 'rr-cache'] 466 shareable_dirs = ['hooks', 'rr-cache']
464 467
465 def __init__(self, 468 def __init__(self,
466 manifest, 469 manifest,
@@ -1143,6 +1146,17 @@ class Project(object):
1143 self._UpdateHooks(quiet=quiet) 1146 self._UpdateHooks(quiet=quiet)
1144 self._InitRemote() 1147 self._InitRemote()
1145 1148
1149 if _ALTERNATES or self.manifest.is_multimanifest:
1150 # If gitdir/objects is a symlink, migrate it from the old layout.
1151 gitdir_objects = os.path.join(self.gitdir, 'objects')
1152 if platform_utils.islink(gitdir_objects):
1153 platform_utils.remove(gitdir_objects, missing_ok=True)
1154 gitdir_alt = os.path.join(self.gitdir, 'objects/info/alternates')
1155 if not os.path.exists(gitdir_alt):
1156 os.makedirs(os.path.dirname(gitdir_alt), exist_ok=True)
1157 _lwrite(gitdir_alt, os.path.join(
1158 os.path.relpath(self.objdir, gitdir_objects), 'objects') + '\n')
1159
1146 if is_new: 1160 if is_new:
1147 alt = os.path.join(self.objdir, 'objects/info/alternates') 1161 alt = os.path.join(self.objdir, 'objects/info/alternates')
1148 try: 1162 try: