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

Side by Side Diff: git_cl.py

Issue 1835923002: Revert of Use tracking remote name for gerrit upload. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: 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 | « no previous file | no next file » | 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 (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 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 # Copyright (C) 2008 Evan Martin <martine@danga.com> 6 # Copyright (C) 2008 Evan Martin <martine@danga.com>
7 7
8 """A git-command for integrating reviews on Rietveld and Gerrit.""" 8 """A git-command for integrating reviews on Rietveld and Gerrit."""
9 9
10 from distutils.version import LooseVersion 10 from distutils.version import LooseVersion
(...skipping 2440 matching lines...) Expand 10 before | Expand all | Expand 10 after
2451 # whitespace. This code is not doing this, but it clearly won't decrease 2451 # whitespace. This code is not doing this, but it clearly won't decrease
2452 # entropy. 2452 # entropy.
2453 lines.append(message) 2453 lines.append(message)
2454 change_hash = RunCommand(['git', 'hash-object', '-t', 'commit', '--stdin'], 2454 change_hash = RunCommand(['git', 'hash-object', '-t', 'commit', '--stdin'],
2455 stdin='\n'.join(lines)) 2455 stdin='\n'.join(lines))
2456 return 'I%s' % change_hash.strip() 2456 return 'I%s' % change_hash.strip()
2457 2457
2458 2458
2459 def GerritUpload(options, args, cl, change): 2459 def GerritUpload(options, args, cl, change):
2460 """upload the current branch to gerrit.""" 2460 """upload the current branch to gerrit."""
2461 # We assume the remote called "origin" is the one we want.
2462 # It is probably not worthwhile to support different workflows.
2463 gerrit_remote = 'origin'
2464
2461 remote, remote_branch = cl.GetRemoteBranch() 2465 remote, remote_branch = cl.GetRemoteBranch()
tandrii(chromium) 2016/03/28 15:44:37 alokp@ I think the right fix is to actually check
2462 branch = GetTargetRef(remote, remote_branch, options.target_branch, 2466 branch = GetTargetRef(remote, remote_branch, options.target_branch,
2463 pending_prefix='') 2467 pending_prefix='')
2464 2468
2465 change_desc = ChangeDescription( 2469 change_desc = ChangeDescription(
2466 options.message or CreateDescriptionFromLog(args)) 2470 options.message or CreateDescriptionFromLog(args))
2467 if not change_desc.description: 2471 if not change_desc.description:
2468 print "\nDescription is empty. Aborting..." 2472 print "\nDescription is empty. Aborting..."
2469 return 1 2473 return 1
2470 2474
2471 if options.title: 2475 if options.title:
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
2512 parent = cl.GetCommonAncestorWithUpstream() 2516 parent = cl.GetCommonAncestorWithUpstream()
2513 2517
2514 tree = RunGit(['rev-parse', 'HEAD:']).strip() 2518 tree = RunGit(['rev-parse', 'HEAD:']).strip()
2515 ref_to_push = RunGit(['commit-tree', tree, '-p', parent, 2519 ref_to_push = RunGit(['commit-tree', tree, '-p', parent,
2516 '-m', message]).strip() 2520 '-m', message]).strip()
2517 else: 2521 else:
2518 if not git_footers.get_footer_change_id(change_desc.description): 2522 if not git_footers.get_footer_change_id(change_desc.description):
2519 DownloadGerritHook(False) 2523 DownloadGerritHook(False)
2520 change_desc.set_description(AddChangeIdToCommitMessage(options, args)) 2524 change_desc.set_description(AddChangeIdToCommitMessage(options, args))
2521 ref_to_push = 'HEAD' 2525 ref_to_push = 'HEAD'
2522 parent = '%s/%s' % (remote, branch) 2526 parent = '%s/%s' % (gerrit_remote, branch)
2523 change_id = git_footers.get_footer_change_id(change_desc.description)[0] 2527 change_id = git_footers.get_footer_change_id(change_desc.description)[0]
2524 2528
2525 commits = RunGitSilent(['rev-list', '%s..%s' % (parent, 2529 commits = RunGitSilent(['rev-list', '%s..%s' % (parent,
2526 ref_to_push)]).splitlines() 2530 ref_to_push)]).splitlines()
2527 if len(commits) > 1: 2531 if len(commits) > 1:
2528 print('WARNING: This will upload %d commits. Run the following command ' 2532 print('WARNING: This will upload %d commits. Run the following command '
2529 'to see which commits will be uploaded: ' % len(commits)) 2533 'to see which commits will be uploaded: ' % len(commits))
2530 print('git log %s..%s' % (parent, ref_to_push)) 2534 print('git log %s..%s' % (parent, ref_to_push))
2531 print('You can also use `git squash-branch` to squash these into a single ' 2535 print('You can also use `git squash-branch` to squash these into a single '
2532 'commit.') 2536 'commit.')
(...skipping 10 matching lines...) Expand all
2543 if cc: 2547 if cc:
2544 receive_options += ['--cc=' + email for email in cc] 2548 receive_options += ['--cc=' + email for email in cc]
2545 if change_desc.get_reviewers(): 2549 if change_desc.get_reviewers():
2546 receive_options.extend( 2550 receive_options.extend(
2547 '--reviewer=' + email for email in change_desc.get_reviewers()) 2551 '--reviewer=' + email for email in change_desc.get_reviewers())
2548 2552
2549 git_command = ['push'] 2553 git_command = ['push']
2550 if receive_options: 2554 if receive_options:
2551 git_command.append('--receive-pack=git receive-pack %s' % 2555 git_command.append('--receive-pack=git receive-pack %s' %
2552 ' '.join(receive_options)) 2556 ' '.join(receive_options))
2553 git_command += [remote, ref_to_push + ':refs/for/' + branch] 2557 git_command += [gerrit_remote, ref_to_push + ':refs/for/' + branch]
2554 push_stdout = gclient_utils.CheckCallAndFilter( 2558 push_stdout = gclient_utils.CheckCallAndFilter(
2555 ['git'] + git_command, 2559 ['git'] + git_command,
2556 print_stdout=True, 2560 print_stdout=True,
2557 # Flush after every line: useful for seeing progress when running as 2561 # Flush after every line: useful for seeing progress when running as
2558 # recipe. 2562 # recipe.
2559 filter_fn=lambda _: sys.stdout.flush()) 2563 filter_fn=lambda _: sys.stdout.flush())
2560 2564
2561 if options.squash: 2565 if options.squash:
2562 regex = re.compile(r'remote:\s+https?://[\w\-\.\/]*/(\d+)\s.*') 2566 regex = re.compile(r'remote:\s+https?://[\w\-\.\/]*/(\d+)\s.*')
2563 change_numbers = [m.group(1) 2567 change_numbers = [m.group(1)
(...skipping 1698 matching lines...) Expand 10 before | Expand all | Expand 10 after
4262 if __name__ == '__main__': 4266 if __name__ == '__main__':
4263 # These affect sys.stdout so do it outside of main() to simplify mocks in 4267 # These affect sys.stdout so do it outside of main() to simplify mocks in
4264 # unit testing. 4268 # unit testing.
4265 fix_encoding.fix_encoding() 4269 fix_encoding.fix_encoding()
4266 colorama.init() 4270 colorama.init()
4267 try: 4271 try:
4268 sys.exit(main(sys.argv[1:])) 4272 sys.exit(main(sys.argv[1:]))
4269 except KeyboardInterrupt: 4273 except KeyboardInterrupt:
4270 sys.stderr.write('interrupted\n') 4274 sys.stderr.write('interrupted\n')
4271 sys.exit(1) 4275 sys.exit(1)
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698