diff options
author | Raman Tenneti <rtenneti@google.com> | 2021-01-14 19:17:50 -0800 |
---|---|---|
committer | Raman Tenneti <rtenneti@google.com> | 2021-01-21 19:41:52 +0000 |
commit | 6a872c9daeec58dda61786e6f65591330709f6ad (patch) | |
tree | dcd22dcc29c91de8a097cf7075400bb463ef40e0 /subcmds/sync.py | |
parent | df6c506a8af47c19e853c96ba15e4446f93304b2 (diff) | |
download | git-repo-6a872c9daeec58dda61786e6f65591330709f6ad.tar.gz |
sync: Added --use-superproject option and support for superproject.v2.12
Added "--use-superporject" option to sync.py to fetch project SHAs from
superproject. If there are any missing projects in superprojects, it
prints the missing entries and exits. If there are no missing entries,
it will use SHAs from superproject to fetch the projects from git.
Tested the code with the following commands.
$ ./run_tests tests/test_manifest_xml.py
$ ./run_tests -v tests/test_git_superproject.py
$ ./run_tests -v
Tested the sync code by copying all the repo changes into my Android
AOSP checkout and adding <superporject> tag to default.xml. With
local modification to the code to print the status,
.../WORKING_DIRECTORY$ repo sync --use-superproject
repo: executing 'git clone' url: sso://android/platform/superproject
repo: executing 'git ls-tree'
Success: []
Bug: https://crbug.com/gerrit/13709
Tested-by: Raman Tenneti <rtenneti@google.com>
Change-Id: Id18665992428dd684c04b0e0b3a52f46316873a0
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/293822
Reviewed-by: Mike Frysinger <vapier@google.com>
Diffstat (limited to 'subcmds/sync.py')
-rw-r--r-- | subcmds/sync.py | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/subcmds/sync.py b/subcmds/sync.py index 3482946d..d6b8f9dc 100644 --- a/subcmds/sync.py +++ b/subcmds/sync.py | |||
@@ -51,11 +51,12 @@ import event_log | |||
51 | from git_command import GIT, git_require | 51 | from git_command import GIT, git_require |
52 | from git_config import GetUrlCookieFile | 52 | from git_config import GetUrlCookieFile |
53 | from git_refs import R_HEADS, HEAD | 53 | from git_refs import R_HEADS, HEAD |
54 | import git_superproject | ||
54 | import gitc_utils | 55 | import gitc_utils |
55 | from project import Project | 56 | from project import Project |
56 | from project import RemoteSpec | 57 | from project import RemoteSpec |
57 | from command import Command, MirrorSafeCommand | 58 | from command import Command, MirrorSafeCommand |
58 | from error import RepoChangedException, GitError, ManifestParseError | 59 | from error import BUG_REPORT_URL, RepoChangedException, GitError, ManifestParseError |
59 | import platform_utils | 60 | import platform_utils |
60 | from project import SyncBuffer | 61 | from project import SyncBuffer |
61 | from progress import Progress | 62 | from progress import Progress |
@@ -241,6 +242,8 @@ later is required to fix a server side protocol bug. | |||
241 | p.add_option('--fetch-submodules', | 242 | p.add_option('--fetch-submodules', |
242 | dest='fetch_submodules', action='store_true', | 243 | dest='fetch_submodules', action='store_true', |
243 | help='fetch submodules from server') | 244 | help='fetch submodules from server') |
245 | p.add_option('--use-superproject', action='store_true', | ||
246 | help='use the manifest superproject to sync projects') | ||
244 | p.add_option('--no-tags', | 247 | p.add_option('--no-tags', |
245 | dest='tags', default=True, action='store_false', | 248 | dest='tags', default=True, action='store_false', |
246 | help="don't fetch tags") | 249 | help="don't fetch tags") |
@@ -894,6 +897,41 @@ later is required to fix a server side protocol bug. | |||
894 | missing_ok=True, | 897 | missing_ok=True, |
895 | submodules_ok=opt.fetch_submodules) | 898 | submodules_ok=opt.fetch_submodules) |
896 | 899 | ||
900 | if opt.use_superproject: | ||
901 | if not self.manifest.superproject: | ||
902 | print('error: superproject tag is not defined in manifest.xml', | ||
903 | file=sys.stderr) | ||
904 | sys.exit(1) | ||
905 | print('WARNING: --use-superproject is experimental and not ' | ||
906 | 'for general use', file=sys.stderr) | ||
907 | superproject_url = self.manifest.superproject['remote'].url | ||
908 | if not superproject_url: | ||
909 | print('error: superproject URL is not defined in manifest.xml', | ||
910 | file=sys.stderr) | ||
911 | sys.exit(1) | ||
912 | superproject = git_superproject.Superproject(self.manifest.repodir) | ||
913 | try: | ||
914 | superproject_shas = superproject.GetAllProjectsSHAs(url=superproject_url) | ||
915 | except Exception as e: | ||
916 | print('error: Cannot get project SHAs for %s: %s: %s' % | ||
917 | (superproject_url, type(e).__name__, str(e)), | ||
918 | file=sys.stderr) | ||
919 | sys.exit(1) | ||
920 | projects_missing_shas = [] | ||
921 | for project in all_projects: | ||
922 | path = project.relpath | ||
923 | if not path: | ||
924 | continue | ||
925 | sha = superproject_shas.get(path) | ||
926 | if sha: | ||
927 | project.SetRevisionId(sha) | ||
928 | else: | ||
929 | projects_missing_shas.append(path) | ||
930 | if projects_missing_shas: | ||
931 | print('error: please file a bug using %s to report missing shas for: %s' % | ||
932 | (BUG_REPORT_URL, projects_missing_shas), file=sys.stderr) | ||
933 | sys.exit(1) | ||
934 | |||
897 | err_network_sync = False | 935 | err_network_sync = False |
898 | err_update_projects = False | 936 | err_update_projects = False |
899 | err_checkout = False | 937 | err_checkout = False |