summaryrefslogtreecommitdiffstats
path: root/subcmds/checkout.py
diff options
context:
space:
mode:
Diffstat (limited to 'subcmds/checkout.py')
-rw-r--r--subcmds/checkout.py39
1 files changed, 24 insertions, 15 deletions
diff --git a/subcmds/checkout.py b/subcmds/checkout.py
index c8a09a8e..9b429489 100644
--- a/subcmds/checkout.py
+++ b/subcmds/checkout.py
@@ -1,5 +1,3 @@
1# -*- coding:utf-8 -*-
2#
3# Copyright (C) 2009 The Android Open Source Project 1# Copyright (C) 2009 The Android Open Source Project
4# 2#
5# Licensed under the Apache License, Version 2.0 (the "License"); 3# Licensed under the Apache License, Version 2.0 (the "License");
@@ -14,13 +12,15 @@
14# See the License for the specific language governing permissions and 12# See the License for the specific language governing permissions and
15# limitations under the License. 13# limitations under the License.
16 14
17from __future__ import print_function 15import functools
18import sys 16import sys
19from command import Command 17
18from command import Command, DEFAULT_LOCAL_JOBS
20from progress import Progress 19from progress import Progress
21 20
21
22class Checkout(Command): 22class Checkout(Command):
23 common = True 23 COMMON = True
24 helpSummary = "Checkout a branch for development" 24 helpSummary = "Checkout a branch for development"
25 helpUsage = """ 25 helpUsage = """
26%prog <branchname> [<project>...] 26%prog <branchname> [<project>...]
@@ -33,28 +33,37 @@ The command is equivalent to:
33 33
34 repo forall [<project>...] -c git checkout <branchname> 34 repo forall [<project>...] -c git checkout <branchname>
35""" 35"""
36 PARALLEL_JOBS = DEFAULT_LOCAL_JOBS
36 37
37 def ValidateOptions(self, opt, args): 38 def ValidateOptions(self, opt, args):
38 if not args: 39 if not args:
39 self.Usage() 40 self.Usage()
40 41
42 def _ExecuteOne(self, nb, project):
43 """Checkout one project."""
44 return (project.CheckoutBranch(nb), project)
45
41 def Execute(self, opt, args): 46 def Execute(self, opt, args):
42 nb = args[0] 47 nb = args[0]
43 err = [] 48 err = []
44 success = [] 49 success = []
45 all_projects = self.GetProjects(args[1:]) 50 all_projects = self.GetProjects(args[1:])
46 51
47 pm = Progress('Checkout %s' % nb, len(all_projects)) 52 def _ProcessResults(_pool, pm, results):
48 for project in all_projects: 53 for status, project in results:
49 pm.update() 54 if status is not None:
55 if status:
56 success.append(project)
57 else:
58 err.append(project)
59 pm.update()
50 60
51 status = project.CheckoutBranch(nb) 61 self.ExecuteInParallel(
52 if status is not None: 62 opt.jobs,
53 if status: 63 functools.partial(self._ExecuteOne, nb),
54 success.append(project) 64 all_projects,
55 else: 65 callback=_ProcessResults,
56 err.append(project) 66 output=Progress('Checkout %s' % (nb,), len(all_projects), quiet=opt.quiet))
57 pm.end()
58 67
59 if err: 68 if err:
60 for p in err: 69 for p in err: