summaryrefslogtreecommitdiffstats
path: root/subcmds/start.py
diff options
context:
space:
mode:
authorSimran Basi <sbasi@google.com>2015-08-20 12:19:28 -0700
committerDan Willemsen <dwillemsen@google.com>2015-08-28 10:53:05 -0700
commitb9a1b73425773dc97843f92aeee9c57c9a08c0f7 (patch)
tree592a3655e92af8c7265ba07e29ba35aa1a1a36a8 /subcmds/start.py
parentdc2545cad60d7e8bae894f5d60eaeb3cff7485ae (diff)
downloadgit-repo-b9a1b73425773dc97843f92aeee9c57c9a08c0f7.tar.gz
GITC: Add repo start support.
Add repo start support for GITC checkouts. If the user is in the GITC FS view, they can now run repo start to check out the sources and create a new working branch. When "repo start" is called on a GITC project, the revision tag is set to an empty string and saved in a new tag: old-revision. This tells the GITC filesystem to display the local copy of the sources when being viewed. The local copy is created by pulling the project sources and the new branch is created based off the original project revision. Updated main.py to setup each command's gitc_manifest when appropriate. Updated repo sync's logic to sync opened projects and updating the GITC manifest file for the rest. Change-Id: I7e4809d1c4fc43c69b26f2f1bebe45aab0cae628
Diffstat (limited to 'subcmds/start.py')
-rw-r--r--subcmds/start.py42
1 files changed, 38 insertions, 4 deletions
diff --git a/subcmds/start.py b/subcmds/start.py
index 60ad41e0..188fd7c6 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,50 @@ 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 proj_name_to_gitc_proj_dict = {}
61 if self.gitc_manifest:
62 all_projects = self.GetProjects(projects, manifest=self.gitc_manifest,
63 missing_ok=True)
64 for project in all_projects:
65 if project.old_revision:
66 project.already_synced = True
67 else:
68 project.already_synced = False
69 project.old_revision = project.revisionExpr
70 proj_name_to_gitc_proj_dict[project.name] = project
71 project.revisionExpr = None
72 # Save the GITC manifest.
73 gitc_utils.save_manifest(self.gitc_manifest)
57 74
75 all_projects = self.GetProjects(projects,
76 missing_ok=bool(self.gitc_manifest))
58 pm = Progress('Starting %s' % nb, len(all_projects)) 77 pm = Progress('Starting %s' % nb, len(all_projects))
59 for project in all_projects: 78 for project in all_projects:
60 pm.update() 79 pm.update()
80 if self.gitc_manifest:
81 gitc_project = proj_name_to_gitc_proj_dict[project.name]
82 # Sync projects that have already been opened.
83 if not gitc_project.already_synced:
84 proj_localdir = os.path.join(self.gitc_manifest.gitc_client_dir,
85 project.relpath)
86 project.worktree = proj_localdir
87 if not os.path.exists(proj_localdir):
88 os.makedirs(proj_localdir)
89 project.Sync_NetworkHalf()
90 sync_buf = SyncBuffer(self.manifest.manifestProject.config)
91 project.Sync_LocalHalf(sync_buf)
92 project.revisionExpr = gitc_project.old_revision
93
61 # If the current revision is a specific SHA1 then we can't push back 94 # 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 95 # to it; so substitute with dest_branch if defined, or with manifest
63 # default revision instead. 96 # default revision instead.
97 branch_merge = ''
64 if IsId(project.revisionExpr): 98 if IsId(project.revisionExpr):
65 if project.dest_branch: 99 if project.dest_branch:
66 project.revisionExpr = project.dest_branch 100 branch_merge = project.dest_branch
67 else: 101 else:
68 project.revisionExpr = self.manifest.default.revisionExpr 102 branch_merge = self.manifest.default.revisionExpr
69 if not project.StartBranch(nb): 103 if not project.StartBranch(nb, branch_merge=branch_merge):
70 err.append(project) 104 err.append(project)
71 pm.end() 105 pm.end()
72 106