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'], |
| 273 error_ok=True |
| 274 ).strip().lower() |
| 275 |
270 cr_settings_file = FindCodereviewSettingsFile() | 276 cr_settings_file = FindCodereviewSettingsFile() |
271 if cr_settings_file: | 277 if autoupdate != 'false' and cr_settings_file: |
272 LoadCodereviewSettingsFromFile(cr_settings_file) | 278 LoadCodereviewSettingsFromFile(cr_settings_file) |
| 279 # set updated to True to avoid infinite calling loop |
| 280 # through DownloadHooks |
273 self.updated = True | 281 self.updated = True |
274 DownloadHooks(False) | 282 DownloadHooks(False) |
275 self.updated = True | 283 self.updated = True |
276 | 284 |
277 def GetDefaultServerUrl(self, error_ok=False): | 285 def GetDefaultServerUrl(self, error_ok=False): |
278 if not self.default_server: | 286 if not self.default_server: |
279 self.LazyUpdateIfNeeded() | 287 self.LazyUpdateIfNeeded() |
280 self.default_server = gclient_utils.UpgradeToHttps( | 288 self.default_server = gclient_utils.UpgradeToHttps( |
281 self._GetConfig('rietveld.server', error_ok=True)) | 289 self._GetConfig('rietveld.server', error_ok=True)) |
282 if error_ok: | 290 if error_ok: |
(...skipping 794 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1077 DieWithError('\nFailed to download hooks.\n' | 1085 DieWithError('\nFailed to download hooks.\n' |
1078 'You need to download from\n%s\n' | 1086 'You need to download from\n%s\n' |
1079 'into .git/hooks/commit-msg and ' | 1087 'into .git/hooks/commit-msg and ' |
1080 'chmod +x .git/hooks/commit-msg' % src) | 1088 'chmod +x .git/hooks/commit-msg' % src) |
1081 | 1089 |
1082 | 1090 |
1083 @subcommand.usage('[repo root containing codereview.settings]') | 1091 @subcommand.usage('[repo root containing codereview.settings]') |
1084 def CMDconfig(parser, args): | 1092 def CMDconfig(parser, args): |
1085 """Edits configuration for this tree.""" | 1093 """Edits configuration for this tree.""" |
1086 | 1094 |
1087 _, args = parser.parse_args(args) | 1095 parser.add_option('--activate-update', action='store_true', |
| 1096 help='activate auto-updating [rietveld] section in ' |
| 1097 '.git/config') |
| 1098 parser.add_option('--deactivate-update', action='store_true', |
| 1099 help='deactivate auto-updating [rietveld] section in ' |
| 1100 '.git/config') |
| 1101 options, args = parser.parse_args(args) |
| 1102 |
| 1103 if options.deactivate_update: |
| 1104 RunGit(['config', 'rietveld.autoupdate', 'false']) |
| 1105 return |
| 1106 |
| 1107 if options.activate_update: |
| 1108 RunGit(['config', '--unset', 'rietveld.autoupdate']) |
| 1109 return |
| 1110 |
1088 if len(args) == 0: | 1111 if len(args) == 0: |
1089 GetCodereviewSettingsInteractively() | 1112 GetCodereviewSettingsInteractively() |
1090 DownloadHooks(True) | 1113 DownloadHooks(True) |
1091 return 0 | 1114 return 0 |
1092 | 1115 |
1093 url = args[0] | 1116 url = args[0] |
1094 if not url.endswith('codereview.settings'): | 1117 if not url.endswith('codereview.settings'): |
1095 url = os.path.join(url, 'codereview.settings') | 1118 url = os.path.join(url, 'codereview.settings') |
1096 | 1119 |
1097 # Load code review settings and download hooks (if available). | 1120 # Load code review settings and download hooks (if available). |
(...skipping 1275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2373 ('AppEngine is misbehaving and returned HTTP %d, again. Keep faith ' | 2396 ('AppEngine is misbehaving and returned HTTP %d, again. Keep faith ' |
2374 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e))) | 2397 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e))) |
2375 | 2398 |
2376 | 2399 |
2377 if __name__ == '__main__': | 2400 if __name__ == '__main__': |
2378 # These affect sys.stdout so do it outside of main() to simplify mocks in | 2401 # These affect sys.stdout so do it outside of main() to simplify mocks in |
2379 # unit testing. | 2402 # unit testing. |
2380 fix_encoding.fix_encoding() | 2403 fix_encoding.fix_encoding() |
2381 colorama.init() | 2404 colorama.init() |
2382 sys.exit(main(sys.argv[1:])) | 2405 sys.exit(main(sys.argv[1:])) |
OLD | NEW |