Chromium Code Reviews| 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 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 260 self.svn_branch = None | 260 self.svn_branch = None |
| 261 self.tree_status_url = None | 261 self.tree_status_url = None |
| 262 self.viewvc_url = None | 262 self.viewvc_url = None |
| 263 self.updated = False | 263 self.updated = False |
| 264 self.is_gerrit = None | 264 self.is_gerrit = None |
| 265 self.git_editor = None | 265 self.git_editor = None |
| 266 | 266 |
| 267 def LazyUpdateIfNeeded(self): | 267 def LazyUpdateIfNeeded(self): |
| 268 """Updates the settings from a codereview.settings file, if available.""" | 268 """Updates the settings from a codereview.settings file, if available.""" |
| 269 if not self.updated: | 269 if not self.updated: |
| 270 # The only value that actually changes the behavior is | |
| 271 # autoupdate = "false". Everything else means "true". | |
| 272 autoupdate = RunGit(['config', 'rietveld.autoupdate'], error_ok=True | |
|
ghost stip (do not use)
2014/01/03 20:40:21
style nit: put error_ok on the next line (+4)
| |
| 273 ).strip().lower() | |
| 274 | |
| 270 cr_settings_file = FindCodereviewSettingsFile() | 275 cr_settings_file = FindCodereviewSettingsFile() |
| 271 if cr_settings_file: | 276 if autoupdate != 'false' and cr_settings_file: |
| 272 LoadCodereviewSettingsFromFile(cr_settings_file) | 277 LoadCodereviewSettingsFromFile(cr_settings_file) |
| 278 # set updated to True to avoid infinite calling loop | |
| 279 # through DownloadHooks | |
| 273 self.updated = True | 280 self.updated = True |
| 274 DownloadHooks(False) | 281 DownloadHooks(False) |
| 275 self.updated = True | 282 self.updated = True |
| 276 | 283 |
| 277 def GetDefaultServerUrl(self, error_ok=False): | 284 def GetDefaultServerUrl(self, error_ok=False): |
| 278 if not self.default_server: | 285 if not self.default_server: |
| 279 self.LazyUpdateIfNeeded() | 286 self.LazyUpdateIfNeeded() |
| 280 self.default_server = gclient_utils.UpgradeToHttps( | 287 self.default_server = gclient_utils.UpgradeToHttps( |
| 281 self._GetConfig('rietveld.server', error_ok=True)) | 288 self._GetConfig('rietveld.server', error_ok=True)) |
| 282 if error_ok: | 289 if error_ok: |
| (...skipping 789 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1072 DieWithError('\nFailed to download hooks.\n' | 1079 DieWithError('\nFailed to download hooks.\n' |
| 1073 'You need to download from\n%s\n' | 1080 'You need to download from\n%s\n' |
| 1074 'into .git/hooks/commit-msg and ' | 1081 'into .git/hooks/commit-msg and ' |
| 1075 'chmod +x .git/hooks/commit-msg' % src) | 1082 'chmod +x .git/hooks/commit-msg' % src) |
| 1076 | 1083 |
| 1077 | 1084 |
| 1078 @subcommand.usage('[repo root containing codereview.settings]') | 1085 @subcommand.usage('[repo root containing codereview.settings]') |
| 1079 def CMDconfig(parser, args): | 1086 def CMDconfig(parser, args): |
| 1080 """Edits configuration for this tree.""" | 1087 """Edits configuration for this tree.""" |
| 1081 | 1088 |
| 1082 _, args = parser.parse_args(args) | 1089 parser.add_option('--activate-update', action='store_true', |
| 1090 help='activate auto-updating [rietveld] section in ' | |
| 1091 '.git/config') | |
| 1092 parser.add_option('--deactivate-update', action='store_true', | |
| 1093 help='deactivate auto-updating [rietveld] section in ' | |
| 1094 '.git/config') | |
| 1095 options, args = parser.parse_args(args) | |
| 1096 | |
| 1097 if options.deactivate_update: | |
| 1098 RunGit(['config', 'rietveld.autoupdate', 'false']) | |
| 1099 return | |
| 1100 | |
| 1101 if options.activate_update: | |
| 1102 RunGit(['config', '--unset', 'rietveld.autoupdate']) | |
| 1103 return | |
| 1104 | |
| 1083 if len(args) == 0: | 1105 if len(args) == 0: |
| 1084 GetCodereviewSettingsInteractively() | 1106 GetCodereviewSettingsInteractively() |
| 1085 DownloadHooks(True) | 1107 DownloadHooks(True) |
| 1086 return 0 | 1108 return 0 |
| 1087 | 1109 |
| 1088 url = args[0] | 1110 url = args[0] |
| 1089 if not url.endswith('codereview.settings'): | 1111 if not url.endswith('codereview.settings'): |
| 1090 url = os.path.join(url, 'codereview.settings') | 1112 url = os.path.join(url, 'codereview.settings') |
| 1091 | 1113 |
| 1092 # Load code review settings and download hooks (if available). | 1114 # Load code review settings and download hooks (if available). |
| (...skipping 1264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2357 ('AppEngine is misbehaving and returned HTTP %d, again. Keep faith ' | 2379 ('AppEngine is misbehaving and returned HTTP %d, again. Keep faith ' |
| 2358 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e))) | 2380 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e))) |
| 2359 | 2381 |
| 2360 | 2382 |
| 2361 if __name__ == '__main__': | 2383 if __name__ == '__main__': |
| 2362 # These affect sys.stdout so do it outside of main() to simplify mocks in | 2384 # These affect sys.stdout so do it outside of main() to simplify mocks in |
| 2363 # unit testing. | 2385 # unit testing. |
| 2364 fix_encoding.fix_encoding() | 2386 fix_encoding.fix_encoding() |
| 2365 colorama.init() | 2387 colorama.init() |
| 2366 sys.exit(main(sys.argv[1:])) | 2388 sys.exit(main(sys.argv[1:])) |
| OLD | NEW |