| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2006-2009 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 """Wrapper script around Rietveld's upload.py that groups files into | 6 """Wrapper script around Rietveld's upload.py that groups files into |
| 7 changelists.""" | 7 changelists.""" |
| 8 | 8 |
| 9 import getpass | 9 import getpass |
| 10 import os | 10 import os |
| (...skipping 801 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 812 | 812 |
| 813 def TryChange(change_info, args, swallow_exception): | 813 def TryChange(change_info, args, swallow_exception): |
| 814 """Create a diff file of change_info and send it to the try server.""" | 814 """Create a diff file of change_info and send it to the try server.""" |
| 815 try: | 815 try: |
| 816 import trychange | 816 import trychange |
| 817 except ImportError: | 817 except ImportError: |
| 818 if swallow_exception: | 818 if swallow_exception: |
| 819 return | 819 return |
| 820 ErrorExit("You need to install trychange.py to use the try server.") | 820 ErrorExit("You need to install trychange.py to use the try server.") |
| 821 | 821 |
| 822 def PathDifference(root, subpath): | |
| 823 """Returns the difference subpath minus root.""" | |
| 824 root = os.path.realpath(root) | |
| 825 subpath = os.path.realpath(subpath) | |
| 826 if not subpath.startswith(root): | |
| 827 return None | |
| 828 # If the root does not have a trailing \ or /, we add it so the returned | |
| 829 # path starts immediately after the seperator regardless of whether it is | |
| 830 # provided. | |
| 831 root = os.path.join(root, '') | |
| 832 return subpath[len(root):] | |
| 833 | |
| 834 trychange_args = [] | 822 trychange_args = [] |
| 835 settings = { | 823 settings = { |
| 836 'port': GetCodeReviewSetting('TRYSERVER_HTTP_PORT'), | 824 'port': GetCodeReviewSetting('TRYSERVER_HTTP_PORT'), |
| 837 'host': GetCodeReviewSetting('TRYSERVER_HTTP_HOST'), | 825 'host': GetCodeReviewSetting('TRYSERVER_HTTP_HOST'), |
| 838 'svn_repo': GetCodeReviewSetting('TRYSERVER_SVN_URL'), | 826 'svn_repo': GetCodeReviewSetting('TRYSERVER_SVN_URL'), |
| 839 'project': GetCodeReviewSetting('TRYSERVER_PROJECT'), | 827 'project': GetCodeReviewSetting('TRYSERVER_PROJECT'), |
| 840 'root': GetCodeReviewSetting('TRYSERVER_ROOT'), | 828 'root': GetCodeReviewSetting('TRYSERVER_ROOT'), |
| 841 'patchlevel': GetCodeReviewSetting('TRYSERVER_PATCHLEVEL'), | 829 'patchlevel': GetCodeReviewSetting('TRYSERVER_PATCHLEVEL'), |
| 842 } | 830 } |
| 843 for (k, v) in settings.iteritems(): | 831 for (k, v) in settings.iteritems(): |
| 844 if v: | 832 if v: |
| 845 trychange_args.extend(['--' + k, v]) | 833 trychange_args.extend(['--' + k, v]) |
| 846 | 834 |
| 847 gclient_root = gclient_utils.FindGclientRoot(GetRepositoryRoot()) | 835 gclient_root = gclient_utils.FindGclientRoot(GetRepositoryRoot()) |
| 848 if gclient_root: | 836 if gclient_root: |
| 849 trychange_args.extend(['--root', PathDifference(gclient_root, | 837 trychange_args.extend(['--root', |
| 850 GetRepositoryRoot())]) | 838 gclient_utils.PathDifference(gclient_root, |
| 839 GetRepositoryRoot())]) |
| 851 if change_info: | 840 if change_info: |
| 852 trychange_args.extend(['--name', change_info.name]) | 841 trychange_args.extend(['--name', change_info.name]) |
| 853 if change_info.issue: | 842 if change_info.issue: |
| 854 trychange_args.extend(["--issue", str(change_info.issue)]) | 843 trychange_args.extend(["--issue", str(change_info.issue)]) |
| 855 if change_info.patchset: | 844 if change_info.patchset: |
| 856 trychange_args.extend(["--patchset", str(change_info.patchset)]) | 845 trychange_args.extend(["--patchset", str(change_info.patchset)]) |
| 857 trychange_args.extend(args) | 846 trychange_args.extend(args) |
| 858 file_list = change_info.GetFileNames() | 847 file_list = change_info.GetFileNames() |
| 859 else: | 848 else: |
| 860 trychange_args.extend(args) | 849 trychange_args.extend(args) |
| (...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1229 return 0 | 1218 return 0 |
| 1230 args =["svn", command] | 1219 args =["svn", command] |
| 1231 root = GetRepositoryRoot() | 1220 root = GetRepositoryRoot() |
| 1232 args.extend([os.path.join(root, x) for x in change_info.GetFileNames()]) | 1221 args.extend([os.path.join(root, x) for x in change_info.GetFileNames()]) |
| 1233 RunShell(args, True) | 1222 RunShell(args, True) |
| 1234 return 0 | 1223 return 0 |
| 1235 | 1224 |
| 1236 | 1225 |
| 1237 if __name__ == "__main__": | 1226 if __name__ == "__main__": |
| 1238 sys.exit(main()) | 1227 sys.exit(main()) |
| OLD | NEW |