diff --git a/project.py b/project.py index 7ba1b38..6252bd6 100644 --- a/project.py +++ b/project.py @@ -1167,6 +1167,13 @@ class Project(object): 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 @@ class Project(object): 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 @@ The command is equivalent to: 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)