summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSean McAllister <smcallis@google.com>2020-04-20 08:41:58 -0600
committerSean McAllister <smcallis@google.com>2020-04-20 16:35:02 +0000
commitaf908cb5438ec3c03a9a32d1a9f286aa5657ff88 (patch)
tree6d02df8ce08d244716807f842b4058c965bda5fd
parent74e8ed4bde37a3ce42579e4601e0a54120853c89 (diff)
downloadgit-repo-af908cb5438ec3c03a9a32d1a9f286aa5657ff88.tar.gz
When writing manifest, set the dest-branch attribute for projects
When generating a revision locked manifest, we need to know what ref to push changes to when doing 'repo upload'. This information is lost when we lock the revision attribute to a particular commit hash, so we need to expose it through the dest-branch attribute. Bug: https://crbug.com/1005103 Test: manual execution Change-Id: Ib31fd77ad8c9379759c4181dac1ea97de43eec35 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/263572 Tested-by: Sean McAllister <smcallis@google.com> Reviewed-by: Mike Frysinger <vapier@google.com>
-rw-r--r--manifest_xml.py9
-rw-r--r--subcmds/manifest.py11
2 files changed, 17 insertions, 3 deletions
diff --git a/manifest_xml.py b/manifest_xml.py
index edcbadae..b2918cac 100644
--- a/manifest_xml.py
+++ b/manifest_xml.py
@@ -284,7 +284,7 @@ https://gerrit.googlesource.com/git-repo/+/HEAD/docs/manifest-format.md
284 def _ParseGroups(self, groups): 284 def _ParseGroups(self, groups):
285 return [x for x in re.split(r'[,\s]+', groups) if x] 285 return [x for x in re.split(r'[,\s]+', groups) if x]
286 286
287 def Save(self, fd, peg_rev=False, peg_rev_upstream=True, groups=None): 287 def Save(self, fd, peg_rev=False, peg_rev_upstream=True, peg_rev_dest_branch=True, groups=None):
288 """Write the current manifest out to the given file descriptor. 288 """Write the current manifest out to the given file descriptor.
289 """ 289 """
290 mp = self.manifestProject 290 mp = self.manifestProject
@@ -389,6 +389,13 @@ https://gerrit.googlesource.com/git-repo/+/HEAD/docs/manifest-format.md
389 # Only save the origin if the origin is not a sha1, and the default 389 # Only save the origin if the origin is not a sha1, and the default
390 # isn't our value 390 # isn't our value
391 e.setAttribute('upstream', p.revisionExpr) 391 e.setAttribute('upstream', p.revisionExpr)
392
393 if peg_rev_dest_branch:
394 if p.dest_branch:
395 e.setAttribute('dest-branch', p.dest_branch)
396 elif value != p.revisionExpr:
397 e.setAttribute('dest-branch', p.revisionExpr)
398
392 else: 399 else:
393 revision = self.remotes[p.remote.orig_name].revision or d.revisionExpr 400 revision = self.remotes[p.remote.orig_name].revision or d.revisionExpr
394 if not revision or revision != p.revisionExpr: 401 if not revision or revision != p.revisionExpr:
diff --git a/subcmds/manifest.py b/subcmds/manifest.py
index 399e241e..fb020d8c 100644
--- a/subcmds/manifest.py
+++ b/subcmds/manifest.py
@@ -38,7 +38,8 @@ The -r option can be used to generate a manifest file with project
38revisions set to the current commit hash. These are known as 38revisions set to the current commit hash. These are known as
39"revision locked manifests", as they don't follow a particular branch. 39"revision locked manifests", as they don't follow a particular branch.
40In this case, the 'upstream' attribute is set to the ref we were on 40In this case, the 'upstream' attribute is set to the ref we were on
41when the manifest was generated. 41when the manifest was generated. The 'dest-branch' attribute is set
42to indicate the remote ref to push changes to via 'repo upload'.
42""" 43"""
43 44
44 @property 45 @property
@@ -62,6 +63,11 @@ when the manifest was generated.
62 help='If in -r mode, do not write the upstream field. ' 63 help='If in -r mode, do not write the upstream field. '
63 'Only of use if the branch names for a sha1 manifest are ' 64 'Only of use if the branch names for a sha1 manifest are '
64 'sensitive.') 65 'sensitive.')
66 p.add_option('--suppress-dest-branch', dest='peg_rev_dest_branch',
67 default=True, action='store_false',
68 help='If in -r mode, do not write the dest-branch field. '
69 'Only of use if the branch names for a sha1 manifest are '
70 'sensitive.')
65 p.add_option('-o', '--output-file', 71 p.add_option('-o', '--output-file',
66 dest='output_file', 72 dest='output_file',
67 default='-', 73 default='-',
@@ -79,7 +85,8 @@ when the manifest was generated.
79 fd = open(opt.output_file, 'w') 85 fd = open(opt.output_file, 'w')
80 self.manifest.Save(fd, 86 self.manifest.Save(fd,
81 peg_rev=opt.peg_rev, 87 peg_rev=opt.peg_rev,
82 peg_rev_upstream=opt.peg_rev_upstream) 88 peg_rev_upstream=opt.peg_rev_upstream,
89 peg_rev_dest_branch=opt.peg_rev_dest_branch)
83 fd.close() 90 fd.close()
84 if opt.output_file != '-': 91 if opt.output_file != '-':
85 print('Saved manifest to %s' % opt.output_file, file=sys.stderr) 92 print('Saved manifest to %s' % opt.output_file, file=sys.stderr)