Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(378)

Side by Side Diff: gcl.py

Issue 501143: Remove gclient-specific hacks from trychange into gcl. (Closed)
Patch Set: Small unit test fix Created 11 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | gclient_utils.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
11 import random 11 import random
12 import re 12 import re
13 import shutil 13 import shutil
14 import string 14 import string
15 import subprocess 15 import subprocess
16 import sys 16 import sys
17 import tempfile 17 import tempfile
18 import upload 18 import upload
19 import urllib2 19 import urllib2
20 20
21 import breakpad 21 import breakpad
22 22
23 # gcl now depends on gclient. 23 # gcl now depends on gclient.
24 from scm import SVN 24 from scm import SVN
25 import gclient_utils 25 import gclient_utils
26 26
27 __version__ = '1.1.2' 27 __version__ = '1.1.3'
28 28
29 29
30 CODEREVIEW_SETTINGS = { 30 CODEREVIEW_SETTINGS = {
31 # Default values. 31 # Default values.
32 "CODE_REVIEW_SERVER": "codereview.chromium.org", 32 "CODE_REVIEW_SERVER": "codereview.chromium.org",
33 "CC_LIST": "chromium-reviews@googlegroups.com", 33 "CC_LIST": "chromium-reviews@googlegroups.com",
34 "VIEW_VC": "http://src.chromium.org/viewvc/chrome?view=rev&revision=", 34 "VIEW_VC": "http://src.chromium.org/viewvc/chrome?view=rev&revision=",
35 } 35 }
36 36
37 # globals that store the root of the current repository and the directory where 37 # globals that store the root of the current repository and the directory where
(...skipping 813 matching lines...) Expand 10 before | Expand all | Expand 10 after
851 851
852 def TryChange(change_info, args, swallow_exception): 852 def TryChange(change_info, args, swallow_exception):
853 """Create a diff file of change_info and send it to the try server.""" 853 """Create a diff file of change_info and send it to the try server."""
854 try: 854 try:
855 import trychange 855 import trychange
856 except ImportError: 856 except ImportError:
857 if swallow_exception: 857 if swallow_exception:
858 return 858 return
859 ErrorExit("You need to install trychange.py to use the try server.") 859 ErrorExit("You need to install trychange.py to use the try server.")
860 860
861 def PathDifference(root, subpath):
862 """Returns the difference subpath minus root."""
863 root = os.path.realpath(root)
864 subpath = os.path.realpath(subpath)
865 if not subpath.startswith(root):
866 return None
867 # If the root does not have a trailing \ or /, we add it so the returned
868 # path starts immediately after the seperator regardless of whether it is
869 # provided.
870 root = os.path.join(root, '')
871 return subpath[len(root):]
872
873 # Try to find the gclient root.
874 def FindGclientRootDir(from_dir):
875 path = os.path.realpath(from_dir)
876 while not os.path.exists(os.path.join(path, '.gclient')):
877 next = os.path.split(path)
878 if not next[1]:
879 return None
880 path = next[0]
881 return path
882
883 trychange_args = []
884 gclient_root = FindGclientRootDir(GetRepositoryRoot())
885 if gclient_root:
886 trychange_args.extend(['--root', PathDifference(gclient_root,
887 GetRepositoryRoot())])
861 if change_info: 888 if change_info:
862 trychange_args = ['--name', change_info.name] 889 trychange_args.extend(['--name', change_info.name])
863 if change_info.issue: 890 if change_info.issue:
864 trychange_args.extend(["--issue", str(change_info.issue)]) 891 trychange_args.extend(["--issue", str(change_info.issue)])
865 if change_info.patchset: 892 if change_info.patchset:
866 trychange_args.extend(["--patchset", str(change_info.patchset)]) 893 trychange_args.extend(["--patchset", str(change_info.patchset)])
867 trychange_args.extend(args) 894 trychange_args.extend(args)
868 trychange.TryChange(trychange_args, 895 trychange.TryChange(trychange_args,
bradn 2009/12/20 22:14:54 Might be more clear if you decide file_list in the
869 file_list=change_info.GetFileNames(), 896 file_list=change_info.GetFileNames(),
870 swallow_exception=swallow_exception, 897 swallow_exception=swallow_exception,
871 prog='gcl try') 898 prog='gcl try')
872 else: 899 else:
873 trychange.TryChange(args, 900 trychange_args.extend(args)
901 trychange.TryChange(trychange_args,
874 file_list=None, 902 file_list=None,
875 swallow_exception=swallow_exception, 903 swallow_exception=swallow_exception,
876 prog='gcl try') 904 prog='gcl try')
877 905
878 906
879 def Commit(change_info, args): 907 def Commit(change_info, args):
880 if not change_info.GetFiles(): 908 if not change_info.GetFiles():
881 print "Nothing to commit, changelist is empty." 909 print "Nothing to commit, changelist is empty."
882 return 910 return
883 if not OptionallyDoPresubmitChecks(change_info, True, args): 911 if not OptionallyDoPresubmitChecks(change_info, True, args):
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
1240 return 0 1268 return 0
1241 args =["svn", command] 1269 args =["svn", command]
1242 root = GetRepositoryRoot() 1270 root = GetRepositoryRoot()
1243 args.extend([os.path.join(root, x) for x in change_info.GetFileNames()]) 1271 args.extend([os.path.join(root, x) for x in change_info.GetFileNames()])
1244 RunShell(args, True) 1272 RunShell(args, True)
1245 return 0 1273 return 0
1246 1274
1247 1275
1248 if __name__ == "__main__": 1276 if __name__ == "__main__":
1249 sys.exit(main()) 1277 sys.exit(main())
OLDNEW
« no previous file with comments | « no previous file | gclient_utils.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698