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 | |
David Pursehouse | 819827a | 2020-02-12 15:20:19 +0900 | [diff] [blame] | 21 | |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 22 | class Prune(PagedCommand): |
| 23 | common = True |
| 24 | helpSummary = "Prune (delete) already merged topics" |
| 25 | helpUsage = """ |
| 26 | %prog [<project>...] |
| 27 | """ |
| 28 | |
| 29 | def Execute(self, opt, args): |
David Pursehouse | 8a68ff9 | 2012-09-24 12:15:13 +0900 | [diff] [blame] | 30 | all_branches = [] |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 31 | for project in self.GetProjects(args): |
David Pursehouse | 8a68ff9 | 2012-09-24 12:15:13 +0900 | [diff] [blame] | 32 | all_branches.extend(project.PruneHeads()) |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 33 | |
David Pursehouse | 8a68ff9 | 2012-09-24 12:15:13 +0900 | [diff] [blame] | 34 | if not all_branches: |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 35 | return |
| 36 | |
| 37 | class Report(Coloring): |
| 38 | def __init__(self, config): |
| 39 | Coloring.__init__(self, config, 'status') |
| 40 | self.project = self.printer('header', attr='bold') |
| 41 | |
David Pursehouse | 8a68ff9 | 2012-09-24 12:15:13 +0900 | [diff] [blame] | 42 | out = Report(all_branches[0].project.config) |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 43 | out.project('Pending Branches') |
| 44 | out.nl() |
| 45 | |
| 46 | project = None |
| 47 | |
David Pursehouse | 8a68ff9 | 2012-09-24 12:15:13 +0900 | [diff] [blame] | 48 | for branch in all_branches: |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 49 | if project != branch.project: |
| 50 | project = branch.project |
| 51 | out.nl() |
| 52 | out.project('project %s/' % project.relpath) |
| 53 | out.nl() |
| 54 | |
Mike Frysinger | 6da1775 | 2019-09-11 18:43:17 -0400 | [diff] [blame] | 55 | print('%s %-33s ' % ( |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 56 | branch.name == project.CurrentBranch and '*' or ' ', |
Mike Frysinger | 6da1775 | 2019-09-11 18:43:17 -0400 | [diff] [blame] | 57 | branch.name), end='') |
| 58 | |
| 59 | if not branch.base_exists: |
| 60 | print('(ignoring: tracking branch is gone: %s)' % (branch.base,)) |
| 61 | else: |
| 62 | commits = branch.commits |
| 63 | date = branch.date |
| 64 | print('(%2d commit%s, %s)' % ( |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 65 | len(commits), |
| 66 | len(commits) != 1 and 's' or ' ', |
Sarah Owens | cecd1d8 | 2012-11-01 22:59:27 -0700 | [diff] [blame] | 67 | date)) |