diff options
Diffstat (limited to 'subcmds/checkout.py')
-rw-r--r-- | subcmds/checkout.py | 83 |
1 files changed, 45 insertions, 38 deletions
diff --git a/subcmds/checkout.py b/subcmds/checkout.py index 768b6027..08012a82 100644 --- a/subcmds/checkout.py +++ b/subcmds/checkout.py | |||
@@ -20,12 +20,12 @@ from progress import Progress | |||
20 | 20 | ||
21 | 21 | ||
22 | class Checkout(Command): | 22 | class 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>...] |
27 | """ | 27 | """ |
28 | helpDescription = """ | 28 | helpDescription = """ |
29 | The '%prog' command checks out an existing branch that was previously | 29 | The '%prog' command checks out an existing branch that was previously |
30 | created by 'repo start'. | 30 | created by 'repo start'. |
31 | 31 | ||
@@ -33,43 +33,50 @@ 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 | PARALLEL_JOBS = DEFAULT_LOCAL_JOBS |
37 | 37 | ||
38 | def ValidateOptions(self, opt, args): | 38 | def ValidateOptions(self, opt, args): |
39 | if not args: | 39 | if not args: |
40 | self.Usage() | 40 | self.Usage() |
41 | 41 | ||
42 | def _ExecuteOne(self, nb, project): | 42 | def _ExecuteOne(self, nb, project): |
43 | """Checkout one project.""" | 43 | """Checkout one project.""" |
44 | return (project.CheckoutBranch(nb), project) | 44 | return (project.CheckoutBranch(nb), project) |
45 | 45 | ||
46 | def Execute(self, opt, args): | 46 | def Execute(self, opt, args): |
47 | nb = args[0] | 47 | nb = args[0] |
48 | err = [] | 48 | err = [] |
49 | success = [] | 49 | success = [] |
50 | all_projects = self.GetProjects(args[1:], all_manifests=not opt.this_manifest_only) | 50 | all_projects = self.GetProjects( |
51 | args[1:], all_manifests=not opt.this_manifest_only | ||
52 | ) | ||
51 | 53 | ||
52 | def _ProcessResults(_pool, pm, results): | 54 | def _ProcessResults(_pool, pm, results): |
53 | for status, project in results: | 55 | for status, project in results: |
54 | if status is not None: | 56 | if status is not None: |
55 | if status: | 57 | if status: |
56 | success.append(project) | 58 | success.append(project) |
57 | else: | 59 | else: |
58 | err.append(project) | 60 | err.append(project) |
59 | pm.update() | 61 | pm.update() |
60 | 62 | ||
61 | self.ExecuteInParallel( | 63 | self.ExecuteInParallel( |
62 | opt.jobs, | 64 | opt.jobs, |
63 | functools.partial(self._ExecuteOne, nb), | 65 | functools.partial(self._ExecuteOne, nb), |
64 | all_projects, | 66 | all_projects, |
65 | callback=_ProcessResults, | 67 | callback=_ProcessResults, |
66 | output=Progress('Checkout %s' % (nb,), len(all_projects), quiet=opt.quiet)) | 68 | output=Progress( |
69 | "Checkout %s" % (nb,), len(all_projects), quiet=opt.quiet | ||
70 | ), | ||
71 | ) | ||
67 | 72 | ||
68 | if err: | 73 | if err: |
69 | for p in err: | 74 | for p in err: |
70 | print("error: %s/: cannot checkout %s" % (p.relpath, nb), | 75 | print( |
71 | file=sys.stderr) | 76 | "error: %s/: cannot checkout %s" % (p.relpath, nb), |
72 | sys.exit(1) | 77 | file=sys.stderr, |
73 | elif not success: | 78 | ) |
74 | print('error: no project has branch %s' % nb, file=sys.stderr) | 79 | sys.exit(1) |
75 | sys.exit(1) | 80 | elif not success: |
81 | print("error: no project has branch %s" % nb, file=sys.stderr) | ||
82 | sys.exit(1) | ||