diff options
Diffstat (limited to 'subcmds/overview.py')
| -rw-r--r-- | subcmds/overview.py | 124 |
1 files changed, 71 insertions, 53 deletions
diff --git a/subcmds/overview.py b/subcmds/overview.py index 11dba95f..8ccad611 100644 --- a/subcmds/overview.py +++ b/subcmds/overview.py | |||
| @@ -19,12 +19,12 @@ from command import PagedCommand | |||
| 19 | 19 | ||
| 20 | 20 | ||
| 21 | class Overview(PagedCommand): | 21 | class Overview(PagedCommand): |
| 22 | COMMON = True | 22 | COMMON = True |
| 23 | helpSummary = "Display overview of unmerged project branches" | 23 | helpSummary = "Display overview of unmerged project branches" |
| 24 | helpUsage = """ | 24 | helpUsage = """ |
| 25 | %prog [--current-branch] [<project>...] | 25 | %prog [--current-branch] [<project>...] |
| 26 | """ | 26 | """ |
| 27 | helpDescription = """ | 27 | helpDescription = """ |
| 28 | The '%prog' command is used to display an overview of the projects branches, | 28 | The '%prog' command is used to display an overview of the projects branches, |
| 29 | and list any local commits that have not yet been merged into the project. | 29 | and list any local commits that have not yet been merged into the project. |
| 30 | 30 | ||
| @@ -33,59 +33,77 @@ branches currently checked out in each project. By default, all branches | |||
| 33 | are displayed. | 33 | are displayed. |
| 34 | """ | 34 | """ |
| 35 | 35 | ||
| 36 | def _Options(self, p): | 36 | def _Options(self, p): |
| 37 | p.add_option('-c', '--current-branch', | 37 | p.add_option( |
| 38 | dest="current_branch", action="store_true", | 38 | "-c", |
| 39 | help="consider only checked out branches") | 39 | "--current-branch", |
| 40 | p.add_option('--no-current-branch', | 40 | dest="current_branch", |
| 41 | dest='current_branch', action='store_false', | 41 | action="store_true", |
| 42 | help='consider all local branches') | 42 | help="consider only checked out branches", |
| 43 | # Turn this into a warning & remove this someday. | 43 | ) |
| 44 | p.add_option('-b', | 44 | p.add_option( |
| 45 | dest='current_branch', action='store_true', | 45 | "--no-current-branch", |
| 46 | help=optparse.SUPPRESS_HELP) | 46 | dest="current_branch", |
| 47 | action="store_false", | ||
| 48 | help="consider all local branches", | ||
| 49 | ) | ||
| 50 | # Turn this into a warning & remove this someday. | ||
| 51 | p.add_option( | ||
| 52 | "-b", | ||
| 53 | dest="current_branch", | ||
| 54 | action="store_true", | ||
| 55 | help=optparse.SUPPRESS_HELP, | ||
| 56 | ) | ||
| 47 | 57 | ||
| 48 | def Execute(self, opt, args): | 58 | def Execute(self, opt, args): |
| 49 | all_branches = [] | 59 | all_branches = [] |
| 50 | for project in self.GetProjects(args, all_manifests=not opt.this_manifest_only): | 60 | for project in self.GetProjects( |
| 51 | br = [project.GetUploadableBranch(x) | 61 | args, all_manifests=not opt.this_manifest_only |
| 52 | for x in project.GetBranches()] | 62 | ): |
| 53 | br = [x for x in br if x] | 63 | br = [project.GetUploadableBranch(x) for x in project.GetBranches()] |
| 54 | if opt.current_branch: | 64 | br = [x for x in br if x] |
| 55 | br = [x for x in br if x.name == project.CurrentBranch] | 65 | if opt.current_branch: |
| 56 | all_branches.extend(br) | 66 | br = [x for x in br if x.name == project.CurrentBranch] |
| 67 | all_branches.extend(br) | ||
| 57 | 68 | ||
| 58 | if not all_branches: | 69 | if not all_branches: |
| 59 | return | 70 | return |
| 60 | 71 | ||
| 61 | class Report(Coloring): | 72 | class Report(Coloring): |
| 62 | def __init__(self, config): | 73 | def __init__(self, config): |
| 63 | Coloring.__init__(self, config, 'status') | 74 | Coloring.__init__(self, config, "status") |
| 64 | self.project = self.printer('header', attr='bold') | 75 | self.project = self.printer("header", attr="bold") |
| 65 | self.text = self.printer('text') | 76 | self.text = self.printer("text") |
| 66 | 77 | ||
| 67 | out = Report(all_branches[0].project.config) | 78 | out = Report(all_branches[0].project.config) |
| 68 | out.text("Deprecated. See repo info -o.") | 79 | out.text("Deprecated. See repo info -o.") |
| 69 | out.nl() | ||
| 70 | out.project('Projects Overview') | ||
| 71 | out.nl() | ||
| 72 | |||
| 73 | project = None | ||
| 74 | |||
| 75 | for branch in all_branches: | ||
| 76 | if project != branch.project: | ||
| 77 | project = branch.project | ||
| 78 | out.nl() | 80 | out.nl() |
| 79 | out.project('project %s/' % project.RelPath(local=opt.this_manifest_only)) | 81 | out.project("Projects Overview") |
| 80 | out.nl() | 82 | out.nl() |
| 81 | 83 | ||
| 82 | commits = branch.commits | 84 | project = None |
| 83 | date = branch.date | 85 | |
| 84 | print('%s %-33s (%2d commit%s, %s)' % ( | 86 | for branch in all_branches: |
| 85 | branch.name == project.CurrentBranch and '*' or ' ', | 87 | if project != branch.project: |
| 86 | branch.name, | 88 | project = branch.project |
| 87 | len(commits), | 89 | out.nl() |
| 88 | len(commits) != 1 and 's' or ' ', | 90 | out.project( |
| 89 | date)) | 91 | "project %s/" |
| 90 | for commit in commits: | 92 | % project.RelPath(local=opt.this_manifest_only) |
| 91 | print('%-35s - %s' % ('', commit)) | 93 | ) |
| 94 | out.nl() | ||
| 95 | |||
| 96 | commits = branch.commits | ||
| 97 | date = branch.date | ||
| 98 | print( | ||
| 99 | "%s %-33s (%2d commit%s, %s)" | ||
| 100 | % ( | ||
| 101 | branch.name == project.CurrentBranch and "*" or " ", | ||
| 102 | branch.name, | ||
| 103 | len(commits), | ||
| 104 | len(commits) != 1 and "s" or " ", | ||
| 105 | date, | ||
| 106 | ) | ||
| 107 | ) | ||
| 108 | for commit in commits: | ||
| 109 | print("%-35s - %s" % ("", commit)) | ||
