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

Side by Side Diff: git_common.py

Issue 1162763003: Fix git branch parsing. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Fix it for real. Created 5 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | tests/git_common_test.py » ('j') | no next file with comments »
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 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 """Return {branch: <|option| value>} for all branches.""" 286 """Return {branch: <|option| value>} for all branches."""
287 try: 287 try:
288 reg = re.compile(r'^branch\.(.*)\.%s$' % option) 288 reg = re.compile(r'^branch\.(.*)\.%s$' % option)
289 lines = run('config', '--get-regexp', reg.pattern).splitlines() 289 lines = run('config', '--get-regexp', reg.pattern).splitlines()
290 return {reg.match(k).group(1): v for k, v in (l.split() for l in lines)} 290 return {reg.match(k).group(1): v for k, v in (l.split() for l in lines)}
291 except subprocess2.CalledProcessError: 291 except subprocess2.CalledProcessError:
292 return {} 292 return {}
293 293
294 294
295 def branches(*args): 295 def branches(*args):
296 NO_BRANCH = ('* (no branch', '* (detached from ') 296 NO_BRANCH = ('* (no branch', '* (detached', '* (HEAD detached')
297 297
298 key = 'depot-tools.branch-limit' 298 key = 'depot-tools.branch-limit'
299 limit = 20 299 limit = 20
300 try: 300 try:
301 limit = int(config(key, limit)) 301 limit = int(config(key, limit))
302 except ValueError: 302 except ValueError:
303 pass 303 pass
304 304
305 raw_branches = run('branch', *args).splitlines() 305 raw_branches = run('branch', *args).splitlines()
306 306
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after
787 hash=branch_hash, upstream=upstream_branch, ahead=ahead, behind=behind) 787 hash=branch_hash, upstream=upstream_branch, ahead=ahead, behind=behind)
788 788
789 # Set None for upstreams which are not branches (e.g empty upstream, remotes 789 # Set None for upstreams which are not branches (e.g empty upstream, remotes
790 # and deleted upstream branches). 790 # and deleted upstream branches).
791 missing_upstreams = {} 791 missing_upstreams = {}
792 for info in info_map.values(): 792 for info in info_map.values():
793 if info.upstream not in info_map and info.upstream not in missing_upstreams: 793 if info.upstream not in info_map and info.upstream not in missing_upstreams:
794 missing_upstreams[info.upstream] = None 794 missing_upstreams[info.upstream] = None
795 795
796 return dict(info_map.items() + missing_upstreams.items()) 796 return dict(info_map.items() + missing_upstreams.items())
OLDNEW
« no previous file with comments | « no previous file | tests/git_common_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698