Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(228)

Side by Side Diff: git_map_branches.py

Issue 1847783002: Multiple improvements to windows bash integration. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Add direct mode and unbuffered Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « git_cl.py ('k') | python_runner.sh » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2014 The Chromium Authors. All rights reserved. 2 # Copyright 2014 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """Provides a short mapping of all the branches in your local repo, organized 6 """Provides a short mapping of all the branches in your local repo, organized
7 by their upstream ('tracking branch') layout. 7 by their upstream ('tracking branch') layout.
8 8
9 Example: 9 Example:
10 origin/master 10 origin/master
11 cool_feature 11 cool_feature
12 dependent_feature 12 dependent_feature
13 other_dependent_feature 13 other_dependent_feature
14 other_feature 14 other_feature
15 15
16 Branches are colorized as follows: 16 Branches are colorized as follows:
17 * Red - a remote branch (usually the root of all local branches) 17 * Red - a remote branch (usually the root of all local branches)
18 * Cyan - a local branch which is the same as HEAD 18 * Cyan - a local branch which is the same as HEAD
19 * Note that multiple branches may be Cyan, if they are all on the same 19 * Note that multiple branches may be Cyan, if they are all on the same
20 commit, and you have that commit checked out. 20 commit, and you have that commit checked out.
21 * Green - a local branch 21 * Green - a local branch
22 * Blue - a 'branch-heads' branch 22 * Blue - a 'branch-heads' branch
23 * Magenta - a tag 23 * Magenta - a tag
24 * Magenta '{NO UPSTREAM}' - If you have local branches which do not track any 24 * Magenta '{NO UPSTREAM}' - If you have local branches which do not track any
25 upstream, then you will see this. 25 upstream, then you will see this.
26 """ 26 """
27 27
28 import argparse 28 import argparse
29 import collections 29 import collections
30 import os
30 import sys 31 import sys
31 import subprocess2 32 import subprocess2
32 33
33 from third_party import colorama 34 from third_party import colorama
34 from third_party.colorama import Fore, Style 35 from third_party.colorama import Fore, Style
35 36
36 from git_common import current_branch, upstream, tags, get_branches_info 37 from git_common import current_branch, upstream, tags, get_branches_info
37 from git_common import get_git_version, MIN_UPSTREAM_TRACK_GIT_VERSION, hash_one 38 from git_common import get_git_version, MIN_UPSTREAM_TRACK_GIT_VERSION, hash_one
38 from git_common import run 39 from git_common import run
39 40
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 if self.show_subject: 265 if self.show_subject:
265 line.append(run('log', '-n1', '--format=%s', branch)) 266 line.append(run('log', '-n1', '--format=%s', branch))
266 267
267 self.output.append(line) 268 self.output.append(line)
268 269
269 for child in sorted(self.__parent_map.pop(branch, ())): 270 for child in sorted(self.__parent_map.pop(branch, ())):
270 self.__append_branch(child, depth=depth + 1) 271 self.__append_branch(child, depth=depth + 1)
271 272
272 273
273 def main(argv): 274 def main(argv):
274 colorama.init() 275 colorama.init(wrap="TERM" not in os.environ)
275 if get_git_version() < MIN_UPSTREAM_TRACK_GIT_VERSION: 276 if get_git_version() < MIN_UPSTREAM_TRACK_GIT_VERSION:
276 print >> sys.stderr, ( 277 print >> sys.stderr, (
277 'This tool will not show all tracking information for git version ' 278 'This tool will not show all tracking information for git version '
278 'earlier than ' + 279 'earlier than ' +
279 '.'.join(str(x) for x in MIN_UPSTREAM_TRACK_GIT_VERSION) + 280 '.'.join(str(x) for x in MIN_UPSTREAM_TRACK_GIT_VERSION) +
280 '. Please consider upgrading.') 281 '. Please consider upgrading.')
281 282
282 parser = argparse.ArgumentParser( 283 parser = argparse.ArgumentParser(
283 description='Print a a tree of all branches parented by their upstreams') 284 description='Print a a tree of all branches parented by their upstreams')
284 parser.add_argument('-v', action='count', 285 parser.add_argument('-v', action='count',
(...skipping 16 matching lines...) Expand all
301 mapper.start() 302 mapper.start()
302 print mapper.output.as_formatted_string() 303 print mapper.output.as_formatted_string()
303 return 0 304 return 0
304 305
305 if __name__ == '__main__': 306 if __name__ == '__main__':
306 try: 307 try:
307 sys.exit(main(sys.argv[1:])) 308 sys.exit(main(sys.argv[1:]))
308 except KeyboardInterrupt: 309 except KeyboardInterrupt:
309 sys.stderr.write('interrupted\n') 310 sys.stderr.write('interrupted\n')
310 sys.exit(1) 311 sys.exit(1)
OLDNEW
« no previous file with comments | « git_cl.py ('k') | python_runner.sh » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698