diff options
Diffstat (limited to 'subcmds/prune.py')
| -rw-r--r-- | subcmds/prune.py | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/subcmds/prune.py b/subcmds/prune.py new file mode 100644 index 00000000..f412bd48 --- /dev/null +++ b/subcmds/prune.py | |||
| @@ -0,0 +1,59 @@ | |||
| 1 | # | ||
| 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 | |||
| 16 | from color import Coloring | ||
| 17 | from command import PagedCommand | ||
| 18 | |||
| 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): | ||
| 27 | all = [] | ||
| 28 | for project in self.GetProjects(args): | ||
| 29 | all.extend(project.PruneHeads()) | ||
| 30 | |||
| 31 | if not all: | ||
| 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 | |||
| 39 | out = Report(all[0].project.config) | ||
| 40 | out.project('Pending Branches') | ||
| 41 | out.nl() | ||
| 42 | |||
| 43 | project = None | ||
| 44 | |||
| 45 | for branch in all: | ||
| 46 | if project != branch.project: | ||
| 47 | project = branch.project | ||
| 48 | out.nl() | ||
| 49 | out.project('project %s/' % project.relpath) | ||
| 50 | out.nl() | ||
| 51 | |||
| 52 | commits = branch.commits | ||
| 53 | date = branch.date | ||
| 54 | print '%s %-33s (%2d commit%s, %s)' % ( | ||
| 55 | branch.name == project.CurrentBranch and '*' or ' ', | ||
| 56 | branch.name, | ||
| 57 | len(commits), | ||
| 58 | len(commits) != 1 and 's' or ' ', | ||
| 59 | date) | ||
