summaryrefslogtreecommitdiffstats
path: root/subcmds/info.py
diff options
context:
space:
mode:
Diffstat (limited to 'subcmds/info.py')
-rw-r--r--subcmds/info.py55
1 files changed, 33 insertions, 22 deletions
diff --git a/subcmds/info.py b/subcmds/info.py
index d62e1e64..6c1246ef 100644
--- a/subcmds/info.py
+++ b/subcmds/info.py
@@ -1,5 +1,3 @@
1# -*- coding:utf-8 -*-
2#
3# Copyright (C) 2012 The Android Open Source Project 1# Copyright (C) 2012 The Android Open Source Project
4# 2#
5# Licensed under the Apache License, Version 2.0 (the "License"); 3# Licensed under the Apache License, Version 2.0 (the "License");
@@ -14,18 +12,22 @@
14# See the License for the specific language governing permissions and 12# See the License for the specific language governing permissions and
15# limitations under the License. 13# limitations under the License.
16 14
15import optparse
16
17from command import PagedCommand 17from command import PagedCommand
18from color import Coloring 18from color import Coloring
19from git_refs import R_M 19from git_refs import R_M, R_HEADS
20
20 21
21class _Coloring(Coloring): 22class _Coloring(Coloring):
22 def __init__(self, config): 23 def __init__(self, config):
23 Coloring.__init__(self, config, "status") 24 Coloring.__init__(self, config, "status")
24 25
26
25class Info(PagedCommand): 27class Info(PagedCommand):
26 common = True 28 COMMON = True
27 helpSummary = "Get info on the manifest branch, current branch or unmerged branches" 29 helpSummary = "Get info on the manifest branch, current branch or unmerged branches"
28 helpUsage = "%prog [-dl] [-o [-b]] [<project>...]" 30 helpUsage = "%prog [-dl] [-o [-c]] [<project>...]"
29 31
30 def _Options(self, p): 32 def _Options(self, p):
31 p.add_option('-d', '--diff', 33 p.add_option('-d', '--diff',
@@ -34,22 +36,28 @@ class Info(PagedCommand):
34 p.add_option('-o', '--overview', 36 p.add_option('-o', '--overview',
35 dest='overview', action='store_true', 37 dest='overview', action='store_true',
36 help='show overview of all local commits') 38 help='show overview of all local commits')
37 p.add_option('-b', '--current-branch', 39 p.add_option('-c', '--current-branch',
38 dest="current_branch", action="store_true", 40 dest="current_branch", action="store_true",
39 help="consider only checked out branches") 41 help="consider only checked out branches")
42 p.add_option('--no-current-branch',
43 dest='current_branch', action='store_false',
44 help='consider all local branches')
45 # Turn this into a warning & remove this someday.
46 p.add_option('-b',
47 dest='current_branch', action='store_true',
48 help=optparse.SUPPRESS_HELP)
40 p.add_option('-l', '--local-only', 49 p.add_option('-l', '--local-only',
41 dest="local", action="store_true", 50 dest="local", action="store_true",
42 help="Disable all remote operations") 51 help="disable all remote operations")
43
44 52
45 def Execute(self, opt, args): 53 def Execute(self, opt, args):
46 self.out = _Coloring(self.manifest.globalConfig) 54 self.out = _Coloring(self.client.globalConfig)
47 self.heading = self.out.printer('heading', attr = 'bold') 55 self.heading = self.out.printer('heading', attr='bold')
48 self.headtext = self.out.nofmt_printer('headtext', fg = 'yellow') 56 self.headtext = self.out.nofmt_printer('headtext', fg='yellow')
49 self.redtext = self.out.printer('redtext', fg = 'red') 57 self.redtext = self.out.printer('redtext', fg='red')
50 self.sha = self.out.printer("sha", fg = 'yellow') 58 self.sha = self.out.printer("sha", fg='yellow')
51 self.text = self.out.nofmt_printer('text') 59 self.text = self.out.nofmt_printer('text')
52 self.dimtext = self.out.printer('dimtext', attr = 'dim') 60 self.dimtext = self.out.printer('dimtext', attr='dim')
53 61
54 self.opt = opt 62 self.opt = opt
55 63
@@ -122,11 +130,14 @@ class Info(PagedCommand):
122 self.printSeparator() 130 self.printSeparator()
123 131
124 def findRemoteLocalDiff(self, project): 132 def findRemoteLocalDiff(self, project):
125 #Fetch all the latest commits 133 # Fetch all the latest commits.
126 if not self.opt.local: 134 if not self.opt.local:
127 project.Sync_NetworkHalf(quiet=True, current_branch_only=True) 135 project.Sync_NetworkHalf(quiet=True, current_branch_only=True)
128 136
129 logTarget = R_M + self.manifest.manifestProject.config.GetBranch("default").merge 137 branch = self.manifest.manifestProject.config.GetBranch('default').merge
138 if branch.startswith(R_HEADS):
139 branch = branch[len(R_HEADS):]
140 logTarget = R_M + branch
130 141
131 bareTmp = project.bare_git._bare 142 bareTmp = project.bare_git._bare
132 project.bare_git._bare = False 143 project.bare_git._bare = False
@@ -195,16 +206,16 @@ class Info(PagedCommand):
195 commits = branch.commits 206 commits = branch.commits
196 date = branch.date 207 date = branch.date
197 self.text('%s %-33s (%2d commit%s, %s)' % ( 208 self.text('%s %-33s (%2d commit%s, %s)' % (
198 branch.name == project.CurrentBranch and '*' or ' ', 209 branch.name == project.CurrentBranch and '*' or ' ',
199 branch.name, 210 branch.name,
200 len(commits), 211 len(commits),
201 len(commits) != 1 and 's' or '', 212 len(commits) != 1 and 's' or '',
202 date)) 213 date))
203 self.out.nl() 214 self.out.nl()
204 215
205 for commit in commits: 216 for commit in commits:
206 split = commit.split() 217 split = commit.split()
207 self.text('{0:38}{1} '.format('','-')) 218 self.text('{0:38}{1} '.format('', '-'))
208 self.sha(split[0] + " ") 219 self.sha(split[0] + " ")
209 self.text(" ".join(split[1:])) 220 self.text(" ".join(split[1:]))
210 self.out.nl() 221 self.out.nl()