Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: trychange.py

Issue 11571052: Fix toplevel_root parsing in trychange.py (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 """Client-side script to send a try job to the try server. It communicates to 6 """Client-side script to send a try job to the try server. It communicates to
7 the try server by either writting to a svn repository or by directly connecting 7 the try server by either writting to a svn repository or by directly connecting
8 to the server by HTTP. 8 to the server by HTTP.
9 """ 9 """
10 10
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 settings_file = self.ReadRootFile(self.codereview_settings_file) 142 settings_file = self.ReadRootFile(self.codereview_settings_file)
143 if settings_file: 143 if settings_file:
144 for line in settings_file.splitlines(): 144 for line in settings_file.splitlines():
145 if not line or line.lstrip().startswith('#'): 145 if not line or line.lstrip().startswith('#'):
146 continue 146 continue
147 k, v = line.split(":", 1) 147 k, v = line.split(":", 1)
148 self.codereview_settings[k.strip()] = v.strip() 148 self.codereview_settings[k.strip()] = v.strip()
149 return self.codereview_settings.get(key, '') 149 return self.codereview_settings.get(key, '')
150 150
151 def _GclStyleSettings(self): 151 def _GclStyleSettings(self):
152 """Set default settings based on the gcl-style settings from the 152 """Set default settings based on the gcl-style settings from the repository.
153 repository.""" 153
154 This method needs to be called after self.top_level_root has been set.
M-A Ruel 2012/12/19 13:46:12 Add an assert instead?
kjellander_chromium 2012/12/19 16:16:15 Actually I think it's a bit confusing to say it ha
155 """
154 settings = { 156 settings = {
155 'port': self.GetCodeReviewSetting('TRYSERVER_HTTP_PORT'), 157 'port': self.GetCodeReviewSetting('TRYSERVER_HTTP_PORT'),
156 'host': self.GetCodeReviewSetting('TRYSERVER_HTTP_HOST'), 158 'host': self.GetCodeReviewSetting('TRYSERVER_HTTP_HOST'),
157 'svn_repo': self.GetCodeReviewSetting('TRYSERVER_SVN_URL'), 159 'svn_repo': self.GetCodeReviewSetting('TRYSERVER_SVN_URL'),
158 'project': self.GetCodeReviewSetting('TRYSERVER_PROJECT'), 160 'project': self.GetCodeReviewSetting('TRYSERVER_PROJECT'),
159 'root': self.GetCodeReviewSetting('TRYSERVER_ROOT'), 161 'root': self.GetCodeReviewSetting('TRYSERVER_ROOT'),
160 'patchlevel': self.GetCodeReviewSetting('TRYSERVER_PATCHLEVEL'), 162 'patchlevel': self.GetCodeReviewSetting('TRYSERVER_PATCHLEVEL'),
161 } 163 }
162 logging.info('\n'.join(['%s: %s' % (k, v) 164 logging.info('\n'.join(['%s: %s' % (k, v)
163 for (k, v) in settings.iteritems() if v])) 165 for (k, v) in settings.iteritems() if v]))
164 for (k, v) in settings.iteritems(): 166 for (k, v) in settings.iteritems():
167 # Do not overwrite options already set using command line flags.
165 if v and getattr(self.options, k) is None: 168 if v and getattr(self.options, k) is None:
166 setattr(self.options, k, v) 169 setattr(self.options, k, v)
167 170
168 def AutomagicalSettings(self): 171 def AutomagicalSettings(self):
169 """Determines settings based on supported code review and checkout tools. 172 """Determines settings based on supported code review and checkout tools.
170 """ 173 """
171 self._GclStyleSettings() 174 # Try to find gclient or repo root first.
172 # Try to find gclient or repo root.
173 if not self.options.no_search: 175 if not self.options.no_search:
174 self.toplevel_root = gclient_utils.FindGclientRoot(self.checkout_root) 176 self.toplevel_root = gclient_utils.FindGclientRoot(self.checkout_root)
175 if self.toplevel_root: 177 if self.toplevel_root:
176 logging.info('Found .gclient at %s' % self.toplevel_root) 178 logging.info('Found .gclient at %s' % self.toplevel_root)
177 else: 179 else:
178 self.toplevel_root = gclient_utils.FindFileUpwards( 180 self.toplevel_root = gclient_utils.FindFileUpwards(
179 os.path.join('..', '.repo'), self.checkout_root) 181 os.path.join('..', '.repo'), self.checkout_root)
180 if self.toplevel_root: 182 if self.toplevel_root:
181 logging.info('Found .repo dir at %s' 183 logging.info('Found .repo dir at %s'
182 % os.path.dirname(self.toplevel_root)) 184 % os.path.dirname(self.toplevel_root))
183 185
186 # Parse TRYSERVER_* settings from codereview.settings before falling back
187 # on setting self.options.root manually further down. Otherwise
188 # TRYSERVER_ROOT would never be used in codereview.settings.
189 self._GclStyleSettings()
190
184 if self.toplevel_root and not self.options.root: 191 if self.toplevel_root and not self.options.root:
185 assert os.path.abspath(self.toplevel_root) == self.toplevel_root 192 assert os.path.abspath(self.toplevel_root) == self.toplevel_root
186 self.options.root = gclient_utils.PathDifference(self.toplevel_root, 193 self.options.root = gclient_utils.PathDifference(self.toplevel_root,
187 self.checkout_root) 194 self.checkout_root)
195 else:
196 self._GclStyleSettings()
188 197
189 def ReadRootFile(self, filename): 198 def ReadRootFile(self, filename):
190 cur = self.checkout_root 199 cur = self.checkout_root
191 root = self.toplevel_root or self.checkout_root 200 root = self.toplevel_root or self.checkout_root
192 201
193 assert cur.startswith(root), (root, cur) 202 assert cur.startswith(root), (root, cur)
194 while cur.startswith(root): 203 while cur.startswith(root):
195 filepath = os.path.join(cur, filename) 204 filepath = os.path.join(cur, filename)
196 if os.path.isfile(filepath): 205 if os.path.isfile(filepath):
197 logging.info('Found %s at %s' % (filename, cur)) 206 logging.info('Found %s at %s' % (filename, cur))
(...skipping 675 matching lines...) Expand 10 before | Expand all | Expand 10 after
873 return 1 882 return 1
874 except (gclient_utils.Error, subprocess2.CalledProcessError), e: 883 except (gclient_utils.Error, subprocess2.CalledProcessError), e:
875 print >> sys.stderr, e 884 print >> sys.stderr, e
876 return 1 885 return 1
877 return 0 886 return 0
878 887
879 888
880 if __name__ == "__main__": 889 if __name__ == "__main__":
881 fix_encoding.fix_encoding() 890 fix_encoding.fix_encoding()
882 sys.exit(TryChange(None, None, False)) 891 sys.exit(TryChange(None, None, False))
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698