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
diff --git a/subcmds/sync.py b/subcmds/sync.py
index 7b44dbd..a99d7e7 100644
--- a/subcmds/sync.py
+++ b/subcmds/sync.py
@@ -75,6 +75,7 @@
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 @@
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,