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.""" | 8 """A git-command for integrating reviews on Rietveld.""" |
9 | 9 |
10 from distutils.version import LooseVersion | 10 from distutils.version import LooseVersion |
(...skipping 582 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
593 if not self.updated: | 593 if not self.updated: |
594 # The only value that actually changes the behavior is | 594 # The only value that actually changes the behavior is |
595 # autoupdate = "false". Everything else means "true". | 595 # autoupdate = "false". Everything else means "true". |
596 autoupdate = RunGit(['config', 'rietveld.autoupdate'], | 596 autoupdate = RunGit(['config', 'rietveld.autoupdate'], |
597 error_ok=True | 597 error_ok=True |
598 ).strip().lower() | 598 ).strip().lower() |
599 | 599 |
600 cr_settings_file = FindCodereviewSettingsFile() | 600 cr_settings_file = FindCodereviewSettingsFile() |
601 if autoupdate != 'false' and cr_settings_file: | 601 if autoupdate != 'false' and cr_settings_file: |
602 LoadCodereviewSettingsFromFile(cr_settings_file) | 602 LoadCodereviewSettingsFromFile(cr_settings_file) |
603 # set updated to True to avoid infinite calling loop | |
604 # through DownloadGerritHook | |
605 self.updated = True | |
606 DownloadGerritHook(False) | |
607 self.updated = True | 603 self.updated = True |
608 | 604 |
609 def GetDefaultServerUrl(self, error_ok=False): | 605 def GetDefaultServerUrl(self, error_ok=False): |
610 if not self.default_server: | 606 if not self.default_server: |
611 self.LazyUpdateIfNeeded() | 607 self.LazyUpdateIfNeeded() |
612 self.default_server = gclient_utils.UpgradeToHttps( | 608 self.default_server = gclient_utils.UpgradeToHttps( |
613 self._GetRietveldConfig('server', error_ok=True)) | 609 self._GetRietveldConfig('server', error_ok=True)) |
614 if error_ok: | 610 if error_ok: |
615 return self.default_server | 611 return self.default_server |
616 if not self.default_server: | 612 if not self.default_server: |
(...skipping 1620 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2237 print 'Upload upstream branch ' + upstream_branch + ' first.' | 2233 print 'Upload upstream branch ' + upstream_branch + ' first.' |
2238 return 1 | 2234 return 1 |
2239 else: | 2235 else: |
2240 parent = cl.GetCommonAncestorWithUpstream() | 2236 parent = cl.GetCommonAncestorWithUpstream() |
2241 | 2237 |
2242 tree = RunGit(['rev-parse', 'HEAD:']).strip() | 2238 tree = RunGit(['rev-parse', 'HEAD:']).strip() |
2243 ref_to_push = RunGit(['commit-tree', tree, '-p', parent, | 2239 ref_to_push = RunGit(['commit-tree', tree, '-p', parent, |
2244 '-m', message]).strip() | 2240 '-m', message]).strip() |
2245 else: | 2241 else: |
2246 if not git_footers.get_footer_change_id(change_desc.description): | 2242 if not git_footers.get_footer_change_id(change_desc.description): |
| 2243 DownloadGerritHook(False) |
2247 AddChangeIdToCommitMessage(options, args) | 2244 AddChangeIdToCommitMessage(options, args) |
2248 ref_to_push = 'HEAD' | 2245 ref_to_push = 'HEAD' |
2249 parent = '%s/%s' % (gerrit_remote, branch) | 2246 parent = '%s/%s' % (gerrit_remote, branch) |
2250 | 2247 |
2251 commits = RunGitSilent(['rev-list', '%s..%s' % (parent, | 2248 commits = RunGitSilent(['rev-list', '%s..%s' % (parent, |
2252 ref_to_push)]).splitlines() | 2249 ref_to_push)]).splitlines() |
2253 if len(commits) > 1: | 2250 if len(commits) > 1: |
2254 print('WARNING: This will upload %d commits. Run the following command ' | 2251 print('WARNING: This will upload %d commits. Run the following command ' |
2255 'to see which commits will be uploaded: ' % len(commits)) | 2252 'to see which commits will be uploaded: ' % len(commits)) |
2256 print('git log %s..%s' % (parent, ref_to_push)) | 2253 print('git log %s..%s' % (parent, ref_to_push)) |
(...skipping 1707 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3964 if __name__ == '__main__': | 3961 if __name__ == '__main__': |
3965 # These affect sys.stdout so do it outside of main() to simplify mocks in | 3962 # These affect sys.stdout so do it outside of main() to simplify mocks in |
3966 # unit testing. | 3963 # unit testing. |
3967 fix_encoding.fix_encoding() | 3964 fix_encoding.fix_encoding() |
3968 colorama.init() | 3965 colorama.init() |
3969 try: | 3966 try: |
3970 sys.exit(main(sys.argv[1:])) | 3967 sys.exit(main(sys.argv[1:])) |
3971 except KeyboardInterrupt: | 3968 except KeyboardInterrupt: |
3972 sys.stderr.write('interrupted\n') | 3969 sys.stderr.write('interrupted\n') |
3973 sys.exit(1) | 3970 sys.exit(1) |
OLD | NEW |