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

Side by Side Diff: update_google_patch.sh

Issue 306793002: [hunspell] Script to automatically generate google.patch (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/hunspell.git@master
Patch Set: Once more rebasing. Created 6 years, 4 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
« no previous file with comments | « README.chromium ('k') | 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
(Empty)
1 #!/bin/bash
2
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.
6
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)
14 #
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.
18
19 cvs_dir=""
20 tempfiles=( )
21 tmplate="/tmp/`basename $0`.XXXXXX"
22
23 # Cleanup function to be executed whenever the script exits.
24 function cleanup() {
25 if [[ $cvs_dir ]]; then
26 rm -r "${cvs_dir}"
27 fi
28
29 if [[ ${tempfiles[@]} ]]; then
30 rm "${tempfiles[@]}"
31 fi
32 cd ${starting_dir}
33 }
34 trap cleanup 0
35
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'"
42 }
43
44 starting_dir=$(pwd)
45 hunspell_dir=$(dirname $(readlink -e $0))
46
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
54
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} )
57
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
64 fi
65 deleted_files=$( echo "${changed_files}" | grep "^D")
66 if [[ ${deleted_files} ]] ; then
67 echo "Script cannot handle deleted files"
68 exit 1
69 fi
70
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}
75
76 # Create copy of google.patch at branch point version.
77 tempfile google_patch_file
78 git show @{u}:google.patch > ${google_patch_file}
79
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
83
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
90
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}
97
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
102
OLDNEW
« no previous file with comments | « README.chromium ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698