diff options
author | Dan Willemsen <dwillemsen@google.com> | 2015-09-08 13:27:20 -0700 |
---|---|---|
committer | Dan Willemsen <dwillemsen@google.com> | 2015-09-09 20:50:40 -0700 |
commit | 5ea32d135963da5542b78895f95332c6a17bbe11 (patch) | |
tree | 832e03decd9f0d7b412b111e00bd28b89c1c9ea6 /subcmds | |
parent | 5cc384034d144c339d2e5822c36c5ca4529ac487 (diff) | |
download | git-repo-5ea32d135963da5542b78895f95332c6a17bbe11.tar.gz |
GITC: Always update the gitc manifest from the repo manifestv1.12.31
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
Diffstat (limited to 'subcmds')
-rw-r--r-- | subcmds/gitc_init.py | 12 | ||||
-rw-r--r-- | subcmds/start.py | 10 | ||||
-rw-r--r-- | subcmds/sync.py | 32 |
3 files changed, 32 insertions, 22 deletions
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 | |||
19 | 19 | ||
20 | import gitc_utils | 20 | import gitc_utils |
21 | from command import RequiresGitcCommand | 21 | from command import RequiresGitcCommand |
22 | from manifest_xml import GitcManifest | ||
22 | from subcmds import init | 23 | from subcmds import init |
23 | 24 | ||
24 | 25 | ||
@@ -68,15 +69,16 @@ use for this GITC client. | |||
68 | os.mkdir(self.client_dir) | 69 | os.mkdir(self.client_dir) |
69 | super(GitcInit, self).Execute(opt, args) | 70 | super(GitcInit, self).Execute(opt, args) |
70 | 71 | ||
71 | for name, remote in self.manifest.remotes.iteritems(): | 72 | manifest_file = self.manifest.manifestFile |
72 | remote.fetchUrl = remote.resolvedFetchUrl | ||
73 | |||
74 | if opt.manifest_file: | 73 | if opt.manifest_file: |
75 | if not os.path.exists(opt.manifest_file): | 74 | if not os.path.exists(opt.manifest_file): |
76 | print('fatal: Specified manifest file %s does not exist.' % | 75 | print('fatal: Specified manifest file %s does not exist.' % |
77 | opt.manifest_file) | 76 | opt.manifest_file) |
78 | sys.exit(1) | 77 | sys.exit(1) |
79 | self.manifest.Override(opt.manifest_file) | 78 | manifest_file = opt.manifest_file |
80 | gitc_utils.generate_gitc_manifest(self.client_dir, self.manifest) | 79 | |
80 | manifest = GitcManifest(self.repodir, opt.gitc_client) | ||
81 | manifest.Override(manifest_file) | ||
82 | gitc_utils.generate_gitc_manifest(None, manifest) | ||
81 | print('Please run `cd %s` to view your GITC client.' % | 83 | print('Please run `cd %s` to view your GITC client.' % |
82 | os.path.join(gitc_utils.GITC_FS_ROOT_DIR, opt.gitc_client)) | 84 | 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. | |||
57 | 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) |
58 | sys.exit(1) | 58 | sys.exit(1) |
59 | 59 | ||
60 | proj_name_to_gitc_proj_dict = {} | ||
61 | if self.gitc_manifest: | 60 | if self.gitc_manifest: |
62 | all_projects = self.GetProjects(projects, manifest=self.gitc_manifest, | 61 | all_projects = self.GetProjects(projects, manifest=self.gitc_manifest, |
63 | missing_ok=True) | 62 | missing_ok=True) |
@@ -67,7 +66,6 @@ revision specified in the manifest. | |||
67 | else: | 66 | else: |
68 | project.already_synced = False | 67 | project.already_synced = False |
69 | project.old_revision = project.revisionExpr | 68 | project.old_revision = project.revisionExpr |
70 | proj_name_to_gitc_proj_dict[project.name] = project | ||
71 | project.revisionExpr = None | 69 | project.revisionExpr = None |
72 | # Save the GITC manifest. | 70 | # Save the GITC manifest. |
73 | gitc_utils.save_manifest(self.gitc_manifest) | 71 | gitc_utils.save_manifest(self.gitc_manifest) |
@@ -77,9 +75,10 @@ revision specified in the manifest. | |||
77 | pm = Progress('Starting %s' % nb, len(all_projects)) | 75 | pm = Progress('Starting %s' % nb, len(all_projects)) |
78 | for project in all_projects: | 76 | for project in all_projects: |
79 | pm.update() | 77 | pm.update() |
78 | |||
80 | if self.gitc_manifest: | 79 | if self.gitc_manifest: |
81 | gitc_project = proj_name_to_gitc_proj_dict[project.name] | 80 | gitc_project = self.gitc_manifest.paths[project.relpath] |
82 | # Sync projects that have already been opened. | 81 | # Sync projects that have not been opened. |
83 | if not gitc_project.already_synced: | 82 | if not gitc_project.already_synced: |
84 | proj_localdir = os.path.join(self.gitc_manifest.gitc_client_dir, | 83 | proj_localdir = os.path.join(self.gitc_manifest.gitc_client_dir, |
85 | project.relpath) | 84 | project.relpath) |
@@ -89,7 +88,7 @@ revision specified in the manifest. | |||
89 | project.Sync_NetworkHalf() | 88 | project.Sync_NetworkHalf() |
90 | sync_buf = SyncBuffer(self.manifest.manifestProject.config) | 89 | sync_buf = SyncBuffer(self.manifest.manifestProject.config) |
91 | project.Sync_LocalHalf(sync_buf) | 90 | project.Sync_LocalHalf(sync_buf) |
92 | project.revisionExpr = gitc_project.old_revision | 91 | project.revisionId = gitc_project.old_revision |
93 | 92 | ||
94 | # If the current revision is a specific SHA1 then we can't push back | 93 | # If the current revision is a specific SHA1 then we can't push back |
95 | # to it; so substitute with dest_branch if defined, or with manifest | 94 | # to it; so substitute with dest_branch if defined, or with manifest |
@@ -100,6 +99,7 @@ revision specified in the manifest. | |||
100 | branch_merge = project.dest_branch | 99 | branch_merge = project.dest_branch |
101 | else: | 100 | else: |
102 | branch_merge = self.manifest.default.revisionExpr | 101 | branch_merge = self.manifest.default.revisionExpr |
102 | |||
103 | if not project.StartBranch(nb, branch_merge=branch_merge): | 103 | if not project.StartBranch(nb, branch_merge=branch_merge): |
104 | err.append(project) | 104 | err.append(project) |
105 | pm.end() | 105 | 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 | |||
75 | from project import SyncBuffer | 75 | from project import SyncBuffer |
76 | from progress import Progress | 76 | from progress import Progress |
77 | from wrapper import Wrapper | 77 | from wrapper import Wrapper |
78 | from manifest_xml import GitcManifest | ||
78 | 79 | ||
79 | _ONE_DAY_S = 24 * 60 * 60 | 80 | _ONE_DAY_S = 24 * 60 * 60 |
80 | 81 | ||
@@ -670,32 +671,39 @@ later is required to fix a server side protocol bug. | |||
670 | if opt.jobs is None: | 671 | if opt.jobs is None: |
671 | self.jobs = self.manifest.default.sync_j | 672 | self.jobs = self.manifest.default.sync_j |
672 | 673 | ||
673 | # TODO (sbasi) - Add support for manifest changes, aka projects | ||
674 | # have been added or deleted from the manifest. | ||
675 | if self.gitc_manifest: | 674 | if self.gitc_manifest: |
676 | gitc_manifest_projects = self.GetProjects(args, | 675 | gitc_manifest_projects = self.GetProjects(args, |
677 | manifest=self.gitc_manifest, | ||
678 | missing_ok=True) | 676 | missing_ok=True) |
679 | gitc_projects = [] | 677 | gitc_projects = [] |
680 | opened_projects = [] | 678 | opened_projects = [] |
681 | for project in gitc_manifest_projects: | 679 | for project in gitc_manifest_projects: |
682 | if not project.old_revision: | 680 | if project.relpath in self.gitc_manifest.paths and \ |
683 | gitc_projects.append(project) | 681 | self.gitc_manifest.paths[project.relpath].old_revision: |
682 | opened_projects.append(project.relpath) | ||
684 | else: | 683 | else: |
685 | opened_projects.append(project) | 684 | gitc_projects.append(project.relpath) |
686 | 685 | ||
687 | if gitc_projects and not opt.local_only: | 686 | if not args: |
687 | gitc_projects = None | ||
688 | |||
689 | if gitc_projects != [] and not opt.local_only: | ||
688 | print('Updating GITC client: %s' % self.gitc_manifest.gitc_client_name) | 690 | print('Updating GITC client: %s' % self.gitc_manifest.gitc_client_name) |
689 | gitc_utils.generate_gitc_manifest(self.gitc_manifest.gitc_client_dir, | 691 | manifest = GitcManifest(self.repodir, self.gitc_manifest.gitc_client_name) |
690 | self.gitc_manifest, | 692 | if manifest_name: |
693 | manifest.Override(manifest_name) | ||
694 | else: | ||
695 | manifest.Override(self.manifest.manifestFile) | ||
696 | gitc_utils.generate_gitc_manifest(self.gitc_manifest, | ||
697 | manifest, | ||
691 | gitc_projects) | 698 | gitc_projects) |
692 | print('GITC client successfully synced.') | 699 | print('GITC client successfully synced.') |
693 | 700 | ||
694 | # The opened projects need to be synced as normal, therefore we | 701 | # The opened projects need to be synced as normal, therefore we |
695 | # generate a new args list to represent the opened projects. | 702 | # generate a new args list to represent the opened projects. |
696 | args = [] | 703 | # TODO: make this more reliable -- if there's a project name/path overlap, |
697 | for proj in opened_projects: | 704 | # this may choose the wrong project. |
698 | args.append(os.path.relpath(proj.worktree, os.getcwd())) | 705 | args = [os.path.relpath(self.manifest.paths[p].worktree, os.getcwd()) |
706 | for p in opened_projects] | ||
699 | if not args: | 707 | if not args: |
700 | return | 708 | return |
701 | all_projects = self.GetProjects(args, | 709 | all_projects = self.GetProjects(args, |