From b9a1b73425773dc97843f92aeee9c57c9a08c0f7 Mon Sep 17 00:00:00 2001 From: Simran Basi Date: Thu, 20 Aug 2015 12:19:28 -0700 Subject: 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 --- subcmds/sync.py | 44 +++++++++++++++++++++++++++++--------------- 1 file changed, 29 insertions(+), 15 deletions(-) (limited to 'subcmds/sync.py') diff --git a/subcmds/sync.py b/subcmds/sync.py index ad0ecdf4..934aaa80 100644 --- a/subcmds/sync.py +++ b/subcmds/sync.py @@ -549,15 +549,6 @@ later is required to fix a server side protocol bug. cwd.split(gitc_utils.GITC_MANIFEST_DIR)[1])) sys.exit(1) - self._gitc_sync = False - if cwd.startswith(gitc_utils.GITC_FS_ROOT_DIR): - self._gitc_sync = True - self._client_name = cwd.split(gitc_utils.GITC_FS_ROOT_DIR)[1].split( - '/')[0] - self._client_dir = os.path.join(gitc_utils.GITC_MANIFEST_DIR, - self._client_name) - print('Updating GITC client: %s' % self._client_name) - if opt.manifest_name: self.manifest.Override(opt.manifest_name) @@ -677,12 +668,6 @@ later is required to fix a server side protocol bug. if opt.repo_upgraded: _PostRepoUpgrade(self.manifest, quiet=opt.quiet) - if self._gitc_sync: - gitc_utils.generate_gitc_manifest(self._client_dir, self.manifest) - print('GITC client successfully synced.') - return - - if not opt.local_only: mp.Sync_NetworkHalf(quiet=opt.quiet, current_branch_only=opt.current_branch_only, @@ -697,6 +682,35 @@ later is required to fix a server side protocol bug. self._ReloadManifest(manifest_name) if opt.jobs is None: self.jobs = self.manifest.default.sync_j + + # TODO (sbasi) - Add support for manifest changes, aka projects + # have been added or deleted from the manifest. + if self.gitc_manifest: + gitc_manifest_projects = self.GetProjects(args, + manifest=self.gitc_manifest, + missing_ok=True) + gitc_projects = [] + opened_projects = [] + for project in gitc_manifest_projects: + if not project.old_revision: + gitc_projects.append(project) + else: + opened_projects.append(project) + + if gitc_projects and not opt.local_only: + print('Updating GITC client: %s' % self.gitc_manifest.gitc_client_name) + gitc_utils.generate_gitc_manifest(self.gitc_manifest.gitc_client_dir, + self.gitc_manifest, + gitc_projects) + print('GITC client successfully synced.') + + # The opened projects need to be synced as normal, therefore we + # generate a new args list to represent the opened projects. + args = [] + for proj in opened_projects: + args.append(os.path.relpath(proj.worktree, cwd)) + if not args: + return all_projects = self.GetProjects(args, missing_ok=True, submodules_ok=opt.fetch_submodules) -- cgit v1.2.3-54-g00ecf