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

Side by Side Diff: git_common.py

Issue 645763002: Improve error handling in git-rebase-update (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Created 6 years, 2 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_rebase_update.py » ('j') | git_rebase_update.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 479 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 * 'HEAD' 490 * 'HEAD'
491 * 'origin/master' 491 * 'origin/master'
492 * 'cool_branch~2' 492 * 'cool_branch~2'
493 """ 493 """
494 try: 494 try:
495 return map(binascii.unhexlify, hash_multi(*commitrefs)) 495 return map(binascii.unhexlify, hash_multi(*commitrefs))
496 except subprocess2.CalledProcessError: 496 except subprocess2.CalledProcessError:
497 raise BadCommitRefException(commitrefs) 497 raise BadCommitRefException(commitrefs)
498 498
499 499
500 RebaseRet = collections.namedtuple('RebaseRet', 'success message') 500 RebaseRet = collections.namedtuple('RebaseRet', 'success stdout stderr')
501 501
502 502
503 def rebase(parent, start, branch, abort=False): 503 def rebase(parent, start, branch, abort=False):
504 """Rebases |start|..|branch| onto the branch |parent|. 504 """Rebases |start|..|branch| onto the branch |parent|.
505 505
506 Args: 506 Args:
507 parent - The new parent ref for the rebased commits. 507 parent - The new parent ref for the rebased commits.
508 start - The commit to start from 508 start - The commit to start from
509 branch - The branch to rebase 509 branch - The branch to rebase
510 abort - If True, will call git-rebase --abort in the event that the rebase 510 abort - If True, will call git-rebase --abort in the event that the rebase
511 doesn't complete successfully. 511 doesn't complete successfully.
512 512
513 Returns a namedtuple with fields: 513 Returns a namedtuple with fields:
514 success - a boolean indicating that the rebase command completed 514 success - a boolean indicating that the rebase command completed
515 successfully. 515 successfully.
516 message - if the rebase failed, this contains the stdout of the failed 516 message - if the rebase failed, this contains the stdout of the failed
517 rebase. 517 rebase.
518 """ 518 """
519 try: 519 try:
520 args = ['--onto', parent, start, branch] 520 args = ['--onto', parent, start, branch]
521 if TEST_MODE: 521 if TEST_MODE:
522 args.insert(0, '--committer-date-is-author-date') 522 args.insert(0, '--committer-date-is-author-date')
523 run('rebase', *args) 523 run('rebase', *args)
524 return RebaseRet(True, '') 524 return RebaseRet(True, '', '')
525 except subprocess2.CalledProcessError as cpe: 525 except subprocess2.CalledProcessError as cpe:
526 if abort: 526 if abort:
527 run('rebase', '--abort') 527 run('rebase', '--abort')
528 return RebaseRet(False, cpe.stdout) 528 return RebaseRet(False, cpe.stdout, cpe.stderr)
529 529
530 530
531 def remove_merge_base(branch): 531 def remove_merge_base(branch):
532 del_branch_config(branch, 'base') 532 del_branch_config(branch, 'base')
533 del_branch_config(branch, 'base-upstream') 533 del_branch_config(branch, 'base-upstream')
534 534
535 535
536 def root(): 536 def root():
537 return config('depot-tools.upstream', 'origin/master') 537 return config('depot-tools.upstream', 'origin/master')
538 538
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
761 hash=branch_hash, upstream=upstream_branch, ahead=ahead, behind=behind) 761 hash=branch_hash, upstream=upstream_branch, ahead=ahead, behind=behind)
762 762
763 # Set None for upstreams which are not branches (e.g empty upstream, remotes 763 # Set None for upstreams which are not branches (e.g empty upstream, remotes
764 # and deleted upstream branches). 764 # and deleted upstream branches).
765 missing_upstreams = {} 765 missing_upstreams = {}
766 for info in info_map.values(): 766 for info in info_map.values():
767 if info.upstream not in info_map and info.upstream not in missing_upstreams: 767 if info.upstream not in info_map and info.upstream not in missing_upstreams:
768 missing_upstreams[info.upstream] = None 768 missing_upstreams[info.upstream] = None
769 769
770 return dict(info_map.items() + missing_upstreams.items()) 770 return dict(info_map.items() + missing_upstreams.items())
OLDNEW
« no previous file with comments | « no previous file | git_rebase_update.py » ('j') | git_rebase_update.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698