1414
1515dryrun=" "
1616stable_version=" "
17- revision =" "
17+ revisions =" "
1818BUGZILLA_BIN=" "
1919BUGZILLA_CMD=" "
2020release_metabug=" "
@@ -31,6 +31,7 @@ function usage() {
3131 echo " -user EMAIL Your email address for logging into bugzilla."
3232 echo " -stable-version X.Y The stable release version (e.g. 4.0, 5.0)."
3333 echo " -r NUM Revision number to merge (e.g. 1234567)."
34+ echo " This option can be specified multiple times."
3435 echo " -bugzilla-bin PATH Path to bugzilla binary (optional)."
3536 echo " -assign-to EMAIL Assign bug to user with EMAIL (optional)."
3637 echo " -dry-run Print commands instead of executing them."
@@ -48,7 +49,7 @@ while [ $# -gt 0 ]; do
4849 ;;
4950 -r)
5051 shift
51- revision= " $1 "
52+ revisions= " $revisions $1 "
5253 ;;
5354 -project)
5455 shift
@@ -91,14 +92,17 @@ case $stable_version in
9192 4.0)
9293 release_metabug=" 32061"
9394 ;;
95+ 5.0)
96+ release_metabug=" 34492"
97+ ;;
9498 * )
9599 echo " error: invalid stable version"
96100 exit 1
97101esac
98102bugzilla_version=$stable_version
99103
100- if [ -z " $revision " ]; then
101- echo " error: revision not specified"
104+ if [ -z " $revisions " ]; then
105+ echo " error: no revisions specified"
102106 exit 1
103107fi
104108
@@ -124,25 +128,23 @@ BUGZILLA_MAJOR_VERSION=`$BUGZILLA_BIN --version 2>&1 | cut -d . -f 1`
124128
125129if [ $BUGZILLA_MAJOR_VERSION -eq 1 ]; then
126130
127- echo " ***************************** Warning *******************************"
128- echo " You are using an older version of the bugzilla cli tool. You will be "
129- echo " able to create bugs, but this script will crash with the following "
130- echo " error when trying to read back information about the bug you created:"
131- echo " "
132- echo " KeyError: 'internals'"
133- echo " "
134- echo " To avoid this error, use version 2.0.0 or higher"
135- echo " https://pypi.python.org/pypi/python-bugzilla"
136- echo " *********************************************************************"
131+ echo " ***************************** Error ** ********************************"
132+ echo " You are using an older version of the bugzilla cli tool, which is not "
133+ echo " supported. You need to use bugzilla cli version 2.0.0 or higher:"
134+ echo " ***********************************************************************"
135+ exit 1
137136fi
138137
139138BUGZILLA_CMD=" $BUGZILLA_BIN --bugzilla=$bugzilla_url "
140139
141- bug_url=" https://reviews.llvm.org/rL$revision "
140+ rev_string=" "
141+ for r in $revisions ; do
142+ rev_string=" $rev_string r$r "
143+ done
142144
143145echo " Checking for duplicate bugs..."
144146
145- check_duplicates=` $BUGZILLA_CMD query --url $bug_url `
147+ check_duplicates=` $BUGZILLA_CMD query --blocked= $release_metabug --field= " cf_fixed_by_commits= $rev_string " `
146148
147149if [ -n " $check_duplicates " ]; then
148150 echo " Duplicate bug found:"
152154
153155echo " Done"
154156
155- # Get short commit summary
157+ # Get short commit summary. To avoid having a huge summary, we just
158+ # use the commit message for the first commit.
156159commit_summary=' '
157- commit_msg=` svn log -r $revision https://llvm.org/svn/llvm-project/`
158- if [ $? -ne 0 ]; then
159- echo " warning: failed to get commit message."
160- commit_msg=" "
161- fi
160+ for r in $revisions ; do
161+ commit_msg=` svn log -r $r https://llvm.org/svn/llvm-project/`
162+ if [ $? -ne 0 ]; then
163+ echo " warning: failed to get commit message."
164+ commit_msg=" "
165+ fi
166+ break
167+ done
162168
163169if [ -n " $commit_msg " ]; then
164170 commit_summary=` echo " $commit_msg " | sed ' 4q;d' | cut -c1-80`
165171 commit_summary=" : ${commit_summary} "
166172fi
167173
168- bug_summary=" Merge r $revision into the $stable_version branch${commit_summary} "
174+ bug_summary=" Merge${rev_string} into the $stable_version branch${commit_summary} "
169175
170- if [ -z " $dryrun " ]; then
171- set -x
172- fi
176+ set -x
177+
178+ # Login to bugzilla
179+ $BUGZILLA_CMD login $bugzilla_user
173180
174- ${dryrun} $BUGZILLA_CMD --login --user= $bugzilla_user new \
181+ bug_id= ` ${dryrun} $BUGZILLA_CMD --ensure-logged-in new \
175182 -p " $bugzilla_product " \
176- -c " $bugzilla_component " -u $bug_url - -blocked=$release_metabug \
183+ -c " $bugzilla_component " --blocked=$release_metabug \
177184 -o All --priority=P --arch All -v $bugzilla_version \
185+ --field=" cf_fixed_by_commits=$rev_string " \
178186 --summary " ${bug_summary} " \
179- -l " Is this patch OK to merge to the $stable_version branch?" \
187+ -l " Is it OK to merge the following revision(s) to the $stable_version branch?" \
180188 $bugzilla_assigned_to \
181- --oneline
182-
183- set +x
189+ -i`
184190
185191if [ -n " $dryrun " ]; then
186192 exit 0
187193fi
188194
189- if [ $BUGZILLA_MAJOR_VERSION -eq 1 ]; then
190- success=` $BUGZILLA_CMD query --url $bug_url `
191- if [ -z " $success " ]; then
192- echo " Failed to create bug."
193- exit 1
194- fi
195+ set +x
195196
196- echo " Created new bug:"
197- echo $success
197+ if [ -z " $bug_id " ]; then
198+ echo " Failed to create bug."
199+ exit 1
198200fi
201+
202+ echo " Created new bug:"
203+ echo https://llvm.org/PR$bug_id
204+
205+ # Add links to revisions
206+ for r in $revisions ; do
207+ $BUGZILLA_CMD --ensure-logged-in modify -l " https://reviews.llvm.org/rL$r " $bug_id
208+ done
0 commit comments