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 import datetime | 10 import datetime |
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 return RunGit(['rev-parse', '--show-cdup']).strip() | 320 return RunGit(['rev-parse', '--show-cdup']).strip() |
321 | 321 |
322 def GetRoot(self): | 322 def GetRoot(self): |
323 if self.root is None: | 323 if self.root is None: |
324 self.root = os.path.abspath(self.GetRelativeRoot()) | 324 self.root = os.path.abspath(self.GetRelativeRoot()) |
325 return self.root | 325 return self.root |
326 | 326 |
327 def GetIsGitSvn(self): | 327 def GetIsGitSvn(self): |
328 """Return true if this repo looks like it's using git-svn.""" | 328 """Return true if this repo looks like it's using git-svn.""" |
329 if self.is_git_svn is None: | 329 if self.is_git_svn is None: |
330 # If you have any "svn-remote.*" config keys, we think you're using svn. | 330 # The presence of a svn-remote using the svn:// (or file://) |
331 self.is_git_svn = RunGitWithCode( | 331 # protocol suggests that you're using svn. Remotes with the |
332 ['config', '--local', '--get-regexp', r'^svn-remote\.'])[0] == 0 | 332 # http* protocols suggest read-only svn access and are ignored. |
| 333 code, result = RunGitWithCode( |
| 334 ['config', '--local', '--get-regexp', r'^svn-remote\..*\.url']) |
| 335 self.is_git_svn = (code == 0 and ("svn://" in result or |
| 336 "file://" in result)) |
333 return self.is_git_svn | 337 return self.is_git_svn |
334 | 338 |
335 def GetSVNBranch(self): | 339 def GetSVNBranch(self): |
336 if self.svn_branch is None: | 340 if self.svn_branch is None: |
337 if not self.GetIsGitSvn(): | 341 if not self.GetIsGitSvn(): |
338 DieWithError('Repo doesn\'t appear to be a git-svn repo.') | 342 DieWithError('Repo doesn\'t appear to be a git-svn repo.') |
339 | 343 |
340 # Try to figure out which remote branch we're based on. | 344 # Try to figure out which remote branch we're based on. |
341 # Strategy: | 345 # Strategy: |
342 # 1) iterate through our branch history and find the svn URL. | 346 # 1) iterate through our branch history and find the svn URL. |
(...skipping 2307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2650 ('AppEngine is misbehaving and returned HTTP %d, again. Keep faith ' | 2654 ('AppEngine is misbehaving and returned HTTP %d, again. Keep faith ' |
2651 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e))) | 2655 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e))) |
2652 | 2656 |
2653 | 2657 |
2654 if __name__ == '__main__': | 2658 if __name__ == '__main__': |
2655 # These affect sys.stdout so do it outside of main() to simplify mocks in | 2659 # These affect sys.stdout so do it outside of main() to simplify mocks in |
2656 # unit testing. | 2660 # unit testing. |
2657 fix_encoding.fix_encoding() | 2661 fix_encoding.fix_encoding() |
2658 colorama.init() | 2662 colorama.init() |
2659 sys.exit(main(sys.argv[1:])) | 2663 sys.exit(main(sys.argv[1:])) |
OLD | NEW |