diff options
author | LaMont Jones <lamontjones@google.com> | 2021-11-18 22:40:18 +0000 |
---|---|---|
committer | LaMont Jones <lamontjones@google.com> | 2022-02-17 21:57:55 +0000 |
commit | cc879a97c3e2614d19b15b4661c3cab4d33139c9 (patch) | |
tree | 69d225e9f0e9d79fec8f423d9c40c275f0bf3b8c /subcmds/manifest.py | |
parent | 87cce68b28c34fa86895baa8d7f48307382e6c75 (diff) | |
download | git-repo-cc879a97c3e2614d19b15b4661c3cab4d33139c9.tar.gz |
Add multi-manifest support with <submanifest> elementv2.22
To be addressed in another change:
- a partial `repo sync` (with a list of projects/paths to sync)
requires `--this-tree-only`.
Change-Id: I6c7400bf001540e9d7694fa70934f8f204cb5f57
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/322657
Tested-by: LaMont Jones <lamontjones@google.com>
Reviewed-by: Mike Frysinger <vapier@google.com>
Diffstat (limited to 'subcmds/manifest.py')
-rw-r--r-- | subcmds/manifest.py | 72 |
1 files changed, 41 insertions, 31 deletions
diff --git a/subcmds/manifest.py b/subcmds/manifest.py index 0fbdeac0..08905cb4 100644 --- a/subcmds/manifest.py +++ b/subcmds/manifest.py | |||
@@ -15,6 +15,7 @@ | |||
15 | import json | 15 | import json |
16 | import os | 16 | import os |
17 | import sys | 17 | import sys |
18 | import optparse | ||
18 | 19 | ||
19 | from command import PagedCommand | 20 | from command import PagedCommand |
20 | 21 | ||
@@ -75,7 +76,7 @@ to indicate the remote ref to push changes to via 'repo upload'. | |||
75 | p.add_option('-o', '--output-file', | 76 | p.add_option('-o', '--output-file', |
76 | dest='output_file', | 77 | dest='output_file', |
77 | default='-', | 78 | default='-', |
78 | help='file to save the manifest to', | 79 | help='file to save the manifest to. (Filename prefix for multi-tree.)', |
79 | metavar='-|NAME.xml') | 80 | metavar='-|NAME.xml') |
80 | 81 | ||
81 | def _Output(self, opt): | 82 | def _Output(self, opt): |
@@ -83,36 +84,45 @@ to indicate the remote ref to push changes to via 'repo upload'. | |||
83 | if opt.manifest_name: | 84 | if opt.manifest_name: |
84 | self.manifest.Override(opt.manifest_name, False) | 85 | self.manifest.Override(opt.manifest_name, False) |
85 | 86 | ||
86 | if opt.output_file == '-': | 87 | for manifest in self.ManifestList(opt): |
87 | fd = sys.stdout | 88 | output_file = opt.output_file |
88 | else: | 89 | if output_file == '-': |
89 | fd = open(opt.output_file, 'w') | 90 | fd = sys.stdout |
90 | 91 | else: | |
91 | self.manifest.SetUseLocalManifests(not opt.ignore_local_manifests) | 92 | if manifest.path_prefix: |
92 | 93 | output_file = f'{opt.output_file}:{manifest.path_prefix.replace("/", "%2f")}' | |
93 | if opt.json: | 94 | fd = open(output_file, 'w') |
94 | print('warning: --json is experimental!', file=sys.stderr) | 95 | |
95 | doc = self.manifest.ToDict(peg_rev=opt.peg_rev, | 96 | manifest.SetUseLocalManifests(not opt.ignore_local_manifests) |
96 | peg_rev_upstream=opt.peg_rev_upstream, | 97 | |
97 | peg_rev_dest_branch=opt.peg_rev_dest_branch) | 98 | if opt.json: |
98 | 99 | print('warning: --json is experimental!', file=sys.stderr) | |
99 | json_settings = { | 100 | doc = manifest.ToDict(peg_rev=opt.peg_rev, |
100 | # JSON style guide says Uunicode characters are fully allowed. | 101 | peg_rev_upstream=opt.peg_rev_upstream, |
101 | 'ensure_ascii': False, | 102 | peg_rev_dest_branch=opt.peg_rev_dest_branch) |
102 | # We use 2 space indent to match JSON style guide. | 103 | |
103 | 'indent': 2 if opt.pretty else None, | 104 | json_settings = { |
104 | 'separators': (',', ': ') if opt.pretty else (',', ':'), | 105 | # JSON style guide says Uunicode characters are fully allowed. |
105 | 'sort_keys': True, | 106 | 'ensure_ascii': False, |
106 | } | 107 | # We use 2 space indent to match JSON style guide. |
107 | fd.write(json.dumps(doc, **json_settings)) | 108 | 'indent': 2 if opt.pretty else None, |
108 | else: | 109 | 'separators': (',', ': ') if opt.pretty else (',', ':'), |
109 | self.manifest.Save(fd, | 110 | 'sort_keys': True, |
110 | peg_rev=opt.peg_rev, | 111 | } |
111 | peg_rev_upstream=opt.peg_rev_upstream, | 112 | fd.write(json.dumps(doc, **json_settings)) |
112 | peg_rev_dest_branch=opt.peg_rev_dest_branch) | 113 | else: |
113 | fd.close() | 114 | manifest.Save(fd, |
114 | if opt.output_file != '-': | 115 | peg_rev=opt.peg_rev, |
115 | print('Saved manifest to %s' % opt.output_file, file=sys.stderr) | 116 | peg_rev_upstream=opt.peg_rev_upstream, |
117 | peg_rev_dest_branch=opt.peg_rev_dest_branch) | ||
118 | if output_file != '-': | ||
119 | fd.close() | ||
120 | if manifest.path_prefix: | ||
121 | print(f'Saved {manifest.path_prefix} submanifest to {output_file}', | ||
122 | file=sys.stderr) | ||
123 | else: | ||
124 | print(f'Saved manifest to {output_file}', file=sys.stderr) | ||
125 | |||
116 | 126 | ||
117 | def ValidateOptions(self, opt, args): | 127 | def ValidateOptions(self, opt, args): |
118 | if args: | 128 | if args: |