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

Side by Side Diff: gcl.py

Issue 9222016: Fix try/finally clause when uploading an issue (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Created 8 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | 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/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 """\ 6 """\
7 Wrapper script around Rietveld's upload.py that simplifies working with groups 7 Wrapper script around Rietveld's upload.py that simplifies working with groups
8 of files. 8 of files.
9 """ 9 """
10 10
(...skipping 839 matching lines...) Expand 10 before | Expand all | Expand 10 after
850 upload_arg.append("--server=%s" % change_info.rietveld) 850 upload_arg.append("--server=%s" % change_info.rietveld)
851 851
852 reviewers = change_info.reviewers or output.reviewers 852 reviewers = change_info.reviewers or output.reviewers
853 if (reviewers and 853 if (reviewers and
854 not any(arg.startswith('-r') or arg.startswith('--reviewer') for 854 not any(arg.startswith('-r') or arg.startswith('--reviewer') for
855 arg in args)): 855 arg in args)):
856 upload_arg.append('--reviewers=%s' % ','.join(reviewers)) 856 upload_arg.append('--reviewers=%s' % ','.join(reviewers))
857 857
858 upload_arg.extend(args) 858 upload_arg.extend(args)
859 859
860 desc_file = "" 860 desc_file = None
861 if change_info.issue: # Uploading a new patchset. 861 try:
862 found_message = False 862 if change_info.issue: # Uploading a new patchset.
863 for arg in args: 863 found_message = False
864 if arg.startswith("--message") or arg.startswith("-m"): 864 for arg in args:
865 found_message = True 865 if arg.startswith("--message") or arg.startswith("-m"):
866 break 866 found_message = True
867 break
867 868
868 if not found_message: 869 if not found_message:
869 upload_arg.append("--message=''") 870 upload_arg.append("--message=''")
870 871
871 upload_arg.append("--issue=%d" % change_info.issue) 872 upload_arg.append("--issue=%d" % change_info.issue)
872 else: # First time we upload. 873 else: # First time we upload.
873 handle, desc_file = tempfile.mkstemp(text=True) 874 handle, desc_file = tempfile.mkstemp(text=True)
874 os.write(handle, change_info.description) 875 os.write(handle, change_info.description)
875 os.close(handle) 876 os.close(handle)
876 877
877 # Watchlist processing -- CC people interested in this changeset 878 # Watchlist processing -- CC people interested in this changeset
878 # http://dev.chromium.org/developers/contributing-code/watchlists 879 # http://dev.chromium.org/developers/contributing-code/watchlists
879 if not no_watchlists: 880 if not no_watchlists:
880 import watchlists 881 import watchlists
881 watchlist = watchlists.Watchlists(change_info.GetLocalRoot()) 882 watchlist = watchlists.Watchlists(change_info.GetLocalRoot())
882 watchers = watchlist.GetWatchersForPaths(change_info.GetFileNames()) 883 watchers = watchlist.GetWatchersForPaths(change_info.GetFileNames())
883 884
884 cc_list = GetCodeReviewSetting("CC_LIST") 885 cc_list = GetCodeReviewSetting("CC_LIST")
885 if not no_watchlists and watchers: 886 if not no_watchlists and watchers:
886 # Filter out all empty elements and join by ',' 887 # Filter out all empty elements and join by ','
887 cc_list = ','.join(filter(None, [cc_list] + watchers)) 888 cc_list = ','.join(filter(None, [cc_list] + watchers))
888 if cc_list: 889 if cc_list:
889 upload_arg.append("--cc=" + cc_list) 890 upload_arg.append("--cc=" + cc_list)
890 upload_arg.append("--description_file=" + desc_file + "") 891 upload_arg.append("--description_file=%s" % desc_file)
891 if change_info.subject: 892 if change_info.subject:
892 upload_arg.append("--message=" + change_info.subject) 893 upload_arg.append("--message=" + change_info.subject)
893 894
894 if GetCodeReviewSetting("PRIVATE") == "True": 895 if GetCodeReviewSetting("PRIVATE") == "True":
895 upload_arg.append("--private") 896 upload_arg.append("--private")
896 897
897 # If we have a lot of files with long paths, then we won't be able to fit 898 # If we have a lot of files with long paths, then we won't be able to fit
898 # the command to "svn diff". Instead, we generate the diff manually for 899 # the command to "svn diff". Instead, we generate the diff manually for
899 # each file and concatenate them before passing it to upload.py. 900 # each file and concatenate them before passing it to upload.py.
900 if change_info.patch is None: 901 if change_info.patch is None:
901 change_info.patch = GenerateDiff(change_info.GetFileNames()) 902 change_info.patch = GenerateDiff(change_info.GetFileNames())
902 903
903 # Change the current working directory before calling upload.py so that it 904 # Change the current working directory before calling upload.py so that it
904 # shows the correct base. 905 # shows the correct base.
905 previous_cwd = os.getcwd() 906 previous_cwd = os.getcwd()
906 os.chdir(change_info.GetLocalRoot()) 907 os.chdir(change_info.GetLocalRoot())
907 try:
908 try: 908 try:
909 issue, patchset = upload.RealMain(upload_arg, change_info.patch) 909 try:
910 except KeyboardInterrupt: 910 issue, patchset = upload.RealMain(upload_arg, change_info.patch)
911 sys.exit(1) 911 except KeyboardInterrupt:
912 if issue and patchset: 912 sys.exit(1)
913 change_info.issue = int(issue) 913 if issue and patchset:
914 change_info.patchset = int(patchset) 914 change_info.issue = int(issue)
915 change_info.Save() 915 change_info.patchset = int(patchset)
916 916 change_info.Save()
917 change_info.PrimeLint()
918 finally:
919 os.chdir(previous_cwd)
920 finally:
917 if desc_file: 921 if desc_file:
918 os.remove(desc_file) 922 os.remove(desc_file)
919 change_info.PrimeLint()
920 finally:
921 os.chdir(previous_cwd)
922 print "*** Upload does not submit a try; use gcl try to submit a try. ***" 923 print "*** Upload does not submit a try; use gcl try to submit a try. ***"
923 return 0 924 return 0
924 925
925 926
926 @need_change_and_args 927 @need_change_and_args
927 @attrs(usage='[--upload]') 928 @attrs(usage='[--upload]')
928 def CMDpresubmit(change_info, args): 929 def CMDpresubmit(change_info, args):
929 """Runs presubmit checks on the change. 930 """Runs presubmit checks on the change.
930 931
931 The actual presubmit code is implemented in presubmit_support.py and looks 932 The actual presubmit code is implemented in presubmit_support.py and looks
(...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after
1461 raise 1462 raise
1462 print >> sys.stderr, ( 1463 print >> sys.stderr, (
1463 'AppEngine is misbehaving and returned HTTP %d, again. Keep faith ' 1464 'AppEngine is misbehaving and returned HTTP %d, again. Keep faith '
1464 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e)) 1465 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e))
1465 return 1 1466 return 1
1466 1467
1467 1468
1468 if __name__ == "__main__": 1469 if __name__ == "__main__":
1469 fix_encoding.fix_encoding() 1470 fix_encoding.fix_encoding()
1470 sys.exit(main(sys.argv[1:])) 1471 sys.exit(main(sys.argv[1:]))
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698