Prompt to delete pending edits before changing the Gerrit CL description.

BUG=641838

Review-Url: https://codereview.chromium.org/2318903002
diff --git a/gerrit_util.py b/gerrit_util.py
index 77fcb07..011606f 100755
--- a/gerrit_util.py
+++ b/gerrit_util.py
@@ -545,6 +545,30 @@
   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.