From 5ea32d135963da5542b78895f95332c6a17bbe11 Mon Sep 17 00:00:00 2001 From: Dan Willemsen Date: Tue, 8 Sep 2015 13:27:20 -0700 Subject: GITC: Always update the gitc manifest from the repo manifest This way any changes made to the main manifest are reflected in the gitc manifest. It's also necessary to use both manifests to sync since the information required to update the gitc manifest is actually in the repo manifest. This also fixes a few issues that came up when testing. notdefault groups weren't being saved to the gitc manifest in a method that matched 'sync'. The merge branch wasn't always being set to the correct value either. Change-Id: I435235cb5622a048ffad0059affd32ecf71f1f5b --- subcmds/gitc_init.py | 12 +++++++----- subcmds/start.py | 10 +++++----- subcmds/sync.py | 32 ++++++++++++++++++++------------ 3 files changed, 32 insertions(+), 22 deletions(-) (limited to 'subcmds') diff --git a/subcmds/gitc_init.py b/subcmds/gitc_init.py index e99affa5..71c50515 100644 --- a/subcmds/gitc_init.py +++ b/subcmds/gitc_init.py @@ -19,6 +19,7 @@ import sys import gitc_utils from command import RequiresGitcCommand +from manifest_xml import GitcManifest from subcmds import init @@ -68,15 +69,16 @@ use for this GITC client. os.mkdir(self.client_dir) super(GitcInit, self).Execute(opt, args) - for name, remote in self.manifest.remotes.iteritems(): - remote.fetchUrl = remote.resolvedFetchUrl - + manifest_file = self.manifest.manifestFile if opt.manifest_file: if not os.path.exists(opt.manifest_file): print('fatal: Specified manifest file %s does not exist.' % opt.manifest_file) sys.exit(1) - self.manifest.Override(opt.manifest_file) - gitc_utils.generate_gitc_manifest(self.client_dir, self.manifest) + manifest_file = opt.manifest_file + + manifest = GitcManifest(self.repodir, opt.gitc_client) + manifest.Override(manifest_file) + gitc_utils.generate_gitc_manifest(None, manifest) print('Please run `cd %s` to view your GITC client.' % os.path.join(gitc_utils.GITC_FS_ROOT_DIR, opt.gitc_client)) diff --git a/subcmds/start.py b/subcmds/start.py index 188fd7c6..940c3413 100644 --- a/subcmds/start.py +++ b/subcmds/start.py @@ -57,7 +57,6 @@ revision specified in the manifest. print("error: at least one project must be specified", file=sys.stderr) sys.exit(1) - proj_name_to_gitc_proj_dict = {} if self.gitc_manifest: all_projects = self.GetProjects(projects, manifest=self.gitc_manifest, missing_ok=True) @@ -67,7 +66,6 @@ revision specified in the manifest. else: project.already_synced = False project.old_revision = project.revisionExpr - proj_name_to_gitc_proj_dict[project.name] = project project.revisionExpr = None # Save the GITC manifest. gitc_utils.save_manifest(self.gitc_manifest) @@ -77,9 +75,10 @@ revision specified in the manifest. pm = Progress('Starting %s' % nb, len(all_projects)) for project in all_projects: pm.update() + if self.gitc_manifest: - gitc_project = proj_name_to_gitc_proj_dict[project.name] - # Sync projects that have already been opened. + gitc_project = self.gitc_manifest.paths[project.relpath] + # Sync projects that have not been opened. if not gitc_project.already_synced: proj_localdir = os.path.join(self.gitc_manifest.gitc_client_dir, project.relpath) @@ -89,7 +88,7 @@ revision specified in the manifest. project.Sync_NetworkHalf() sync_buf = SyncBuffer(self.manifest.manifestProject.config) project.Sync_LocalHalf(sync_buf) - project.revisionExpr = gitc_project.old_revision + project.revisionId = gitc_project.old_revision # If the current revision is a specific SHA1 then we can't push back # to it; so substitute with dest_branch if defined, or with manifest @@ -100,6 +99,7 @@ revision specified in the manifest. branch_merge = project.dest_branch else: branch_merge = self.manifest.default.revisionExpr + if not project.StartBranch(nb, branch_merge=branch_merge): err.append(project) pm.end() diff --git a/subcmds/sync.py b/subcmds/sync.py index 7b44dbd8..a99d7e74 100644 --- a/subcmds/sync.py +++ b/subcmds/sync.py @@ -75,6 +75,7 @@ from error import RepoChangedException, GitError, ManifestParseError from project import SyncBuffer from progress import Progress from wrapper import Wrapper +from manifest_xml import GitcManifest _ONE_DAY_S = 24 * 60 * 60 @@ -670,32 +671,39 @@ later is required to fix a server side protocol bug. 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) + if project.relpath in self.gitc_manifest.paths and \ + self.gitc_manifest.paths[project.relpath].old_revision: + opened_projects.append(project.relpath) else: - opened_projects.append(project) + gitc_projects.append(project.relpath) - if gitc_projects and not opt.local_only: + if not args: + gitc_projects = None + + 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, + manifest = GitcManifest(self.repodir, self.gitc_manifest.gitc_client_name) + if manifest_name: + manifest.Override(manifest_name) + else: + manifest.Override(self.manifest.manifestFile) + gitc_utils.generate_gitc_manifest(self.gitc_manifest, + 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, os.getcwd())) + # TODO: make this more reliable -- if there's a project name/path overlap, + # this may choose the wrong project. + args = [os.path.relpath(self.manifest.paths[p].worktree, os.getcwd()) + for p in opened_projects] if not args: return all_projects = self.GetProjects(args, -- cgit v1.2.3-54-g00ecf