GetGerritBranch should return None if the branch does not exist

Currently gerrit_client retries if received 404, which does not
provide anything meaningful.
It is nature to get 404 for a non-exist branch. I am not sure why
we raise a 200 error per an empty response. I think
we could just accept 404 and return it like other GET functions, e.g.
GetAccountDetails().

BUG=1208430
TEST=local

Change-Id: I054bad99b69c54cc125141108299193f5cc092de
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3077363
Reviewed-by: Michael Moss <mmoss@chromium.org>
Reviewed-by: Anthony Polito <apolito@google.com>
Commit-Queue: Xinan Lin <linxinan@chromium.org>
diff --git a/gerrit_util.py b/gerrit_util.py
index 9a8a2db..c3a058b 100644
--- a/gerrit_util.py
+++ b/gerrit_util.py
@@ -1042,20 +1042,17 @@
 
 
 def GetGerritBranch(host, project, branch):
-  """Gets a branch from given project and commit.
+  """Gets a branch info from given project and branch name.
 
   See:
   https://gerrit-review.googlesource.com/Documentation/rest-api-projects.html#get-branch
 
   Returns:
-    A JSON object with 'revision' key.
+    A JSON object with 'revision' key if the branch exists, otherwise None.
   """
   path = 'projects/%s/branches/%s' % (project, branch)
   conn = CreateHttpConn(host, path, reqtype='GET')
-  response = ReadHttpJsonResponse(conn)
-  if response:
-    return response
-  raise GerritError(200, 'Unable to get gerrit branch')
+  return ReadHttpJsonResponse(conn, accept_statuses=[200, 404])
 
 
 def GetProjectHead(host, project):