Chromium Code Reviews| Index: git_cl.py |
| diff --git a/git_cl.py b/git_cl.py |
| index 07c528c36f55f38af2af6d12f03a1f81dcbe0238..6dade13d8b35185ad1fdf22fad8a14aa12061dd9 100755 |
| --- a/git_cl.py |
| +++ b/git_cl.py |
| @@ -1393,9 +1393,9 @@ class Changelist(object): |
| author, |
| upstream=upstream_branch) |
| - def UpdateDescription(self, description): |
| + def UpdateDescription(self, force, description): |
|
tandrii(chromium)
2016/09/07 13:33:39
light suggestion: i'd add force=False as second ar
dsansome
2016/09/08 07:07:17
Done.
|
| self.description = description |
| - return self._codereview_impl.UpdateDescriptionRemote(description) |
| + return self._codereview_impl.UpdateDescriptionRemote(force, description) |
| def RunHook(self, committing, may_prompt, verbose, change): |
| """Calls sys.exit() if the hook fails; returns a HookResults otherwise.""" |
| @@ -1603,7 +1603,7 @@ class _ChangelistCodereviewBase(object): |
| # None is valid return value, otherwise presubmit_support.GerritAccessor. |
| return None |
| - def UpdateDescriptionRemote(self, description): |
| + def UpdateDescriptionRemote(self, force, description): |
| """Update the description on codereview site.""" |
| raise NotImplementedError() |
| @@ -1798,7 +1798,7 @@ class _RietveldChangelistImpl(_ChangelistCodereviewBase): |
| return 'reply' |
| return 'waiting' |
| - def UpdateDescriptionRemote(self, description): |
| + def UpdateDescriptionRemote(self, force, description): |
| return self.RpcServer().update_description( |
| self.GetIssue(), self.description) |
| @@ -2294,7 +2294,17 @@ class _GerritChangelistImpl(_ChangelistCodereviewBase): |
| url = data['revisions'][current_rev]['fetch']['http']['url'] |
| return gerrit_util.GetChangeDescriptionFromGitiles(url, current_rev) |
| - def UpdateDescriptionRemote(self, description): |
| + def UpdateDescriptionRemote(self, force, description): |
| + if gerrit_util.HasPendingChangeEdit(self._GetGerritHost(), self.GetIssue()): |
| + if not force: |
| + ask_for_data( |
| + 'The description cannot be modified while the issue has a pending ' |
| + 'unpublished\nedit. Either publish the edit in the Gerrit web UI ' |
|
tandrii(chromium)
2016/09/07 13:33:39
nit: i prefer not avoid manual text wrapping (ie n
dsansome
2016/09/08 07:07:17
Done.
|
| + 'or delete it.\n\n' |
| + 'Press Enter to delete the unpublished edit, Ctrl+C to abort.') |
| + |
| + gerrit_util.DeletePendingChangeEdit(self._GetGerritHost(), |
| + self.GetIssue()) |
| gerrit_util.SetCommitMessage(self._GetGerritHost(), self.GetIssue(), |
| description) |
| @@ -3607,6 +3617,9 @@ def CMDdescription(parser, args): |
| parser.add_option('-n', '--new-description', |
| help='New description to set for this issue (- for stdin, ' |
| '+ to load from local commit HEAD)') |
| + parser.add_option('-f', '--force', action='store_true', |
| + help='Delete any unpublished Gerrit edits for this issue ' |
| + 'without prompting') |
| _add_codereview_select_options(parser) |
| auth.add_auth_options(parser) |
| @@ -3655,7 +3668,7 @@ def CMDdescription(parser, args): |
| description.prompt() |
| if cl.GetDescription() != description.description: |
| - cl.UpdateDescription(description.description) |
| + cl.UpdateDescription(options.force, description.description) |
| return 0 |
| @@ -4238,7 +4251,7 @@ def SendUpstream(parser, args, cmd): |
| change_desc.append_footer('Committed: %s' % (revision,)) |
| print('Closing issue ' |
| '(you may be prompted for your codereview password)...') |
| - cl.UpdateDescription(change_desc.description) |
| + cl.UpdateDescription(False, change_desc.description) |
| cl.CloseIssue() |
| props = cl.GetIssueProperties() |
| patch_num = len(props['patchsets']) |