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

Side by Side Diff: gcl.py

Issue 119315: Add --force as a synonym for --no_presubmit as per Nicolas' request. (Closed)
Patch Set: Created 11 years, 6 months 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 | tests/gcl_unittest.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
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 return result 238 return result
239 239
240 240
241 def WriteFile(filename, contents): 241 def WriteFile(filename, contents):
242 """Overwrites the file with the given contents.""" 242 """Overwrites the file with the given contents."""
243 file = open(filename, 'w') 243 file = open(filename, 'w')
244 file.write(contents) 244 file.write(contents)
245 file.close() 245 file.close()
246 246
247 247
248 def FilterFlag(args, flag):
249 """Returns True if the flag is present in args list.
250
251 The flag is removed from args if present.
252 """
253 if flag in args:
254 args.remove(flag)
255 return True
256 return False
257
258
248 class ChangeInfo(object): 259 class ChangeInfo(object):
249 """Holds information about a changelist. 260 """Holds information about a changelist.
250 261
251 name: change name. 262 name: change name.
252 issue: the Rietveld issue number or 0 if it hasn't been uploaded yet. 263 issue: the Rietveld issue number or 0 if it hasn't been uploaded yet.
253 patchset: the Rietveld latest patchset number or 0. 264 patchset: the Rietveld latest patchset number or 0.
254 description: the description. 265 description: the description.
255 files: a list of 2 tuple containing (status, filename) of changed files, 266 files: a list of 2 tuple containing (status, filename) of changed files,
256 with paths being relative to the top repository directory. 267 with paths being relative to the top repository directory.
257 """ 268 """
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after
706 # svn diff on a mv/cp'd file outputs nothing. 717 # svn diff on a mv/cp'd file outputs nothing.
707 # We put in an empty Index entry so upload.py knows about them. 718 # We put in an empty Index entry so upload.py knows about them.
708 diff.append("\nIndex: %s\n" % file) 719 diff.append("\nIndex: %s\n" % file)
709 else: 720 else:
710 # The file is not modified anymore. It should be removed from the set. 721 # The file is not modified anymore. It should be removed from the set.
711 pass 722 pass
712 os.chdir(previous_cwd) 723 os.chdir(previous_cwd)
713 return "".join(diff) 724 return "".join(diff)
714 725
715 726
727
728 def OptionallyDoPresubmitChecks(change_info, committing, args):
729 if FilterFlag(args, "--no_presubmit") or FilterFlag(args, "--force"):
730 return True
731 return DoPresubmitChecks(change_info, committing=committing)
732
733
716 def UploadCL(change_info, args): 734 def UploadCL(change_info, args):
717 if not change_info.FileList(): 735 if not change_info.FileList():
718 print "Nothing to upload, changelist is empty." 736 print "Nothing to upload, changelist is empty."
719 return 737 return
720 738 if not OptionallyDoPresubmitChecks(change_info, False, args):
721 if not "--no_presubmit" in args: 739 return
722 if not DoPresubmitChecks(change_info, committing=False): 740 no_try = FilterFlag(args, "--no_try") or FilterFlag(args, "--no-try")
723 return
724 else:
725 args.remove("--no_presubmit")
726
727 no_try = "--no_try" in args
728 if no_try:
729 args.remove("--no_try")
730 else:
731 # Support --no-try as --no_try
732 no_try = "--no-try" in args
733 if no_try:
734 args.remove("--no-try")
735 741
736 # Map --send-mail to --send_mail 742 # Map --send-mail to --send_mail
737 if "--send-mail" in args: 743 if FilterFlag(args, "--send-mail"):
738 args.remove("--send-mail")
739 args.append("--send_mail") 744 args.append("--send_mail")
740 745
741 # Supports --clobber for the try server. 746 # Supports --clobber for the try server.
742 clobber = False 747 clobber = FilterFlag(args, "--clobber")
743 if "--clobber" in args:
744 args.remove("--clobber")
745 clobber = True
746 748
747 # Disable try when the server is overridden. 749 # Disable try when the server is overridden.
748 server_1 = re.compile(r"^-s\b.*") 750 server_1 = re.compile(r"^-s\b.*")
749 server_2 = re.compile(r"^--server\b.*") 751 server_2 = re.compile(r"^--server\b.*")
750 for arg in args: 752 for arg in args:
751 if server_1.match(arg) or server_2.match(arg): 753 if server_1.match(arg) or server_2.match(arg):
752 no_try = True 754 no_try = True
753 break 755 break
754 756
755 upload_arg = ["upload.py", "-y"] 757 upload_arg = ["upload.py", "-y"]
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
859 trychange.TryChange(args, 861 trychange.TryChange(args,
860 file_list=None, 862 file_list=None,
861 swallow_exception=swallow_exception, 863 swallow_exception=swallow_exception,
862 prog='gcl try') 864 prog='gcl try')
863 865
864 866
865 def Commit(change_info, args): 867 def Commit(change_info, args):
866 if not change_info.FileList(): 868 if not change_info.FileList():
867 print "Nothing to commit, changelist is empty." 869 print "Nothing to commit, changelist is empty."
868 return 870 return
869 871 if not OptionallyDoPresubmitChecks(change_info, True, args):
870 if not "--no_presubmit" in args: 872 return
871 if not DoPresubmitChecks(change_info, committing=True):
872 return
873 else:
874 args.remove("--no_presubmit")
875 873
876 # We face a problem with svn here: Let's say change 'bleh' modifies 874 # We face a problem with svn here: Let's say change 'bleh' modifies
877 # svn:ignore on dir1\. but another unrelated change 'pouet' modifies 875 # svn:ignore on dir1\. but another unrelated change 'pouet' modifies
878 # dir1\foo.cc. When the user `gcl commit bleh`, foo.cc is *also committed*. 876 # dir1\foo.cc. When the user `gcl commit bleh`, foo.cc is *also committed*.
879 # The only fix is to use --non-recursive but that has its issues too: 877 # The only fix is to use --non-recursive but that has its issues too:
880 # Let's say if dir1 is deleted, --non-recursive must *not* be used otherwise 878 # Let's say if dir1 is deleted, --non-recursive must *not* be used otherwise
881 # you'll get "svn: Cannot non-recursively commit a directory deletion of a 879 # you'll get "svn: Cannot non-recursively commit a directory deletion of a
882 # directory with child nodes". Yay... 880 # directory with child nodes". Yay...
883 commit_cmd = ["svn", "commit"] 881 commit_cmd = ["svn", "commit"]
884 filename = '' 882 filename = ''
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
1158 # the files. This allows commands such as 'gcl diff xxx' to work. 1156 # the files. This allows commands such as 'gcl diff xxx' to work.
1159 args =["svn", command] 1157 args =["svn", command]
1160 root = GetRepositoryRoot() 1158 root = GetRepositoryRoot()
1161 args.extend([os.path.join(root, x) for x in change_info.FileList()]) 1159 args.extend([os.path.join(root, x) for x in change_info.FileList()])
1162 RunShell(args, True) 1160 RunShell(args, True)
1163 return 0 1161 return 0
1164 1162
1165 1163
1166 if __name__ == "__main__": 1164 if __name__ == "__main__":
1167 sys.exit(main()) 1165 sys.exit(main())
OLDNEW
« no previous file with comments | « no previous file | tests/gcl_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698