blob: 39c571a4606f37dc0656fba145a0bc12d23ea9fc [file] [log] [blame]
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -07001#
2# Copyright (C) 2008 The Android Open Source Project
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
Sarah Owenscecd1d82012-11-01 22:59:27 -070016from __future__ import print_function
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -070017from color import Coloring
18from command import PagedCommand
19
20class Prune(PagedCommand):
21 common = True
22 helpSummary = "Prune (delete) already merged topics"
23 helpUsage = """
24%prog [<project>...]
25"""
26
27 def Execute(self, opt, args):
David Pursehouse8a68ff92012-09-24 12:15:13 +090028 all_branches = []
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -070029 for project in self.GetProjects(args):
David Pursehouse8a68ff92012-09-24 12:15:13 +090030 all_branches.extend(project.PruneHeads())
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -070031
David Pursehouse8a68ff92012-09-24 12:15:13 +090032 if not all_branches:
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -070033 return
34
35 class Report(Coloring):
36 def __init__(self, config):
37 Coloring.__init__(self, config, 'status')
38 self.project = self.printer('header', attr='bold')
39
David Pursehouse8a68ff92012-09-24 12:15:13 +090040 out = Report(all_branches[0].project.config)
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -070041 out.project('Pending Branches')
42 out.nl()
43
44 project = None
45
David Pursehouse8a68ff92012-09-24 12:15:13 +090046 for branch in all_branches:
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -070047 if project != branch.project:
48 project = branch.project
49 out.nl()
50 out.project('project %s/' % project.relpath)
51 out.nl()
52
53 commits = branch.commits
54 date = branch.date
Sarah Owenscecd1d82012-11-01 22:59:27 -070055 print('%s %-33s (%2d commit%s, %s)' % (
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -070056 branch.name == project.CurrentBranch and '*' or ' ',
57 branch.name,
58 len(commits),
59 len(commits) != 1 and 's' or ' ',
Sarah Owenscecd1d82012-11-01 22:59:27 -070060 date))