diff options
author | Etan Cohen <etancohen@google.com> | 2014-07-09 21:33:31 -0700 |
---|---|---|
committer | Etan Cohen <etancohen@google.com> | 2014-07-11 10:56:03 -0700 |
commit | 588142dfcb464a0db9ebc7b323ab2338d8f730de (patch) | |
tree | 4a2bace371ca6800e19e293a9681acc15a6369f4 /subcmds | |
parent | 666d534636d262cbfd971509dd0f0be0cddb2e11 (diff) | |
download | git-repo-588142dfcb464a0db9ebc7b323ab2338d8f730de.tar.gz |
Provide detail print-out when not all projects of a branch are current.
When current is "split" (i.e. some projects are current while others are not):
- Disable 'not in' printout (i.e. will print out all projects)
- Disable printing of multiple projects on one line
- Print current projects in green, non-current in white
Since using color to differentiate current from non-current in "split" cases:
- In non-split cases also print out project names in color (green for current
white for non-current)
Change-Id: Ia6b826612c708447cecfe5954dc767f7b2ea2ea7
Diffstat (limited to 'subcmds')
-rw-r--r-- | subcmds/branches.py | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/subcmds/branches.py b/subcmds/branches.py index f714c1e8..2902684a 100644 --- a/subcmds/branches.py +++ b/subcmds/branches.py | |||
@@ -47,6 +47,10 @@ class BranchInfo(object): | |||
47 | return self.current > 0 | 47 | return self.current > 0 |
48 | 48 | ||
49 | @property | 49 | @property |
50 | def IsSplitCurrent(self): | ||
51 | return self.current != 0 and self.current != len(self.projects) | ||
52 | |||
53 | @property | ||
50 | def IsPublished(self): | 54 | def IsPublished(self): |
51 | return self.published > 0 | 55 | return self.published > 0 |
52 | 56 | ||
@@ -139,10 +143,14 @@ is shown, then the branch appears in all projects. | |||
139 | if in_cnt < project_cnt: | 143 | if in_cnt < project_cnt: |
140 | fmt = out.write | 144 | fmt = out.write |
141 | paths = [] | 145 | paths = [] |
142 | if in_cnt < project_cnt - in_cnt: | 146 | non_cur_paths = [] |
147 | if i.IsSplitCurrent or (in_cnt < project_cnt - in_cnt): | ||
143 | in_type = 'in' | 148 | in_type = 'in' |
144 | for b in i.projects: | 149 | for b in i.projects: |
145 | paths.append(b.project.relpath) | 150 | if not i.IsSplitCurrent or b.current: |
151 | paths.append(b.project.relpath) | ||
152 | else: | ||
153 | non_cur_paths.append(b.project.relpath) | ||
146 | else: | 154 | else: |
147 | fmt = out.notinproject | 155 | fmt = out.notinproject |
148 | in_type = 'not in' | 156 | in_type = 'not in' |
@@ -154,13 +162,19 @@ is shown, then the branch appears in all projects. | |||
154 | paths.append(p.relpath) | 162 | paths.append(p.relpath) |
155 | 163 | ||
156 | s = ' %s %s' % (in_type, ', '.join(paths)) | 164 | s = ' %s %s' % (in_type, ', '.join(paths)) |
157 | if width + 7 + len(s) < 80: | 165 | if not i.IsSplitCurrent and (width + 7 + len(s) < 80): |
166 | fmt = out.current if i.IsCurrent else fmt | ||
158 | fmt(s) | 167 | fmt(s) |
159 | else: | 168 | else: |
160 | fmt(' %s:' % in_type) | 169 | fmt(' %s:' % in_type) |
170 | fmt = out.current if i.IsCurrent else out.write | ||
161 | for p in paths: | 171 | for p in paths: |
162 | out.nl() | 172 | out.nl() |
163 | fmt(width*' ' + ' %s' % p) | 173 | fmt(width*' ' + ' %s' % p) |
174 | fmt = out.write | ||
175 | for p in non_cur_paths: | ||
176 | out.nl() | ||
177 | fmt(width*' ' + ' %s' % p) | ||
164 | else: | 178 | else: |
165 | out.write(' in all projects') | 179 | out.write(' in all projects') |
166 | out.nl() | 180 | out.nl() |