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 noautoupdate = RunGit(['config', 'rietveld.noautoupdate'], error_ok=True | |
271 ).strip().lower() | |
iannucci
2013/12/17 00:21:39
polarity should reverse to 'autoupdate'
| |
272 if noautoupdate == 'true': | |
273 self.updated = True | |
274 return | |
iannucci
2013/12/17 00:21:39
then this block can go away.
| |
275 | |
270 cr_settings_file = FindCodereviewSettingsFile() | 276 cr_settings_file = FindCodereviewSettingsFile() |
271 if cr_settings_file: | 277 if cr_settings_file: |
iannucci
2013/12/17 00:21:39
if autoupdate 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 789 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1072 DieWithError('\nFailed to download hooks.\n' | 1080 DieWithError('\nFailed to download hooks.\n' |
1073 'You need to download from\n%s\n' | 1081 'You need to download from\n%s\n' |
1074 'into .git/hooks/commit-msg and ' | 1082 'into .git/hooks/commit-msg and ' |
1075 'chmod +x .git/hooks/commit-msg' % src) | 1083 'chmod +x .git/hooks/commit-msg' % src) |
1076 | 1084 |
1077 | 1085 |
1078 @subcommand.usage('[repo root containing codereview.settings]') | 1086 @subcommand.usage('[repo root containing codereview.settings]') |
1079 def CMDconfig(parser, args): | 1087 def CMDconfig(parser, args): |
1080 """Edits configuration for this tree.""" | 1088 """Edits configuration for this tree.""" |
1081 | 1089 |
1082 _, args = parser.parse_args(args) | 1090 parser.add_option('--activate-update', action='store_true', |
1091 help='activate auto-updating [rietveld] section in ' | |
1092 '.git/config') | |
ghost stip (do not use)
2013/12/16 19:20:23
align '.git with 'activate
| |
1093 parser.add_option('--deactivate-update', action='store_true', | |
iannucci
2013/12/17 00:21:39
Hm... I think these should both have dest='activat
| |
1094 help='deactivate auto-updating [rietveld] section in ' | |
1095 '.git/config') | |
ghost stip (do not use)
2013/12/16 19:20:23
same
| |
1096 options, args = parser.parse_args(args) | |
1097 | |
1098 if options.deactivate_update: | |
1099 RunGit(['config', 'rietveld.noautoupdate', 'true']) | |
iannucci
2013/12/17 00:21:39
option should be rietveld.autoupdate
| |
1100 return | |
1101 | |
1102 if options.activate_update: | |
1103 RunGit(['config', '--unset', 'rietveld.noautoupdate']) | |
1104 return | |
1105 | |
1083 if len(args) == 0: | 1106 if len(args) == 0: |
1084 GetCodereviewSettingsInteractively() | 1107 GetCodereviewSettingsInteractively() |
1085 DownloadHooks(True) | 1108 DownloadHooks(True) |
1086 return 0 | 1109 return 0 |
1087 | 1110 |
1088 url = args[0] | 1111 url = args[0] |
1089 if not url.endswith('codereview.settings'): | 1112 if not url.endswith('codereview.settings'): |
1090 url = os.path.join(url, 'codereview.settings') | 1113 url = os.path.join(url, 'codereview.settings') |
1091 | 1114 |
1092 # Load code review settings and download hooks (if available). | 1115 # 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 ' | 2380 ('AppEngine is misbehaving and returned HTTP %d, again. Keep faith ' |
2358 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e))) | 2381 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e))) |
2359 | 2382 |
2360 | 2383 |
2361 if __name__ == '__main__': | 2384 if __name__ == '__main__': |
2362 # These affect sys.stdout so do it outside of main() to simplify mocks in | 2385 # These affect sys.stdout so do it outside of main() to simplify mocks in |
2363 # unit testing. | 2386 # unit testing. |
2364 fix_encoding.fix_encoding() | 2387 fix_encoding.fix_encoding() |
2365 colorama.init() | 2388 colorama.init() |
2366 sys.exit(main(sys.argv[1:])) | 2389 sys.exit(main(sys.argv[1:])) |
OLD | NEW |