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 logging | 10 import logging |
(...skipping 699 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
710 if filename in os.listdir(cwd): | 710 if filename in os.listdir(cwd): |
711 if os.path.isfile(os.path.join(cwd, filename)): | 711 if os.path.isfile(os.path.join(cwd, filename)): |
712 return open(os.path.join(cwd, filename)) | 712 return open(os.path.join(cwd, filename)) |
713 if cwd == root: | 713 if cwd == root: |
714 break | 714 break |
715 cwd = os.path.dirname(cwd) | 715 cwd = os.path.dirname(cwd) |
716 | 716 |
717 | 717 |
718 def LoadCodereviewSettingsFromFile(fileobj): | 718 def LoadCodereviewSettingsFromFile(fileobj): |
719 """Parse a codereview.settings file and updates hooks.""" | 719 """Parse a codereview.settings file and updates hooks.""" |
720 keyvals = {} | 720 keyvals = gclient_utils.ParseCodereviewSettingsContent(fileobj.read()) |
721 for line in fileobj.read().splitlines(): | |
722 if not line or line.startswith("#"): | |
723 continue | |
724 k, v = line.split(": ", 1) | |
725 keyvals[k] = v | |
726 | 721 |
727 def SetProperty(name, setting, unset_error_ok=False): | 722 def SetProperty(name, setting, unset_error_ok=False): |
728 fullname = 'rietveld.' + name | 723 fullname = 'rietveld.' + name |
729 if setting in keyvals: | 724 if setting in keyvals: |
730 RunGit(['config', fullname, keyvals[setting]]) | 725 RunGit(['config', fullname, keyvals[setting]]) |
731 else: | 726 else: |
732 RunGit(['config', '--unset-all', fullname], error_ok=unset_error_ok) | 727 RunGit(['config', '--unset-all', fullname], error_ok=unset_error_ok) |
733 | 728 |
734 SetProperty('server', 'CODE_REVIEW_SERVER') | 729 SetProperty('server', 'CODE_REVIEW_SERVER') |
735 # Only server setting is required. Other settings can be absent. | 730 # Only server setting is required. Other settings can be absent. |
(...skipping 695 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1431 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e))) | 1426 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e))) |
1432 | 1427 |
1433 # Not a known command. Default to help. | 1428 # Not a known command. Default to help. |
1434 GenUsage(parser, 'help') | 1429 GenUsage(parser, 'help') |
1435 return CMDhelp(parser, argv) | 1430 return CMDhelp(parser, argv) |
1436 | 1431 |
1437 | 1432 |
1438 if __name__ == '__main__': | 1433 if __name__ == '__main__': |
1439 fix_encoding.fix_encoding() | 1434 fix_encoding.fix_encoding() |
1440 sys.exit(main(sys.argv[1:])) | 1435 sys.exit(main(sys.argv[1:])) |
OLD | NEW |