Index: gerrit_util.py |
diff --git a/gerrit_util.py b/gerrit_util.py |
index 77fcb07c4ceaa143193759c52073cf8a8152f00a..011606f652fd7e6dc961057d6d4b89aa1dad6aa8 100755 |
--- a/gerrit_util.py |
+++ b/gerrit_util.py |
@@ -545,6 +545,30 @@ def SubmitChange(host, change, wait_for_merge=True): |
return ReadHttpJsonResponse(conn, ignore_404=False) |
+def HasPendingChangeEdit(host, change): |
+ conn = CreateHttpConn(host, 'changes/%s/edit' % change) |
+ try: |
+ ReadHttpResponse(conn, ignore_404=False) |
+ except GerritError as e: |
+ # On success, gerrit returns status 204; anything else is an error. |
+ if e.http_status != 204: |
+ raise |
+ return False |
+ else: |
+ return True |
+ |
+ |
+def DeletePendingChangeEdit(host, change): |
+ conn = CreateHttpConn(host, 'changes/%s/edit' % change, reqtype='DELETE') |
+ try: |
+ ReadHttpResponse(conn, ignore_404=False) |
+ except GerritError as e: |
+ # On success, gerrit returns status 204; if the edit was already deleted it |
+ # returns 404. Anything else is an error. |
+ if e.http_status not in (204, 404): |
+ raise |
+ |
+ |
def SetCommitMessage(host, change, description): |
"""Updates a commit message.""" |
# First, edit the commit message in a draft. |