Indiciate the tree status in the rietveld message when bypassing hooks

BUG=none
R=iannucci@chromium.org,maruel@chromium.org

Review URL: https://codereview.chromium.org/130803004

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@244793 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/git_cl.py b/git_cl.py
index 2bf1b98..4acbed5 100755
--- a/git_cl.py
+++ b/git_cl.py
@@ -1750,8 +1750,8 @@
   else:
     breakpad.SendStack(
         'GitClHooksBypassedCommit',
-        'Issue %s/%s bypassed hook when committing' %
-        (cl.GetRietveldServer(), cl.GetIssue()),
+        'Issue %s/%s bypassed hook when committing (tree status was "%s")' %
+        (cl.GetRietveldServer(), cl.GetIssue(), GetTreeStatus()),
         verbose=False)
 
   change_desc = ChangeDescription(options.message)
@@ -1871,7 +1871,10 @@
     props = cl.GetIssueProperties()
     patch_num = len(props['patchsets'])
     comment = "Committed patchset #%d manually as r%s" % (patch_num, revision)
-    comment += ' (presubmit successful).' if not options.bypass_hooks else '.'
+    if options.bypass_hooks:
+      comment += ' (tree was closed).' if GetTreeStatus() == 'closed' else '.'
+    else:
+      comment += ' (presubmit successful).'
     cl.RpcServer().add_comment(cl.GetIssue(), comment)
     cl.SetIssue(None)
 
@@ -2023,10 +2026,10 @@
   return subprocess2.call(['git', 'svn', 'rebase'] + args, env=env)
 
 
-def GetTreeStatus():
+def GetTreeStatus(url=None):
   """Fetches the tree status and returns either 'open', 'closed',
   'unknown' or 'unset'."""
-  url = settings.GetTreeStatusUrl(error_ok=True)
+  url = url or settings.GetTreeStatusUrl(error_ok=True)
   if url:
     status = urllib2.urlopen(url).read().lower()
     if status.find('closed') != -1 or status == '0':