| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # Copyright (c) 2009 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2009 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 """Client-side script to send a try job to the try server. It communicates to | 5 """Client-side script to send a try job to the try server. It communicates to |
| 6 the try server by either writting to a svn repository or by directly connecting | 6 the try server by either writting to a svn repository or by directly connecting |
| 7 to the server by HTTP. | 7 to the server by HTTP. |
| 8 """ | 8 """ |
| 9 | 9 |
| 10 import datetime | 10 import datetime |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 def GetFileNames(self): | 107 def GetFileNames(self): |
| 108 """Return the list of files in the diff.""" | 108 """Return the list of files in the diff.""" |
| 109 return self.files | 109 return self.files |
| 110 | 110 |
| 111 def GetCodeReviewSetting(self, key): | 111 def GetCodeReviewSetting(self, key): |
| 112 """Returns a value for the given key for this repository. | 112 """Returns a value for the given key for this repository. |
| 113 | 113 |
| 114 Uses gcl-style settings from the repository. | 114 Uses gcl-style settings from the repository. |
| 115 """ | 115 """ |
| 116 if gcl: | 116 if gcl: |
| 117 return gcl.GetCodeReviewSetting(key) | 117 gcl_setting = gcl.GetCodeReviewSetting(key) |
| 118 else: | 118 if gcl_setting != '': |
| 119 if self.codereview_settings is None: | 119 return gcl_setting |
| 120 self.codereview_settings = {} | 120 if self.codereview_settings is None: |
| 121 settings_file = self.ReadRootFile(self.codereview_settings_file) | 121 self.codereview_settings = {} |
| 122 if settings_file: | 122 settings_file = self.ReadRootFile(self.codereview_settings_file) |
| 123 for line in settings_file.splitlines(): | 123 if settings_file: |
| 124 if not line or line.lstrip().startswith('#'): | 124 for line in settings_file.splitlines(): |
| 125 continue | 125 if not line or line.lstrip().startswith('#'): |
| 126 k, v = line.split(":", 1) | 126 continue |
| 127 self.codereview_settings[k.strip()] = v.strip() | 127 k, v = line.split(":", 1) |
| 128 return self.codereview_settings.get(key, '') | 128 self.codereview_settings[k.strip()] = v.strip() |
| 129 return self.codereview_settings.get(key, '') |
| 129 | 130 |
| 130 def _GclStyleSettings(self): | 131 def _GclStyleSettings(self): |
| 131 """Set default settings based on the gcl-style settings from the | 132 """Set default settings based on the gcl-style settings from the |
| 132 repository.""" | 133 repository.""" |
| 133 settings = { | 134 settings = { |
| 134 'port': self.GetCodeReviewSetting('TRYSERVER_HTTP_PORT'), | 135 'port': self.GetCodeReviewSetting('TRYSERVER_HTTP_PORT'), |
| 135 'host': self.GetCodeReviewSetting('TRYSERVER_HTTP_HOST'), | 136 'host': self.GetCodeReviewSetting('TRYSERVER_HTTP_HOST'), |
| 136 'svn_repo': self.GetCodeReviewSetting('TRYSERVER_SVN_URL'), | 137 'svn_repo': self.GetCodeReviewSetting('TRYSERVER_SVN_URL'), |
| 137 'project': self.GetCodeReviewSetting('TRYSERVER_PROJECT'), | 138 'project': self.GetCodeReviewSetting('TRYSERVER_PROJECT'), |
| 138 'root': self.GetCodeReviewSetting('TRYSERVER_ROOT'), | 139 'root': self.GetCodeReviewSetting('TRYSERVER_ROOT'), |
| (...skipping 605 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 744 except (InvalidScript, NoTryServerAccess), e: | 745 except (InvalidScript, NoTryServerAccess), e: |
| 745 if swallow_exception: | 746 if swallow_exception: |
| 746 return 1 | 747 return 1 |
| 747 print e | 748 print e |
| 748 return 1 | 749 return 1 |
| 749 return 0 | 750 return 0 |
| 750 | 751 |
| 751 | 752 |
| 752 if __name__ == "__main__": | 753 if __name__ == "__main__": |
| 753 sys.exit(TryChange(None, [], False)) | 754 sys.exit(TryChange(None, [], False)) |
| OLD | NEW |