Improve GetPushBranch logic to work with LKGM checkouts.

GetPushBranch logic currently depends on $REPO_RREV, which, for only works
for checkouts that are not revision-locked. I've updated that logic to
work with revision-locked checkouts.

This is a followup to Ib6eb14cc to address my TODO items listed in that
commit.

BUG=none
TEST=Run x86-generic-full prebuilt stage with --lkgm.

Change-Id: I1e728b42d53802bfa40206dc6a24c264760a41ac
Reviewed-on: https://gerrit.chromium.org/gerrit/19232
Commit-Ready: David James <davidjames@chromium.org>
Reviewed-by: David James <davidjames@chromium.org>
Tested-by: David James <davidjames@chromium.org>
diff --git a/scripts/cbuildbot.py b/scripts/cbuildbot.py
index 77fef0f..81e9d89 100644
--- a/scripts/cbuildbot.py
+++ b/scripts/cbuildbot.py
@@ -92,10 +92,11 @@
     if tracking_branch.startswith('refs/heads/'):
       return tracking_branch.replace('refs/heads/', '')
   # If we are not on a branch, or if the tracking branch is a revision,
-  # use the default manifest branch. This only works if we are in a
-  # repo repository. TODO(davidjames): Fix this to work if we're not in a repo
-  # repository.
-  return cros_lib.GetManifestDefaultBranch(cwd)
+  # use the push branch. For repo repositories, this will be the manifest
+  # branch configured for this project. For other repositories, we'll just
+  # guess 'master', since there's no easy way to find out what branch
+  # we're on.
+  return cros_lib.GetPushBranch(cwd)[1]
 
 
 def _CheckBuildRootBranch(buildroot, tracking_branch):