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.
21 tmplate
="/tmp/`basename $0`.XXXXXX"
23 # Cleanup function to be executed whenever the script exits.
25 if [[ $cvs_dir ]]; then
29 if [[ ${tempfiles[@]} ]]; then
36 # Generate a temp file and register it for cleanup
39 local tmpfile
=$
(mktemp
${tmplate}) ||
exit 1
40 tempfiles
+=( "${tmpfile}" )
41 eval $result="'$tmpfile'"
45 hunspell_dir
=$
(dirname $
(readlink
-e $0))
47 # Temp file with a list of all excluded files
49 cat << EOF > ${filter_file}
51 update_google_patch.sh
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"
65 deleted_files
=$
( echo "${changed_files}" |
grep "^D")
66 if [[ ${deleted_files} ]] ; then
67 echo "Script cannot handle deleted files"
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.
86 echo Checking out CVS version.
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.
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
100 echo Updating google.
patch.
101 cvs
-q diff -u > ${hunspell_dir}/google.
patch