Update mojo sdk to rev 1dc8a9a5db73d3718d99917fadf31f5fb2ebad4f
[chromium-blink-merge.git] / third_party / hunspell / update_google_patch.sh
blob6b7357adb8210a289d35555bcdd0d365820efffa
1 #!/bin/bash
3 # Copyright 2014 The Chromium Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file.
7 # Creates an updated google.patch that reflects all checked-in changes in the
8 # current branch. To do this, it
9 # 1) Checks out the baseline from CVS into a separate /tmp directory.
10 # 2) Applies all changes third_party/hunspell had since baseline to the CVS dir.
11 # 2a) Applying google.patch at current branches upstream revision
12 # 2b) Applying all changes made in the current branch since upstream
13 # 3) Diffs the updated CVS dir against the checkout made in 1)
15 # No files in the current branch except google.patch will be modified, and
16 # applying google.patch to the CVS baseline catches baseline up to
17 # third_party/hunspell.
19 cvs_dir=""
20 tempfiles=( )
21 tmplate="/tmp/`basename $0`.XXXXXX"
23 # Cleanup function to be executed whenever the script exits.
24 function cleanup() {
25 if [[ $cvs_dir ]]; then
26 rm -r "${cvs_dir}"
29 if [[ ${tempfiles[@]} ]]; then
30 rm "${tempfiles[@]}"
32 cd ${starting_dir}
34 trap cleanup 0
36 # Generate a temp file and register it for cleanup
37 function tempfile() {
38 local result=$1
39 local tmpfile=$(mktemp ${tmplate}) || exit 1
40 tempfiles+=( "${tmpfile}" )
41 eval $result="'$tmpfile'"
44 starting_dir=$(pwd)
45 hunspell_dir=$(dirname $(readlink -e $0))
47 # Temp file with a list of all excluded files
48 tempfile filter_file
49 cat << EOF > ${filter_file}
50 google.patch
51 update_google_patch.sh
52 README.chromium
53 EOF
55 # List of all files changed relative to upstream in current branch.
56 changed_files=$(git --no-pager diff @{u} --name-status | grep -vf ${filter_file} )
58 # Check we don't actually have files that are added or deleted, because
59 # that can't be handled by the read-only CVS checkout.
60 added_files=$( echo "${changed_files}" | grep "^A")
61 if [[ ${added_files} ]] ; then
62 echo "Script cannot handle added files"
63 exit 1
65 deleted_files=$( echo "${changed_files}" | grep "^D")
66 if [[ ${deleted_files} ]] ; then
67 echo "Script cannot handle deleted files"
68 exit 1
71 # Generate patch between branch point from upstream and current HEAD.
72 diff_files=$( echo "${changed_files}" | grep "^M" | cut -f1 --complement )
73 tempfile local_patch_file
74 echo "${diff_files}" | xargs -IXX git --no-pager diff --no-prefix @{u} -- XX > ${local_patch_file}
76 # Create copy of google.patch at branch point version.
77 tempfile google_patch_file
78 git show @{u}:google.patch > ${google_patch_file}
80 # Create a temporary checkout for CVS hunspell's baseline. All further work
81 # will happen in this temp directory.
82 cvs_dir=$(mktemp -d ${tmplate}) || exit 1
84 # Get CVS hunspell baseline.
85 cd ${cvs_dir}
86 echo Checking out CVS version.
87 cvs -z3 \
88 -qd:pserver:anonymous@hunspell.cvs.sourceforge.net:/cvsroot/hunspell \
89 co -D "23 Mar 2012" -P hunspell
91 # Apply google.patch and changes in current branch to CVS hunspell baseline.
92 cd hunspell
93 echo Applying google.patch.
94 patch -p0 -i ${google_patch_file}
95 echo Applying local patch.
96 patch -p0 -i ${local_patch_file}
98 # And generate a new google.patch by diffing modified CVS hunspell against CVS
99 # hunspell baseline.
100 echo Updating google.patch.
101 cvs -q diff -u > ${hunspell_dir}/google.patch