diff options
Diffstat (limited to 'subcmds')
| -rw-r--r-- | subcmds/start.py | 42 | ||||
| -rw-r--r-- | subcmds/sync.py | 44 |
2 files changed, 67 insertions, 19 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 | ||
| 16 | from __future__ import print_function | 16 | from __future__ import print_function |
| 17 | import os | ||
| 17 | import sys | 18 | import sys |
| 19 | |||
| 18 | from command import Command | 20 | from command import Command |
| 19 | from git_config import IsId | 21 | from git_config import IsId |
| 20 | from git_command import git | 22 | from git_command import git |
| 23 | import gitc_utils | ||
| 21 | from progress import Progress | 24 | from progress import Progress |
| 25 | from project import SyncBuffer | ||
| 22 | 26 | ||
| 23 | class Start(Command): | 27 | class 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 | ||
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. | |||
| 549 | cwd.split(gitc_utils.GITC_MANIFEST_DIR)[1])) | 549 | cwd.split(gitc_utils.GITC_MANIFEST_DIR)[1])) |
| 550 | sys.exit(1) | 550 | sys.exit(1) |
| 551 | 551 | ||
| 552 | self._gitc_sync = False | ||
| 553 | if cwd.startswith(gitc_utils.GITC_FS_ROOT_DIR): | ||
| 554 | self._gitc_sync = True | ||
| 555 | self._client_name = cwd.split(gitc_utils.GITC_FS_ROOT_DIR)[1].split( | ||
| 556 | '/')[0] | ||
| 557 | self._client_dir = os.path.join(gitc_utils.GITC_MANIFEST_DIR, | ||
| 558 | self._client_name) | ||
| 559 | print('Updating GITC client: %s' % self._client_name) | ||
| 560 | |||
| 561 | if opt.manifest_name: | 552 | if opt.manifest_name: |
| 562 | self.manifest.Override(opt.manifest_name) | 553 | self.manifest.Override(opt.manifest_name) |
| 563 | 554 | ||
| @@ -677,12 +668,6 @@ later is required to fix a server side protocol bug. | |||
| 677 | if opt.repo_upgraded: | 668 | if opt.repo_upgraded: |
| 678 | _PostRepoUpgrade(self.manifest, quiet=opt.quiet) | 669 | _PostRepoUpgrade(self.manifest, quiet=opt.quiet) |
| 679 | 670 | ||
| 680 | if self._gitc_sync: | ||
| 681 | gitc_utils.generate_gitc_manifest(self._client_dir, self.manifest) | ||
| 682 | print('GITC client successfully synced.') | ||
| 683 | return | ||
| 684 | |||
| 685 | |||
| 686 | if not opt.local_only: | 671 | if not opt.local_only: |
| 687 | mp.Sync_NetworkHalf(quiet=opt.quiet, | 672 | mp.Sync_NetworkHalf(quiet=opt.quiet, |
| 688 | current_branch_only=opt.current_branch_only, | 673 | current_branch_only=opt.current_branch_only, |
| @@ -697,6 +682,35 @@ later is required to fix a server side protocol bug. | |||
| 697 | self._ReloadManifest(manifest_name) | 682 | self._ReloadManifest(manifest_name) |
| 698 | if opt.jobs is None: | 683 | if opt.jobs is None: |
| 699 | self.jobs = self.manifest.default.sync_j | 684 | self.jobs = self.manifest.default.sync_j |
| 685 | |||
| 686 | # TODO (sbasi) - Add support for manifest changes, aka projects | ||
| 687 | # have been added or deleted from the manifest. | ||
| 688 | if self.gitc_manifest: | ||
| 689 | gitc_manifest_projects = self.GetProjects(args, | ||
| 690 | manifest=self.gitc_manifest, | ||
| 691 | missing_ok=True) | ||
| 692 | gitc_projects = [] | ||
| 693 | opened_projects = [] | ||
| 694 | for project in gitc_manifest_projects: | ||
| 695 | if not project.old_revision: | ||
| 696 | gitc_projects.append(project) | ||
| 697 | else: | ||
| 698 | opened_projects.append(project) | ||
| 699 | |||
| 700 | if gitc_projects and not opt.local_only: | ||
| 701 | print('Updating GITC client: %s' % self.gitc_manifest.gitc_client_name) | ||
| 702 | gitc_utils.generate_gitc_manifest(self.gitc_manifest.gitc_client_dir, | ||
| 703 | self.gitc_manifest, | ||
| 704 | gitc_projects) | ||
| 705 | print('GITC client successfully synced.') | ||
| 706 | |||
| 707 | # The opened projects need to be synced as normal, therefore we | ||
| 708 | # generate a new args list to represent the opened projects. | ||
| 709 | args = [] | ||
| 710 | for proj in opened_projects: | ||
| 711 | args.append(os.path.relpath(proj.worktree, cwd)) | ||
| 712 | if not args: | ||
| 713 | return | ||
| 700 | all_projects = self.GetProjects(args, | 714 | all_projects = self.GetProjects(args, |
| 701 | missing_ok=True, | 715 | missing_ok=True, |
| 702 | submodules_ok=opt.fetch_submodules) | 716 | submodules_ok=opt.fetch_submodules) |
