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