Fixed repo checkout error message when git reports errors.

In the current version of repo checkout, we often get the error:
  error: no project has branch xyzzy

...even when the actual error was something else.  This fixes it
to only report the 'no project has branch' when that is actually true.

This fix is very similar to one made for 'repo abandon':
  https://review.source.android.com/#change,22207

The repo checkout error is filed as: <http://crosbug.com/6514>

TEST=manual

A sample creating a case where 'git checkout' will fail:

  $ repo start branch1 .
  $ repo start branch2 .
  $ touch bogusfile
  $ git add bogusfile
  $ git commit -m "create bogus file"
  [branch2 f8b6b08] create bogus file
   0 files changed, 0 insertions(+), 0 deletions(-)
   create mode 100644 bogusfile
  $ echo "More" >> bogusfile
  $ repo checkout branch1 .
  error: chromite/: cannot checkout branch1

A sample case showing that we still fail if no project has a branch:

  $ repo checkout xyzzy .
  error: no project has branch xyzzy

Change-Id: I48a8e258fa7a9c1f2800dafc683787204bbfcc63
diff --git a/project.py b/project.py
index 7ba1b38..6252bd6 100644
--- a/project.py
+++ b/project.py
@@ -1167,6 +1167,13 @@
 
   def CheckoutBranch(self, name):
     """Checkout a local topic branch.
+
+        Args:
+          name: The name of the branch to checkout.
+
+        Returns:
+          True if the checkout succeeded; False if it didn't; None if the branch
+          didn't exist.
     """
     rev = R_HEADS + name
     head = self.work_git.GetHead()
@@ -1181,7 +1188,7 @@
     except KeyError:
       # Branch does not exist in this project
       #
-      return False
+      return None
 
     if head.startswith(R_HEADS):
       try:
diff --git a/subcmds/checkout.py b/subcmds/checkout.py
index 4198acd..533d20e 100644
--- a/subcmds/checkout.py
+++ b/subcmds/checkout.py
@@ -38,21 +38,27 @@
 
     nb = args[0]
     err = []
+    success = []
     all = self.GetProjects(args[1:])
 
     pm = Progress('Checkout %s' % nb, len(all))
     for project in all:
       pm.update()
-      if not project.CheckoutBranch(nb):
-        err.append(project)
+
+      status = project.CheckoutBranch(nb)
+      if status is not None:
+        if status:
+          success.append(project)
+        else:
+          err.append(project)
     pm.end()
 
     if err:
-      if len(err) == len(all):
-        print >>sys.stderr, 'error: no project has branch %s' % nb
-      else:
-        for p in err:
-          print >>sys.stderr,\
-            "error: %s/: cannot checkout %s" \
-            % (p.relpath, nb)
+      for p in err:
+        print >>sys.stderr,\
+          "error: %s/: cannot checkout %s" \
+          % (p.relpath, nb)
+      sys.exit(1)
+    elif not success:
+      print >>sys.stderr, 'error: no project has branch %s' % nb
       sys.exit(1)