diff options
| author | Brian Harring <ferringb@chromium.org> | 2012-07-28 15:37:04 -0700 |
|---|---|---|
| committer | Brian Harring <ferringb@google.com> | 2012-07-28 15:44:05 -0700 |
| commit | 435370c6f0e202378ae233cf1088e499ba07e971 (patch) | |
| tree | 17ef58db736d091ad62b54db0c7169b964ccb95e | |
| parent | e8f75fa3687bfe894a4fa8e59881b7d9170d8a41 (diff) | |
| download | git-repo-435370c6f0e202378ae233cf1088e499ba07e971.tar.gz | |
upload: add --draft option.
Change-Id: I6967ff2f8163cd4116027b3f15ddb36875942af4
| -rw-r--r-- | project.py | 16 | ||||
| -rw-r--r-- | subcmds/upload.py | 5 |
2 files changed, 16 insertions, 5 deletions
| @@ -176,10 +176,11 @@ class ReviewableBranch(object): | |||
| 176 | R_HEADS + self.name, | 176 | R_HEADS + self.name, |
| 177 | '--') | 177 | '--') |
| 178 | 178 | ||
| 179 | def UploadForReview(self, people, auto_topic=False): | 179 | def UploadForReview(self, people, auto_topic=False, draft=False): |
| 180 | self.project.UploadForReview(self.name, | 180 | self.project.UploadForReview(self.name, |
| 181 | people, | 181 | people, |
| 182 | auto_topic=auto_topic) | 182 | auto_topic=auto_topic, |
| 183 | draft=draft) | ||
| 183 | 184 | ||
| 184 | def GetPublishedRefs(self): | 185 | def GetPublishedRefs(self): |
| 185 | refs = {} | 186 | refs = {} |
| @@ -881,7 +882,8 @@ class Project(object): | |||
| 881 | 882 | ||
| 882 | def UploadForReview(self, branch=None, | 883 | def UploadForReview(self, branch=None, |
| 883 | people=([],[]), | 884 | people=([],[]), |
| 884 | auto_topic=False): | 885 | auto_topic=False, |
| 886 | draft=False): | ||
| 885 | """Uploads the named branch for code review. | 887 | """Uploads the named branch for code review. |
| 886 | """ | 888 | """ |
| 887 | if branch is None: | 889 | if branch is None: |
| @@ -920,7 +922,13 @@ class Project(object): | |||
| 920 | 922 | ||
| 921 | if dest_branch.startswith(R_HEADS): | 923 | if dest_branch.startswith(R_HEADS): |
| 922 | dest_branch = dest_branch[len(R_HEADS):] | 924 | dest_branch = dest_branch[len(R_HEADS):] |
| 923 | ref_spec = '%s:refs/for/%s' % (R_HEADS + branch.name, dest_branch) | 925 | |
| 926 | upload_type = 'for' | ||
| 927 | if draft: | ||
| 928 | upload_type = 'drafts' | ||
| 929 | |||
| 930 | ref_spec = '%s:refs/%s/%s' % (R_HEADS + branch.name, upload_type, | ||
| 931 | dest_branch) | ||
| 924 | if auto_topic: | 932 | if auto_topic: |
| 925 | ref_spec = ref_spec + '/' + branch.name | 933 | ref_spec = ref_spec + '/' + branch.name |
| 926 | cmd.append(ref_spec) | 934 | cmd.append(ref_spec) |
diff --git a/subcmds/upload.py b/subcmds/upload.py index 69efa107..c9312973 100644 --- a/subcmds/upload.py +++ b/subcmds/upload.py | |||
| @@ -134,6 +134,9 @@ Gerrit Code Review: http://code.google.com/p/gerrit/ | |||
| 134 | p.add_option('--cbr', '--current-branch', | 134 | p.add_option('--cbr', '--current-branch', |
| 135 | dest='current_branch', action='store_true', | 135 | dest='current_branch', action='store_true', |
| 136 | help='Upload current git branch.') | 136 | help='Upload current git branch.') |
| 137 | p.add_option('-d', '--draft', | ||
| 138 | action='store_true', dest='draft', default=False, | ||
| 139 | help='If specified, upload as a draft.') | ||
| 137 | 140 | ||
| 138 | # Options relating to upload hook. Note that verify and no-verify are NOT | 141 | # Options relating to upload hook. Note that verify and no-verify are NOT |
| 139 | # opposites of each other, which is why they store to different locations. | 142 | # opposites of each other, which is why they store to different locations. |
| @@ -324,7 +327,7 @@ Gerrit Code Review: http://code.google.com/p/gerrit/ | |||
| 324 | key = 'review.%s.uploadtopic' % branch.project.remote.review | 327 | key = 'review.%s.uploadtopic' % branch.project.remote.review |
| 325 | opt.auto_topic = branch.project.config.GetBoolean(key) | 328 | opt.auto_topic = branch.project.config.GetBoolean(key) |
| 326 | 329 | ||
| 327 | branch.UploadForReview(people, auto_topic=opt.auto_topic) | 330 | branch.UploadForReview(people, auto_topic=opt.auto_topic, draft=opt.draft) |
| 328 | branch.uploaded = True | 331 | branch.uploaded = True |
| 329 | except UploadError, e: | 332 | except UploadError, e: |
| 330 | branch.error = e | 333 | branch.error = e |
