OLD | NEW |
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 2142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2153 | 2153 |
2154 if not dependents: | 2154 if not dependents: |
2155 print 'There are no dependent local branches for %s' % root_branch | 2155 print 'There are no dependent local branches for %s' % root_branch |
2156 return 0 | 2156 return 0 |
2157 | 2157 |
2158 print ('This command will checkout all dependent branches and run ' | 2158 print ('This command will checkout all dependent branches and run ' |
2159 '"git cl upload".') | 2159 '"git cl upload".') |
2160 ask_for_data('[Press enter to continue or ctrl-C to quit]') | 2160 ask_for_data('[Press enter to continue or ctrl-C to quit]') |
2161 | 2161 |
2162 # Add a default patchset title to all upload calls in Rietveld. | 2162 # Add a default patchset title to all upload calls in Rietveld. |
2163 if not settings.GetIsGerrit(): | 2163 if not cl.IsGerrit(): |
2164 args.extend(['-t', 'Updated patchset dependency']) | 2164 args.extend(['-t', 'Updated patchset dependency']) |
2165 | 2165 |
2166 # Record all dependents that failed to upload. | 2166 # Record all dependents that failed to upload. |
2167 failures = {} | 2167 failures = {} |
2168 # Go through all dependents, checkout the branch and upload. | 2168 # Go through all dependents, checkout the branch and upload. |
2169 try: | 2169 try: |
2170 for dependent_branch in dependents: | 2170 for dependent_branch in dependents: |
2171 print | 2171 print |
2172 print '--------------------------------------' | 2172 print '--------------------------------------' |
2173 print 'Running "git cl upload" from %s:' % dependent_branch | 2173 print 'Running "git cl upload" from %s:' % dependent_branch |
(...skipping 887 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3061 if cl.GetBranch() is None: | 3061 if cl.GetBranch() is None: |
3062 DieWithError('Can\'t upload from detached HEAD state. Get on a branch!') | 3062 DieWithError('Can\'t upload from detached HEAD state. Get on a branch!') |
3063 | 3063 |
3064 # Default to diffing against common ancestor of upstream branch | 3064 # Default to diffing against common ancestor of upstream branch |
3065 base_branch = cl.GetCommonAncestorWithUpstream() | 3065 base_branch = cl.GetCommonAncestorWithUpstream() |
3066 args = [base_branch, 'HEAD'] | 3066 args = [base_branch, 'HEAD'] |
3067 | 3067 |
3068 # Make sure authenticated to Rietveld before running expensive hooks. It is | 3068 # Make sure authenticated to Rietveld before running expensive hooks. It is |
3069 # a fast, best efforts check. Rietveld still can reject the authentication | 3069 # a fast, best efforts check. Rietveld still can reject the authentication |
3070 # during the actual upload. | 3070 # during the actual upload. |
3071 if not settings.GetIsGerrit() and auth_config.use_oauth2: | 3071 if not cl.IsGerrit() and auth_config.use_oauth2: |
3072 authenticator = auth.get_authenticator_for_host( | 3072 authenticator = auth.get_authenticator_for_host( |
3073 cl.GetCodereviewServer(), auth_config) | 3073 cl.GetCodereviewServer(), auth_config) |
3074 if not authenticator.has_cached_credentials(): | 3074 if not authenticator.has_cached_credentials(): |
3075 raise auth.LoginRequiredError(cl.GetCodereviewServer()) | 3075 raise auth.LoginRequiredError(cl.GetCodereviewServer()) |
3076 | 3076 |
3077 # Apply watchlists on upload. | 3077 # Apply watchlists on upload. |
3078 change = cl.GetChange(base_branch, None) | 3078 change = cl.GetChange(base_branch, None) |
3079 watchlist = watchlists.Watchlists(change.RepositoryRoot()) | 3079 watchlist = watchlists.Watchlists(change.RepositoryRoot()) |
3080 files = [f.LocalPath() for f in change.AffectedFiles()] | 3080 files = [f.LocalPath() for f in change.AffectedFiles()] |
3081 if not options.bypass_watchlists: | 3081 if not options.bypass_watchlists: |
(...skipping 22 matching lines...) Expand all Loading... |
3104 if latest_patchset and local_patchset and local_patchset != latest_patchset: | 3104 if latest_patchset and local_patchset and local_patchset != latest_patchset: |
3105 print ('The last upload made from this repository was patchset #%d but ' | 3105 print ('The last upload made from this repository was patchset #%d but ' |
3106 'the most recent patchset on the server is #%d.' | 3106 'the most recent patchset on the server is #%d.' |
3107 % (local_patchset, latest_patchset)) | 3107 % (local_patchset, latest_patchset)) |
3108 print ('Uploading will still work, but if you\'ve uploaded to this issue ' | 3108 print ('Uploading will still work, but if you\'ve uploaded to this issue ' |
3109 'from another machine or branch the patch you\'re uploading now ' | 3109 'from another machine or branch the patch you\'re uploading now ' |
3110 'might not include those changes.') | 3110 'might not include those changes.') |
3111 ask_for_data('About to upload; enter to confirm.') | 3111 ask_for_data('About to upload; enter to confirm.') |
3112 | 3112 |
3113 print_stats(options.similarity, options.find_copies, args) | 3113 print_stats(options.similarity, options.find_copies, args) |
3114 if settings.GetIsGerrit(): | 3114 if cl.IsGerrit(): |
3115 if options.squash and options.no_squash: | 3115 if options.squash and options.no_squash: |
3116 DieWithError('Can only use one of --squash or --no-squash') | 3116 DieWithError('Can only use one of --squash or --no-squash') |
3117 | 3117 |
3118 options.squash = ((settings.GetSquashGerritUploads() or options.squash) and | 3118 options.squash = ((settings.GetSquashGerritUploads() or options.squash) and |
3119 not options.no_squash) | 3119 not options.no_squash) |
3120 | 3120 |
3121 ret = GerritUpload(options, args, cl, change) | 3121 ret = GerritUpload(options, args, cl, change) |
3122 else: | 3122 else: |
3123 ret = RietveldUpload(options, args, cl, change) | 3123 ret = RietveldUpload(options, args, cl, change) |
3124 if not ret: | 3124 if not ret: |
(...skipping 1352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4477 if __name__ == '__main__': | 4477 if __name__ == '__main__': |
4478 # These affect sys.stdout so do it outside of main() to simplify mocks in | 4478 # These affect sys.stdout so do it outside of main() to simplify mocks in |
4479 # unit testing. | 4479 # unit testing. |
4480 fix_encoding.fix_encoding() | 4480 fix_encoding.fix_encoding() |
4481 colorama.init() | 4481 colorama.init() |
4482 try: | 4482 try: |
4483 sys.exit(main(sys.argv[1:])) | 4483 sys.exit(main(sys.argv[1:])) |
4484 except KeyboardInterrupt: | 4484 except KeyboardInterrupt: |
4485 sys.stderr.write('interrupted\n') | 4485 sys.stderr.write('interrupted\n') |
4486 sys.exit(1) | 4486 sys.exit(1) |
OLD | NEW |