summaryrefslogtreecommitdiffstats
path: root/subcmds/overview.py
diff options
context:
space:
mode:
authorJoe Hansche <jhansche@myyearbook.com>2012-07-09 12:59:56 -0400
committerShawn O. Pearce <sop@google.com>2012-07-31 22:08:32 -0700
commit2f127de7520a0b689bfe5082360eeb53a05d6e2d (patch)
tree00613e764af267a5c1636c04cb5597f0d4beec9e /subcmds/overview.py
parent7da1314e38a2bb2941511c9003fa388eddb55c0a (diff)
downloadgit-repo-2f127de7520a0b689bfe5082360eeb53a05d6e2d.tar.gz
Add "repo overview" command.
The overview command shows an overview of each branch in all (or the specified) projects. The overview lists any local commits that have not yet been merged into the project. The report output is inspired by the report displayed following a "repo prune" event, with the addition of listing the one-line log messages for each commit that is not yet merged. The report can also be filtered to show only active branches; by default all branches that have commits beyond the upstream HEAD will be listed. Change-Id: Ibe67793991ad1aa38de3bc9747de4ba64e5591aa
Diffstat (limited to 'subcmds/overview.py')
-rw-r--r--subcmds/overview.py80
1 files changed, 80 insertions, 0 deletions
diff --git a/subcmds/overview.py b/subcmds/overview.py
new file mode 100644
index 00000000..96fa93d8
--- /dev/null
+++ b/subcmds/overview.py
@@ -0,0 +1,80 @@
1#
2# Copyright (C) 2012 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
16from color import Coloring
17from command import PagedCommand
18
19
20class Overview(PagedCommand):
21 common = True
22 helpSummary = "Display overview of unmerged project branches"
23 helpUsage = """
24%prog [--current-branch] [<project>...]
25"""
26 helpDescription = """
27The '%prog' command is used to display an overview of the projects branches,
28and list any local commits that have not yet been merged into the project.
29
30The -b/--current-branch option can be used to restrict the output to only
31branches currently checked out in each project. By default, all branches
32are displayed.
33"""
34
35 def _Options(self, p):
36 p.add_option('-b', '--current-branch',
37 dest="current_branch", action="store_true",
38 help="Consider only checked out branches")
39
40 def Execute(self, opt, args):
41 all = []
42 for project in self.GetProjects(args):
43 br = [project.GetUploadableBranch(x)
44 for x in project.GetBranches().keys()]
45 br = [x for x in br if x]
46 if opt.current_branch:
47 br = [x for x in br if x.name == project.CurrentBranch]
48 all.extend(br)
49
50 if not all:
51 return
52
53 class Report(Coloring):
54 def __init__(self, config):
55 Coloring.__init__(self, config, 'status')
56 self.project = self.printer('header', attr='bold')
57
58 out = Report(all[0].project.config)
59 out.project('Projects Overview')
60 out.nl()
61
62 project = None
63
64 for branch in all:
65 if project != branch.project:
66 project = branch.project
67 out.nl()
68 out.project('project %s/' % project.relpath)
69 out.nl()
70
71 commits = branch.commits
72 date = branch.date
73 print '%s %-33s (%2d commit%s, %s)' % (
74 branch.name == project.CurrentBranch and '*' or ' ',
75 branch.name,
76 len(commits),
77 len(commits) != 1 and 's' or ' ',
78 date)
79 for commit in commits:
80 print '%-35s - %s' % ('', commit)