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

Side by Side Diff: git_common.py

Issue 536793002: Skip tracking status in map-branches when -v flag is not supplied. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Created 6 years, 3 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 | « no previous file | git_map_branches.py » ('j') | git_map_branches.py » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 # Monkeypatch IMapIterator so that Ctrl-C can kill everything properly. 5 # Monkeypatch IMapIterator so that Ctrl-C can kill everything properly.
6 # Derived from https://gist.github.com/aljungberg/626518 6 # Derived from https://gist.github.com/aljungberg/626518
7 import multiprocessing.pool 7 import multiprocessing.pool
8 from multiprocessing.pool import IMapIterator 8 from multiprocessing.pool import IMapIterator
9 def wrapper(func): 9 def wrapper(func):
10 def wrap(self, timeout=None): 10 def wrap(self, timeout=None):
(...skipping 715 matching lines...) Expand 10 before | Expand all | Expand 10 after
726 def get_git_version(): 726 def get_git_version():
727 """Returns a tuple that contains the numeric components of the current git 727 """Returns a tuple that contains the numeric components of the current git
728 version.""" 728 version."""
729 version_string = run('--version') 729 version_string = run('--version')
730 version_match = re.search(r'(\d+.)+(\d+)', version_string) 730 version_match = re.search(r'(\d+.)+(\d+)', version_string)
731 version = version_match.group() if version_match else '' 731 version = version_match.group() if version_match else ''
732 732
733 return tuple(int(x) for x in version.split('.')) 733 return tuple(int(x) for x in version.split('.'))
734 734
735 735
736 def get_all_tracking_info(): 736 def get_all_tracking_info(include_tracking_status=True):
Matt Giuca 2014/09/03 03:21:55 Don't set a default here. There isn't a "correct"
calamity 2014/09/03 04:38:53 Done.
737 format_string = ( 737 format_string = (
738 '--format=%(refname:short):%(objectname:short):%(upstream:short):') 738 '--format=%(refname:short):%(objectname:short):%(upstream:short):')
739 739
740 # This is not covered by the depot_tools CQ which only has git version 1.8. 740 # This is not covered by the depot_tools CQ which only has git version 1.8.
741 if get_git_version() >= MIN_UPSTREAM_TRACK_GIT_VERSION: # pragma: no cover 741 if (include_tracking_status and
742 get_git_version() >= MIN_UPSTREAM_TRACK_GIT_VERSION): # pragma: no cover
742 format_string += '%(upstream:track)' 743 format_string += '%(upstream:track)'
743 744
744 info_map = {} 745 info_map = {}
745 data = run('for-each-ref', format_string, 'refs/heads') 746 data = run('for-each-ref', format_string, 'refs/heads')
746 TrackingInfo = collections.namedtuple( 747 TrackingInfo = collections.namedtuple(
747 'TrackingInfo', 'hash upstream ahead behind') 748 'TrackingInfo', 'hash upstream ahead behind')
748 for line in data.splitlines(): 749 for line in data.splitlines():
749 (branch, branch_hash, upstream_branch, tracking_status) = line.split(':') 750 (branch, branch_hash, upstream_branch, tracking_status) = line.split(':')
750 751
751 ahead_match = re.search(r'ahead (\d+)', tracking_status) 752 ahead_match = re.search(r'ahead (\d+)', tracking_status)
752 ahead = int(ahead_match.group(1)) if ahead_match else None 753 ahead = int(ahead_match.group(1)) if ahead_match else None
753 754
754 behind_match = re.search(r'behind (\d+)', tracking_status) 755 behind_match = re.search(r'behind (\d+)', tracking_status)
755 behind = int(behind_match.group(1)) if behind_match else None 756 behind = int(behind_match.group(1)) if behind_match else None
756 757
757 info_map[branch] = TrackingInfo( 758 info_map[branch] = TrackingInfo(
758 hash=branch_hash, upstream=upstream_branch, ahead=ahead, behind=behind) 759 hash=branch_hash, upstream=upstream_branch, ahead=ahead, behind=behind)
759 760
760 # Set None for upstreams which are not branches (e.g empty upstream, remotes 761 # Set None for upstreams which are not branches (e.g empty upstream, remotes
761 # and deleted upstream branches). 762 # and deleted upstream branches).
762 missing_upstreams = {} 763 missing_upstreams = {}
763 for info in info_map.values(): 764 for info in info_map.values():
764 if info.upstream not in info_map and info.upstream not in missing_upstreams: 765 if info.upstream not in info_map and info.upstream not in missing_upstreams:
765 missing_upstreams[info.upstream] = None 766 missing_upstreams[info.upstream] = None
766 767
767 return dict(info_map.items() + missing_upstreams.items()) 768 return dict(info_map.items() + missing_upstreams.items())
OLDNEW
« no previous file with comments | « no previous file | git_map_branches.py » ('j') | git_map_branches.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698