summaryrefslogtreecommitdiffstats
path: root/subcmds/prune.py
diff options
context:
space:
mode:
Diffstat (limited to 'subcmds/prune.py')
-rw-r--r--subcmds/prune.py31
1 files changed, 23 insertions, 8 deletions
diff --git a/subcmds/prune.py b/subcmds/prune.py
index ff2fba1d..584ee7ed 100644
--- a/subcmds/prune.py
+++ b/subcmds/prune.py
@@ -1,5 +1,3 @@
1# -*- coding:utf-8 -*-
2#
3# Copyright (C) 2008 The Android Open Source Project 1# Copyright (C) 2008 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,21 +12,38 @@
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 itertools
16
18from color import Coloring 17from color import Coloring
19from command import PagedCommand 18from command import DEFAULT_LOCAL_JOBS, PagedCommand
19
20 20
21class Prune(PagedCommand): 21class Prune(PagedCommand):
22 common = True 22 COMMON = True
23 helpSummary = "Prune (delete) already merged topics" 23 helpSummary = "Prune (delete) already merged topics"
24 helpUsage = """ 24 helpUsage = """
25%prog [<project>...] 25%prog [<project>...]
26""" 26"""
27 PARALLEL_JOBS = DEFAULT_LOCAL_JOBS
28
29 def _ExecuteOne(self, project):
30 """Process one project."""
31 return project.PruneHeads()
27 32
28 def Execute(self, opt, args): 33 def Execute(self, opt, args):
29 all_branches = [] 34 projects = self.GetProjects(args)
30 for project in self.GetProjects(args): 35
31 all_branches.extend(project.PruneHeads()) 36 # NB: Should be able to refactor this module to display summary as results
37 # come back from children.
38 def _ProcessResults(_pool, _output, results):
39 return list(itertools.chain.from_iterable(results))
40
41 all_branches = self.ExecuteInParallel(
42 opt.jobs,
43 self._ExecuteOne,
44 projects,
45 callback=_ProcessResults,
46 ordered=True)
32 47
33 if not all_branches: 48 if not all_branches:
34 return 49 return