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

Side by Side Diff: gcl.py

Issue 434061: gcl: add a new flag '-c' that stands for 'contributor'.... (Closed) Base URL: http://src.chromium.org/svn/trunk/tools/depot_tools/
Patch Set: following marc comments 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 | Annotate | Revision Log
« 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 optparse
10 import os 11 import os
11 import random 12 import random
12 import re 13 import re
13 import shutil 14 import shutil
14 import string 15 import string
15 import subprocess 16 import subprocess
16 import sys 17 import sys
17 import tempfile 18 import tempfile
18 import upload 19 import upload
19 import urllib2 20 import urllib2
(...skipping 893 matching lines...) Expand 10 before | Expand all | Expand 10 after
913 swallow_exception=swallow_exception, 914 swallow_exception=swallow_exception,
914 prog='gcl try') 915 prog='gcl try')
915 else: 916 else:
916 trychange.TryChange(args, 917 trychange.TryChange(args,
917 file_list=None, 918 file_list=None,
918 swallow_exception=swallow_exception, 919 swallow_exception=swallow_exception,
919 prog='gcl try') 920 prog='gcl try')
920 921
921 922
922 def Commit(change_info, args): 923 def Commit(change_info, args):
924 parser = optparse.OptionParser(usage='gcl commit [options]')
925 parser.add_option('-c', '--contributor',
926 help="external contributor for patch (appended to " +
927 "description)")
928 (options, args) = parser.parse_args(args)
929
923 if not change_info.GetFiles(): 930 if not change_info.GetFiles():
924 print "Nothing to commit, changelist is empty." 931 print "Nothing to commit, changelist is empty."
925 return 932 return
926 if not OptionallyDoPresubmitChecks(change_info, True, args): 933 if not OptionallyDoPresubmitChecks(change_info, True, args):
927 return 934 return
928 935
929 # We face a problem with svn here: Let's say change 'bleh' modifies 936 # We face a problem with svn here: Let's say change 'bleh' modifies
930 # svn:ignore on dir1\. but another unrelated change 'pouet' modifies 937 # svn:ignore on dir1\. but another unrelated change 'pouet' modifies
931 # dir1\foo.cc. When the user `gcl commit bleh`, foo.cc is *also committed*. 938 # dir1\foo.cc. When the user `gcl commit bleh`, foo.cc is *also committed*.
932 # The only fix is to use --non-recursive but that has its issues too: 939 # The only fix is to use --non-recursive but that has its issues too:
933 # Let's say if dir1 is deleted, --non-recursive must *not* be used otherwise 940 # Let's say if dir1 is deleted, --non-recursive must *not* be used otherwise
934 # you'll get "svn: Cannot non-recursively commit a directory deletion of a 941 # you'll get "svn: Cannot non-recursively commit a directory deletion of a
935 # directory with child nodes". Yay... 942 # directory with child nodes". Yay...
936 commit_cmd = ["svn", "commit"] 943 commit_cmd = ["svn", "commit"]
937 if change_info.issue: 944 if change_info.issue:
938 # Get the latest description from Rietveld. 945 # Get the latest description from Rietveld.
939 change_info.description = GetIssueDescription(change_info.issue) 946 change_info.description = GetIssueDescription(change_info.issue)
940 947
941 commit_message = change_info.description.replace('\r\n', '\n') 948 commit_message = change_info.description.replace('\r\n', '\n')
949 if options.contributor:
950 commit_message += ('\nPatch from %s' % options.contributor)
942 if change_info.issue: 951 if change_info.issue:
943 commit_message += ('\nReview URL: http://%s/%d' % 952 commit_message += ('\nReview URL: http://%s/%d' %
944 (GetCodeReviewSetting("CODE_REVIEW_SERVER"), 953 (GetCodeReviewSetting("CODE_REVIEW_SERVER"),
945 change_info.issue)) 954 change_info.issue))
946 955
947 handle, commit_filename = tempfile.mkstemp(text=True) 956 handle, commit_filename = tempfile.mkstemp(text=True)
948 os.write(handle, commit_message) 957 os.write(handle, commit_message)
949 os.close(handle) 958 os.close(handle)
950 959
951 handle, targets_filename = tempfile.mkstemp(text=True) 960 handle, targets_filename = tempfile.mkstemp(text=True)
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
1283 return 0 1292 return 0
1284 args =["svn", command] 1293 args =["svn", command]
1285 root = GetRepositoryRoot() 1294 root = GetRepositoryRoot()
1286 args.extend([os.path.join(root, x) for x in change_info.GetFileNames()]) 1295 args.extend([os.path.join(root, x) for x in change_info.GetFileNames()])
1287 RunShell(args, True) 1296 RunShell(args, True)
1288 return 0 1297 return 0
1289 1298
1290 1299
1291 if __name__ == "__main__": 1300 if __name__ == "__main__":
1292 sys.exit(main()) 1301 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