| 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 __future__ import print_function | 10 from __future__ import print_function | 
| (...skipping 752 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 763 | 763 | 
| 764   def GetIsGerrit(self): | 764   def GetIsGerrit(self): | 
| 765     """Return true if this repo is assosiated with gerrit code review system.""" | 765     """Return true if this repo is assosiated with gerrit code review system.""" | 
| 766     if self.is_gerrit is None: | 766     if self.is_gerrit is None: | 
| 767       self.is_gerrit = self._GetConfig('gerrit.host', error_ok=True) | 767       self.is_gerrit = self._GetConfig('gerrit.host', error_ok=True) | 
| 768     return self.is_gerrit | 768     return self.is_gerrit | 
| 769 | 769 | 
| 770   def GetSquashGerritUploads(self): | 770   def GetSquashGerritUploads(self): | 
| 771     """Return true if uploads to Gerrit should be squashed by default.""" | 771     """Return true if uploads to Gerrit should be squashed by default.""" | 
| 772     if self.squash_gerrit_uploads is None: | 772     if self.squash_gerrit_uploads is None: | 
| 773       self.squash_gerrit_uploads = ( | 773       self.squash_gerrit_uploads = self.GetSquashGerritUploadsOverride() | 
| 774           RunGit(['config', '--bool', 'gerrit.squash-uploads'], | 774       if self.squash_gerrit_uploads is None: | 
| 775                  error_ok=True).strip() == 'true') | 775         # Default is squash now (http://crbug.com/611892#c23). | 
|  | 776         self.squash_gerrit_uploads = not ( | 
|  | 777             RunGit(['config', '--bool', 'gerrit.squash-uploads'], | 
|  | 778                    error_ok=True).strip() == 'false') | 
| 776     return self.squash_gerrit_uploads | 779     return self.squash_gerrit_uploads | 
| 777 | 780 | 
|  | 781   def GetSquashGerritUploadsOverride(self): | 
|  | 782     """Return True or False if codereview.settings should be overridden. | 
|  | 783 | 
|  | 784     Returns None if no override has been defined. | 
|  | 785     """ | 
|  | 786     # See also http://crbug.com/611892#c23 | 
|  | 787     result = RunGit(['config', '--bool', 'gerrit.override-squash-uploads'], | 
|  | 788                     error_ok=True).strip() | 
|  | 789     if result == 'true': | 
|  | 790       return True | 
|  | 791     if result == 'false': | 
|  | 792       return False | 
|  | 793     return None | 
|  | 794 | 
| 778   def GetGerritSkipEnsureAuthenticated(self): | 795   def GetGerritSkipEnsureAuthenticated(self): | 
| 779     """Return True if EnsureAuthenticated should not be done for Gerrit | 796     """Return True if EnsureAuthenticated should not be done for Gerrit | 
| 780     uploads.""" | 797     uploads.""" | 
| 781     if self.gerrit_skip_ensure_authenticated is None: | 798     if self.gerrit_skip_ensure_authenticated is None: | 
| 782       self.gerrit_skip_ensure_authenticated = ( | 799       self.gerrit_skip_ensure_authenticated = ( | 
| 783           RunGit(['config', '--bool', 'gerrit.skip-ensure-authenticated'], | 800           RunGit(['config', '--bool', 'gerrit.skip-ensure-authenticated'], | 
| 784                  error_ok=True).strip() == 'true') | 801                  error_ok=True).strip() == 'true') | 
| 785     return self.gerrit_skip_ensure_authenticated | 802     return self.gerrit_skip_ensure_authenticated | 
| 786 | 803 | 
| 787   def GetGitEditor(self): | 804   def GetGitEditor(self): | 
| (...skipping 1543 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 2331       if reply.lower().startswith('y'): | 2348       if reply.lower().startswith('y'): | 
| 2332         gclient_utils.rm_file_or_tree(hook) | 2349         gclient_utils.rm_file_or_tree(hook) | 
| 2333         print('Gerrit commit-msg hook removed.') | 2350         print('Gerrit commit-msg hook removed.') | 
| 2334       else: | 2351       else: | 
| 2335         print('OK, will keep Gerrit commit-msg hook in place.') | 2352         print('OK, will keep Gerrit commit-msg hook in place.') | 
| 2336 | 2353 | 
| 2337   def CMDUploadChange(self, options, args, change): | 2354   def CMDUploadChange(self, options, args, change): | 
| 2338     """Upload the current branch to Gerrit.""" | 2355     """Upload the current branch to Gerrit.""" | 
| 2339     if options.squash and options.no_squash: | 2356     if options.squash and options.no_squash: | 
| 2340       DieWithError('Can only use one of --squash or --no-squash') | 2357       DieWithError('Can only use one of --squash or --no-squash') | 
| 2341     options.squash = ((settings.GetSquashGerritUploads() or options.squash) and | 2358 | 
| 2342                       not options.no_squash) | 2359     if not options.squash and not options.no_squash: | 
|  | 2360       # Load default for user, repo, squash=true, in this order. | 
|  | 2361       options.squash = settings.GetSquashGerritUploads() | 
|  | 2362     elif options.no_squash: | 
|  | 2363       options.squash = False | 
| 2343 | 2364 | 
| 2344     # We assume the remote called "origin" is the one we want. | 2365     # We assume the remote called "origin" is the one we want. | 
| 2345     # It is probably not worthwhile to support different workflows. | 2366     # It is probably not worthwhile to support different workflows. | 
| 2346     gerrit_remote = 'origin' | 2367     gerrit_remote = 'origin' | 
| 2347 | 2368 | 
| 2348     remote, remote_branch = self.GetRemoteBranch() | 2369     remote, remote_branch = self.GetRemoteBranch() | 
| 2349     branch = GetTargetRef(remote, remote_branch, options.target_branch, | 2370     branch = GetTargetRef(remote, remote_branch, options.target_branch, | 
| 2350                           pending_prefix='') | 2371                           pending_prefix='') | 
| 2351 | 2372 | 
| 2352     if options.squash: | 2373     if options.squash: | 
| (...skipping 2667 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 5020 if __name__ == '__main__': | 5041 if __name__ == '__main__': | 
| 5021   # These affect sys.stdout so do it outside of main() to simplify mocks in | 5042   # These affect sys.stdout so do it outside of main() to simplify mocks in | 
| 5022   # unit testing. | 5043   # unit testing. | 
| 5023   fix_encoding.fix_encoding() | 5044   fix_encoding.fix_encoding() | 
| 5024   setup_color.init() | 5045   setup_color.init() | 
| 5025   try: | 5046   try: | 
| 5026     sys.exit(main(sys.argv[1:])) | 5047     sys.exit(main(sys.argv[1:])) | 
| 5027   except KeyboardInterrupt: | 5048   except KeyboardInterrupt: | 
| 5028     sys.stderr.write('interrupted\n') | 5049     sys.stderr.write('interrupted\n') | 
| 5029     sys.exit(1) | 5050     sys.exit(1) | 
| OLD | NEW | 
|---|