Mike Frysinger | f601376 | 2019-06-13 02:30:51 -0400 | [diff] [blame] | 1 | # -*- coding:utf-8 -*- |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2 | # |
| 3 | # Copyright (C) 2008 The Android Open Source Project |
| 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | # you may not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of the License at |
| 8 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | # See the License for the specific language governing permissions and |
| 15 | # limitations under the License. |
| 16 | |
Sarah Owens | cecd1d8 | 2012-11-01 22:59:27 -0700 | [diff] [blame] | 17 | from __future__ import print_function |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 18 | from color import Coloring |
| 19 | from command import PagedCommand |
| 20 | |
| 21 | class Prune(PagedCommand): |
| 22 | common = True |
| 23 | helpSummary = "Prune (delete) already merged topics" |
| 24 | helpUsage = """ |
| 25 | %prog [<project>...] |
| 26 | """ |
| 27 | |
| 28 | def Execute(self, opt, args): |
David Pursehouse | 8a68ff9 | 2012-09-24 12:15:13 +0900 | [diff] [blame] | 29 | all_branches = [] |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 30 | for project in self.GetProjects(args): |
David Pursehouse | 8a68ff9 | 2012-09-24 12:15:13 +0900 | [diff] [blame] | 31 | all_branches.extend(project.PruneHeads()) |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 32 | |
David Pursehouse | 8a68ff9 | 2012-09-24 12:15:13 +0900 | [diff] [blame] | 33 | if not all_branches: |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 34 | return |
| 35 | |
| 36 | class Report(Coloring): |
| 37 | def __init__(self, config): |
| 38 | Coloring.__init__(self, config, 'status') |
| 39 | self.project = self.printer('header', attr='bold') |
| 40 | |
David Pursehouse | 8a68ff9 | 2012-09-24 12:15:13 +0900 | [diff] [blame] | 41 | out = Report(all_branches[0].project.config) |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 42 | out.project('Pending Branches') |
| 43 | out.nl() |
| 44 | |
| 45 | project = None |
| 46 | |
David Pursehouse | 8a68ff9 | 2012-09-24 12:15:13 +0900 | [diff] [blame] | 47 | for branch in all_branches: |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 48 | if project != branch.project: |
| 49 | project = branch.project |
| 50 | out.nl() |
| 51 | out.project('project %s/' % project.relpath) |
| 52 | out.nl() |
| 53 | |
| 54 | commits = branch.commits |
| 55 | date = branch.date |
Sarah Owens | cecd1d8 | 2012-11-01 22:59:27 -0700 | [diff] [blame] | 56 | print('%s %-33s (%2d commit%s, %s)' % ( |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 57 | branch.name == project.CurrentBranch and '*' or ' ', |
| 58 | branch.name, |
| 59 | len(commits), |
| 60 | len(commits) != 1 and 's' or ' ', |
Sarah Owens | cecd1d8 | 2012-11-01 22:59:27 -0700 | [diff] [blame] | 61 | date)) |