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