summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--project.py9
-rw-r--r--subcmds/checkout.py24
2 files changed, 23 insertions, 10 deletions
diff --git a/project.py b/project.py
index 7ba1b38a..6252bd68 100644
--- a/project.py
+++ b/project.py
@@ -1167,6 +1167,13 @@ class Project(object):
1167 1167
1168 def CheckoutBranch(self, name): 1168 def CheckoutBranch(self, name):
1169 """Checkout a local topic branch. 1169 """Checkout a local topic branch.
1170
1171 Args:
1172 name: The name of the branch to checkout.
1173
1174 Returns:
1175 True if the checkout succeeded; False if it didn't; None if the branch
1176 didn't exist.
1170 """ 1177 """
1171 rev = R_HEADS + name 1178 rev = R_HEADS + name
1172 head = self.work_git.GetHead() 1179 head = self.work_git.GetHead()
@@ -1181,7 +1188,7 @@ class Project(object):
1181 except KeyError: 1188 except KeyError:
1182 # Branch does not exist in this project 1189 # Branch does not exist in this project
1183 # 1190 #
1184 return False 1191 return None
1185 1192
1186 if head.startswith(R_HEADS): 1193 if head.startswith(R_HEADS):
1187 try: 1194 try:
diff --git a/subcmds/checkout.py b/subcmds/checkout.py
index 4198acd1..533d20e1 100644
--- a/subcmds/checkout.py
+++ b/subcmds/checkout.py
@@ -38,21 +38,27 @@ The command is equivalent to:
38 38
39 nb = args[0] 39 nb = args[0]
40 err = [] 40 err = []
41 success = []
41 all = self.GetProjects(args[1:]) 42 all = self.GetProjects(args[1:])
42 43
43 pm = Progress('Checkout %s' % nb, len(all)) 44 pm = Progress('Checkout %s' % nb, len(all))
44 for project in all: 45 for project in all:
45 pm.update() 46 pm.update()
46 if not project.CheckoutBranch(nb): 47
47 err.append(project) 48 status = project.CheckoutBranch(nb)
49 if status is not None:
50 if status:
51 success.append(project)
52 else:
53 err.append(project)
48 pm.end() 54 pm.end()
49 55
50 if err: 56 if err:
51 if len(err) == len(all): 57 for p in err:
52 print >>sys.stderr, 'error: no project has branch %s' % nb 58 print >>sys.stderr,\
53 else: 59 "error: %s/: cannot checkout %s" \
54 for p in err: 60 % (p.relpath, nb)
55 print >>sys.stderr,\ 61 sys.exit(1)
56 "error: %s/: cannot checkout %s" \ 62 elif not success:
57 % (p.relpath, nb) 63 print >>sys.stderr, 'error: no project has branch %s' % nb
58 sys.exit(1) 64 sys.exit(1)