summaryrefslogtreecommitdiffstats
path: root/subcmds/start.py
diff options
context:
space:
mode:
Diffstat (limited to 'subcmds/start.py')
-rw-r--r--subcmds/start.py49
1 files changed, 45 insertions, 4 deletions
diff --git a/subcmds/start.py b/subcmds/start.py
index 60ad41e0..d1430a9d 100644
--- a/subcmds/start.py
+++ b/subcmds/start.py
@@ -14,11 +14,15 @@
14# limitations under the License. 14# limitations under the License.
15 15
16from __future__ import print_function 16from __future__ import print_function
17import os
17import sys 18import sys
19
18from command import Command 20from command import Command
19from git_config import IsId 21from git_config import IsId
20from git_command import git 22from git_command import git
23import gitc_utils
21from progress import Progress 24from progress import Progress
25from project import SyncBuffer
22 26
23class Start(Command): 27class Start(Command):
24 common = True 28 common = True
@@ -53,20 +57,57 @@ revision specified in the manifest.
53 print("error: at least one project must be specified", file=sys.stderr) 57 print("error: at least one project must be specified", file=sys.stderr)
54 sys.exit(1) 58 sys.exit(1)
55 59
56 all_projects = self.GetProjects(projects) 60 all_projects = self.GetProjects(projects,
61 missing_ok=bool(self.gitc_manifest))
62
63 # This must happen after we find all_projects, since GetProjects may need
64 # the local directory, which will disappear once we save the GITC manifest.
65 if self.gitc_manifest:
66 gitc_projects = self.GetProjects(projects, manifest=self.gitc_manifest,
67 missing_ok=True)
68 for project in gitc_projects:
69 if project.old_revision:
70 project.already_synced = True
71 else:
72 project.already_synced = False
73 project.old_revision = project.revisionExpr
74 project.revisionExpr = None
75 # Save the GITC manifest.
76 gitc_utils.save_manifest(self.gitc_manifest)
77
78 # Make sure we have a valid CWD
79 if not os.path.exists(os.getcwd()):
80 os.chdir(self.manifest.topdir)
57 81
58 pm = Progress('Starting %s' % nb, len(all_projects)) 82 pm = Progress('Starting %s' % nb, len(all_projects))
59 for project in all_projects: 83 for project in all_projects:
60 pm.update() 84 pm.update()
85
86 if self.gitc_manifest:
87 gitc_project = self.gitc_manifest.paths[project.relpath]
88 # Sync projects that have not been opened.
89 if not gitc_project.already_synced:
90 proj_localdir = os.path.join(self.gitc_manifest.gitc_client_dir,
91 project.relpath)
92 project.worktree = proj_localdir
93 if not os.path.exists(proj_localdir):
94 os.makedirs(proj_localdir)
95 project.Sync_NetworkHalf()
96 sync_buf = SyncBuffer(self.manifest.manifestProject.config)
97 project.Sync_LocalHalf(sync_buf)
98 project.revisionId = gitc_project.old_revision
99
61 # If the current revision is a specific SHA1 then we can't push back 100 # If the current revision is a specific SHA1 then we can't push back
62 # to it; so substitute with dest_branch if defined, or with manifest 101 # to it; so substitute with dest_branch if defined, or with manifest
63 # default revision instead. 102 # default revision instead.
103 branch_merge = ''
64 if IsId(project.revisionExpr): 104 if IsId(project.revisionExpr):
65 if project.dest_branch: 105 if project.dest_branch:
66 project.revisionExpr = project.dest_branch 106 branch_merge = project.dest_branch
67 else: 107 else:
68 project.revisionExpr = self.manifest.default.revisionExpr 108 branch_merge = self.manifest.default.revisionExpr
69 if not project.StartBranch(nb): 109
110 if not project.StartBranch(nb, branch_merge=branch_merge):
70 err.append(project) 111 err.append(project)
71 pm.end() 112 pm.end()
72 113