summaryrefslogtreecommitdiffstats
path: root/project.py
diff options
context:
space:
mode:
authorLaMont Jones <lamontjones@google.com>2022-08-31 20:21:25 +0000
committerLaMont Jones <lamontjones@google.com>2022-09-08 23:28:27 +0000
commitaf8fb132d50bc76386677140ebeaf323f0f5d4e1 (patch)
tree3e5205cb2c14237255c6dc71306d5e299a6a3574 /project.py
parent4112c07688d0e0e568478e9f42be349bdd511d45 (diff)
downloadgit-repo-af8fb132d50bc76386677140ebeaf323f0f5d4e1.tar.gz
Revert "project: initialize new manifests in temp dirs"
This reverts commit 07d21e6bde9bd7efdfb8f25f2ed23f023daa5c1f. Reason for revert: crbug.com/gerrit/16230, b/244467766 - breaks aosp-master-with-phones case Change-Id: Id967d92f8622c2c13356b09e46ece9f20040aabc Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/344314 Tested-by: LaMont Jones <lamontjones@google.com> Reviewed-by: Xin Li <delphij@google.com>
Diffstat (limited to 'project.py')
-rw-r--r--project.py42
1 files changed, 5 insertions, 37 deletions
diff --git a/project.py b/project.py
index ab449f00..2b57a5fb 100644
--- a/project.py
+++ b/project.py
@@ -2794,35 +2794,6 @@ class Project(object):
2794 else: 2794 else:
2795 raise 2795 raise
2796 2796
2797 def _InitialCheckoutStart(self):
2798 """Called when checking out a project for the first time.
2799
2800 This will use temporary non-visible paths so we can be safely interrupted
2801 without leaving incomplete state behind.
2802 """
2803 paths = [f'{x}.tmp' for x in (self.relpath, self.worktree, self.gitdir, self.objdir)]
2804 for p in paths:
2805 platform_utils.rmtree(p, ignore_errors=True)
2806 self.UpdatePaths(*paths)
2807
2808 def _InitialCheckoutFinalizeNetworkHalf(self):
2809 """Finalize the object dirs after network syncing works."""
2810 # Once the network half finishes, we can move the objects into the right
2811 # place by removing the ".tmp" suffix on the dirs.
2812 platform_utils.rmtree(self.gitdir[:-4], ignore_errors=True)
2813 os.rename(self.gitdir, self.gitdir[:-4])
2814 self.UpdatePaths(self.relpath, self.worktree, self.gitdir[:-4], self.objdir[:-4])
2815
2816 def _InitialCheckoutFinalizeLocalHalf(self):
2817 """Finalize the initial checkout and make it available."""
2818 assert self.gitdir == self.objdir
2819 # Once the local half finishes, we can move the manifest dir into the right
2820 # place by removing the ".tmp" suffix on the dirs.
2821 platform_utils.rmtree(self.worktree[:-4], ignore_errors=True)
2822 os.rename(self.worktree, self.worktree[:-4])
2823 self.UpdatePaths(
2824 self.relpath[:-4], self.worktree[:-4], self.gitdir, self.objdir)
2825
2826 def _InitGitWorktree(self): 2797 def _InitGitWorktree(self):
2827 """Init the project using git worktrees.""" 2798 """Init the project using git worktrees."""
2828 self.bare_git.worktree('prune') 2799 self.bare_git.worktree('prune')
@@ -3709,8 +3680,6 @@ class ManifestProject(MetaProject):
3709 (GitConfig.ForUser().UrlInsteadOf(manifest_url),), 3680 (GitConfig.ForUser().UrlInsteadOf(manifest_url),),
3710 file=sys.stderr) 3681 file=sys.stderr)
3711 3682
3712 self._InitialCheckoutStart()
3713
3714 # The manifest project object doesn't keep track of the path on the 3683 # The manifest project object doesn't keep track of the path on the
3715 # server where this git is located, so let's save that here. 3684 # server where this git is located, so let's save that here.
3716 mirrored_manifest_git = None 3685 mirrored_manifest_git = None
@@ -3870,14 +3839,16 @@ class ManifestProject(MetaProject):
3870 partial_clone_exclude=self.manifest.PartialCloneExclude): 3839 partial_clone_exclude=self.manifest.PartialCloneExclude):
3871 r = self.GetRemote() 3840 r = self.GetRemote()
3872 print('fatal: cannot obtain manifest %s' % r.url, file=sys.stderr) 3841 print('fatal: cannot obtain manifest %s' % r.url, file=sys.stderr)
3842
3843 # Better delete the manifest git dir if we created it; otherwise next
3844 # time (when user fixes problems) we won't go through the "is_new" logic.
3845 if is_new:
3846 platform_utils.rmtree(self.gitdir)
3873 return False 3847 return False
3874 3848
3875 if manifest_branch: 3849 if manifest_branch:
3876 self.MetaBranchSwitch(submodules=submodules) 3850 self.MetaBranchSwitch(submodules=submodules)
3877 3851
3878 if is_new:
3879 self._InitialCheckoutFinalizeNetworkHalf()
3880
3881 syncbuf = SyncBuffer(self.config) 3852 syncbuf = SyncBuffer(self.config)
3882 self.Sync_LocalHalf(syncbuf, submodules=submodules) 3853 self.Sync_LocalHalf(syncbuf, submodules=submodules)
3883 syncbuf.Finish() 3854 syncbuf.Finish()
@@ -3900,9 +3871,6 @@ class ManifestProject(MetaProject):
3900 with open(dest, 'wb') as f: 3871 with open(dest, 'wb') as f:
3901 f.write(manifest_data) 3872 f.write(manifest_data)
3902 3873
3903 if is_new:
3904 self._InitialCheckoutFinalizeLocalHalf()
3905
3906 try: 3874 try:
3907 self.manifest.Link(manifest_name) 3875 self.manifest.Link(manifest_name)
3908 except ManifestParseError as e: 3876 except ManifestParseError as e: