diff options
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 |