Fix another bug in the gn_roll script.

We were not checking out the branch used to build gn before
checking on the tryjob statuses for that branch.

R=brettw@chromium.org
BUG=

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

Cr-Original-Commit-Position: refs/heads/master@{#352145}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: 3862a3e5baf3e0e5c867d82df6615414ae914855
diff --git a/tools/gn/bin/roll_gn.py b/tools/gn/bin/roll_gn.py
index b5c276e..66c711a 100644
--- a/tools/gn/bin/roll_gn.py
+++ b/tools/gn/bin/roll_gn.py
@@ -179,6 +179,10 @@
       fp.write(new_deps)
 
   def WaitForBuildToFinish(self):
+    ret = self.CheckoutBuildBranch()
+    if ret:
+      return ret
+
     print('Checking build')
     results = self.CheckBuild()
     while (len(results) < 3 or
@@ -203,6 +207,16 @@
 
     return ret
 
+  def CheckoutBuildBranch(self):
+    ret, out, err = self.Call('git checkout build_gn_%s' % self.new_gn_version)
+    if ret:
+      print('Failed to check out build_gn_%s' % self.new_gn_version)
+      if out:
+        print(out)
+      if err:
+        print(err, file=sys.stderr)
+    return ret
+
   def CheckBuild(self):
     _, out, _ = self.Call('git-cl issue')
 
@@ -276,6 +290,10 @@
     return results
 
   def RollBuildtools(self):
+    ret = self.CheckoutBuildBranch()
+    if ret:
+      return ret
+
     results = self.CheckBuild()
     if (len(results) < 3 or
         not all(r['state'] == 'success' for r in results.values())):