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 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 return subprocess2.call( | 255 return subprocess2.call( |
256 ['git', | 256 ['git', |
257 'diff', '--no-ext-diff', '--stat'] + similarity_options + args, | 257 'diff', '--no-ext-diff', '--stat'] + similarity_options + args, |
258 env=env) | 258 env=env) |
259 | 259 |
260 | 260 |
261 class Settings(object): | 261 class Settings(object): |
262 def __init__(self): | 262 def __init__(self): |
263 self.default_server = None | 263 self.default_server = None |
264 self.cc = None | 264 self.cc = None |
265 self.relative_root = None | 265 self.root = None |
266 self.is_git_svn = None | 266 self.is_git_svn = None |
267 self.svn_branch = None | 267 self.svn_branch = None |
268 self.tree_status_url = None | 268 self.tree_status_url = None |
269 self.viewvc_url = None | 269 self.viewvc_url = None |
270 self.updated = False | 270 self.updated = False |
271 self.is_gerrit = None | 271 self.is_gerrit = None |
272 self.git_editor = None | 272 self.git_editor = None |
273 | 273 |
274 def LazyUpdateIfNeeded(self): | 274 def LazyUpdateIfNeeded(self): |
275 """Updates the settings from a codereview.settings file, if available.""" | 275 """Updates the settings from a codereview.settings file, if available.""" |
(...skipping 20 matching lines...) Expand all Loading... |
296 self._GetRietveldConfig('server', error_ok=True)) | 296 self._GetRietveldConfig('server', error_ok=True)) |
297 if error_ok: | 297 if error_ok: |
298 return self.default_server | 298 return self.default_server |
299 if not self.default_server: | 299 if not self.default_server: |
300 error_message = ('Could not find settings file. You must configure ' | 300 error_message = ('Could not find settings file. You must configure ' |
301 'your review setup by running "git cl config".') | 301 'your review setup by running "git cl config".') |
302 self.default_server = gclient_utils.UpgradeToHttps( | 302 self.default_server = gclient_utils.UpgradeToHttps( |
303 self._GetRietveldConfig('server', error_message=error_message)) | 303 self._GetRietveldConfig('server', error_message=error_message)) |
304 return self.default_server | 304 return self.default_server |
305 | 305 |
306 def GetRelativeRoot(self): | 306 @staticmethod |
307 if self.relative_root is None: | 307 def GetRelativeRoot(): |
308 self.relative_root = RunGit(['rev-parse', '--show-cdup']).strip() | 308 return RunGit(['rev-parse', '--show-cdup']).strip() |
309 return self.relative_root | |
310 | 309 |
311 def GetRoot(self): | 310 def GetRoot(self): |
312 return os.path.abspath(self.GetRelativeRoot()) | 311 if self.root is None: |
| 312 self.root = os.path.abspath(self.GetRelativeRoot()) |
| 313 return self.root |
313 | 314 |
314 def GetIsGitSvn(self): | 315 def GetIsGitSvn(self): |
315 """Return true if this repo looks like it's using git-svn.""" | 316 """Return true if this repo looks like it's using git-svn.""" |
316 if self.is_git_svn is None: | 317 if self.is_git_svn is None: |
317 # If you have any "svn-remote.*" config keys, we think you're using svn. | 318 # If you have any "svn-remote.*" config keys, we think you're using svn. |
318 self.is_git_svn = RunGitWithCode( | 319 self.is_git_svn = RunGitWithCode( |
319 ['config', '--local', '--get-regexp', r'^svn-remote\.'])[0] == 0 | 320 ['config', '--local', '--get-regexp', r'^svn-remote\.'])[0] == 0 |
320 return self.is_git_svn | 321 return self.is_git_svn |
321 | 322 |
322 def GetSVNBranch(self): | 323 def GetSVNBranch(self): |
(...skipping 2106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2429 ('AppEngine is misbehaving and returned HTTP %d, again. Keep faith ' | 2430 ('AppEngine is misbehaving and returned HTTP %d, again. Keep faith ' |
2430 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e))) | 2431 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e))) |
2431 | 2432 |
2432 | 2433 |
2433 if __name__ == '__main__': | 2434 if __name__ == '__main__': |
2434 # These affect sys.stdout so do it outside of main() to simplify mocks in | 2435 # These affect sys.stdout so do it outside of main() to simplify mocks in |
2435 # unit testing. | 2436 # unit testing. |
2436 fix_encoding.fix_encoding() | 2437 fix_encoding.fix_encoding() |
2437 colorama.init() | 2438 colorama.init() |
2438 sys.exit(main(sys.argv[1:])) | 2439 sys.exit(main(sys.argv[1:])) |
OLD | NEW |