diff options
author | Shawn O. Pearce <sop@google.com> | 2010-07-15 16:52:42 -0700 |
---|---|---|
committer | Shawn O. Pearce <sop@google.com> | 2010-07-15 16:52:42 -0700 |
commit | a5ece0e0505324218f38af02a1fe046ca2bcc278 (patch) | |
tree | 429cbf0b23d2606737629e7fc77a4ad0b228c90a /project.py | |
parent | cc50bac8c7706082596d70756249d4964a67f281 (diff) | |
download | git-repo-a5ece0e0505324218f38af02a1fe046ca2bcc278.tar.gz |
upload -t: Automatically include local branch name
If the -t flag is given to upload, the local branch name is
automatically sent to Gerrit Code Review as the topic branch name
for the change(s). This requires the server to be Gerrit Code
Review v2.1.3-53-gd50c94e or later, which isn't widely deployed
right now, so the default is opt-out.
Change-Id: I034fcacb405b7cb909147152db427fe69dd7bcbf
Signed-off-by: Shawn O. Pearce <sop@google.com>
Diffstat (limited to 'project.py')
-rw-r--r-- | project.py | 17 |
1 files changed, 13 insertions, 4 deletions
@@ -149,10 +149,11 @@ class ReviewableBranch(object): | |||
149 | R_HEADS + self.name, | 149 | R_HEADS + self.name, |
150 | '--') | 150 | '--') |
151 | 151 | ||
152 | def UploadForReview(self, people): | 152 | def UploadForReview(self, people, auto_topic=False): |
153 | self.project.UploadForReview(self.name, | 153 | self.project.UploadForReview(self.name, |
154 | self.replace_changes, | 154 | self.replace_changes, |
155 | people) | 155 | people, |
156 | auto_topic=auto_topic) | ||
156 | 157 | ||
157 | def GetPublishedRefs(self): | 158 | def GetPublishedRefs(self): |
158 | refs = {} | 159 | refs = {} |
@@ -555,7 +556,10 @@ class Project(object): | |||
555 | return rb | 556 | return rb |
556 | return None | 557 | return None |
557 | 558 | ||
558 | def UploadForReview(self, branch=None, replace_changes=None, people=([],[])): | 559 | def UploadForReview(self, branch=None, |
560 | replace_changes=None, | ||
561 | people=([],[]), | ||
562 | auto_topic=False): | ||
559 | """Uploads the named branch for code review. | 563 | """Uploads the named branch for code review. |
560 | """ | 564 | """ |
561 | if branch is None: | 565 | if branch is None: |
@@ -587,10 +591,15 @@ class Project(object): | |||
587 | for e in people[1]: | 591 | for e in people[1]: |
588 | rp.append('--cc=%s' % sq(e)) | 592 | rp.append('--cc=%s' % sq(e)) |
589 | 593 | ||
594 | ref_spec = '%s:refs/for/%s' % (R_HEADS + branch.name, dest_branch) | ||
595 | if auto_topic: | ||
596 | ref_spec = ref_spec + '/' + branch.name | ||
597 | |||
590 | cmd = ['push'] | 598 | cmd = ['push'] |
591 | cmd.append('--receive-pack=%s' % " ".join(rp)) | 599 | cmd.append('--receive-pack=%s' % " ".join(rp)) |
592 | cmd.append(branch.remote.SshReviewUrl(self.UserEmail)) | 600 | cmd.append(branch.remote.SshReviewUrl(self.UserEmail)) |
593 | cmd.append('%s:refs/for/%s' % (R_HEADS + branch.name, dest_branch)) | 601 | cmd.append(ref_spec) |
602 | |||
594 | if replace_changes: | 603 | if replace_changes: |
595 | for change_id,commit_id in replace_changes.iteritems(): | 604 | for change_id,commit_id in replace_changes.iteritems(): |
596 | cmd.append('%s:refs/changes/%s/new' % (commit_id, change_id)) | 605 | cmd.append('%s:refs/changes/%s/new' % (commit_id, change_id)) |