Chromium Code Reviews| 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 15 matching lines...) Expand all Loading... | |
| 26 try: | 26 try: |
| 27 import json | 27 import json |
| 28 except ImportError: | 28 except ImportError: |
| 29 json = None | 29 json = None |
| 30 | 30 |
| 31 try: | 31 try: |
| 32 import breakpad | 32 import breakpad |
| 33 except ImportError: | 33 except ImportError: |
| 34 pass | 34 pass |
| 35 | 35 |
| 36 # We try to use gcl.py's GetCodeReviewSettings function if available. | |
| 37 GclGetCodeReviewSetting = None | |
|
M-A Ruel
2010/10/06 23:43:18
I'd prefer gcl = None and use if gcl: return gcl.G
Jói
2010/10/06 23:54:03
Done.
| |
| 38 try: | |
| 39 import gcl | |
| 40 GclGetCodeReviewSetting = gcl.GetCodeReviewSetting | |
| 41 except: | |
|
M-A Ruel
2010/10/06 23:43:18
except ImportError:
Jói
2010/10/06 23:54:03
Done.
| |
| 42 pass | |
| 43 | |
| 36 import gclient_utils | 44 import gclient_utils |
| 37 import scm | 45 import scm |
| 38 | 46 |
| 39 __version__ = '1.2' | 47 __version__ = '1.2' |
| 40 | 48 |
| 41 | 49 |
| 42 # Constants | 50 # Constants |
| 43 HELP_STRING = "Sorry, Tryserver is not available." | 51 HELP_STRING = "Sorry, Tryserver is not available." |
| 44 USAGE = r"""%prog [options] | 52 USAGE = r"""%prog [options] |
| 45 | 53 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 99 self.codereview_settings_file = 'codereview.settings' | 107 self.codereview_settings_file = 'codereview.settings' |
| 100 self.gclient_root = None | 108 self.gclient_root = None |
| 101 | 109 |
| 102 def GetFileNames(self): | 110 def GetFileNames(self): |
| 103 """Return the list of files in the diff.""" | 111 """Return the list of files in the diff.""" |
| 104 return self.files | 112 return self.files |
| 105 | 113 |
| 106 def GetCodeReviewSetting(self, key): | 114 def GetCodeReviewSetting(self, key): |
| 107 """Returns a value for the given key for this repository. | 115 """Returns a value for the given key for this repository. |
| 108 | 116 |
| 109 Uses gcl-style settings from the repository.""" | 117 Uses gcl-style settings from the repository. |
| 110 if self.codereview_settings is None: | 118 """ |
| 111 self.codereview_settings = {} | 119 if GclGetCodeReviewSetting: |
| 112 settings_file = self.ReadRootFile(self.codereview_settings_file) | 120 return GclGetCodeReviewSetting(key) |
| 113 if settings_file: | 121 else: |
| 114 for line in settings_file.splitlines(): | 122 if self.codereview_settings is None: |
| 115 if not line or line.lstrip().startswith('#'): | 123 self.codereview_settings = {} |
| 116 continue | 124 settings_file = self.ReadRootFile(self.codereview_settings_file) |
| 117 k, v = line.split(":", 1) | 125 if settings_file: |
| 118 self.codereview_settings[k.strip()] = v.strip() | 126 for line in settings_file.splitlines(): |
| 119 return self.codereview_settings.get(key, '') | 127 if not line or line.lstrip().startswith('#'): |
| 128 continue | |
| 129 k, v = line.split(":", 1) | |
| 130 self.codereview_settings[k.strip()] = v.strip() | |
| 131 return self.codereview_settings.get(key, '') | |
| 120 | 132 |
| 121 def _GclStyleSettings(self): | 133 def _GclStyleSettings(self): |
| 122 """Set default settings based on the gcl-style settings from the | 134 """Set default settings based on the gcl-style settings from the |
| 123 repository.""" | 135 repository.""" |
| 124 settings = { | 136 settings = { |
| 125 'port': self.GetCodeReviewSetting('TRYSERVER_HTTP_PORT'), | 137 'port': self.GetCodeReviewSetting('TRYSERVER_HTTP_PORT'), |
| 126 'host': self.GetCodeReviewSetting('TRYSERVER_HTTP_HOST'), | 138 'host': self.GetCodeReviewSetting('TRYSERVER_HTTP_HOST'), |
| 127 'svn_repo': self.GetCodeReviewSetting('TRYSERVER_SVN_URL'), | 139 'svn_repo': self.GetCodeReviewSetting('TRYSERVER_SVN_URL'), |
| 128 'project': self.GetCodeReviewSetting('TRYSERVER_PROJECT'), | 140 'project': self.GetCodeReviewSetting('TRYSERVER_PROJECT'), |
| 129 'root': self.GetCodeReviewSetting('TRYSERVER_ROOT'), | 141 'root': self.GetCodeReviewSetting('TRYSERVER_ROOT'), |
| (...skipping 605 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 735 except (InvalidScript, NoTryServerAccess), e: | 747 except (InvalidScript, NoTryServerAccess), e: |
| 736 if swallow_exception: | 748 if swallow_exception: |
| 737 return 1 | 749 return 1 |
| 738 print e | 750 print e |
| 739 return 1 | 751 return 1 |
| 740 return 0 | 752 return 0 |
| 741 | 753 |
| 742 | 754 |
| 743 if __name__ == "__main__": | 755 if __name__ == "__main__": |
| 744 sys.exit(TryChange(None, [], False)) | 756 sys.exit(TryChange(None, [], False)) |
| OLD | NEW |