OLD | NEW |
1 #!/bin/bash | 1 #!/bin/bash |
2 | 2 |
3 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 3 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
6 | 6 |
7 branch_name="" | 7 branch_name="" |
8 checkout_branch=no | 8 checkout_branch=no |
9 create_branch=no | 9 create_branch=no |
10 quiet=no | 10 quiet=no |
11 svn_lkgr= | 11 svn_lkgr= |
12 | 12 |
13 while [ $# -gt 0 ]; do | 13 while [ $# -gt 0 ]; do |
14 case "$1" in | 14 case "$1" in |
15 --checkout|--force-branch) | 15 --checkout|--force-branch) |
16 checkout_branch=yes | 16 checkout_branch=yes |
17 create_branch=yes | 17 create_branch=yes |
18 ;; | 18 ;; |
| 19 --closest) |
| 20 use_closest=yes |
| 21 ;; |
19 --create) | 22 --create) |
20 create_branch=yes | 23 create_branch=yes |
21 ;; | 24 ;; |
22 -n|--name) | 25 -n|--name) |
23 branch_name=$2 | 26 branch_name=$2 |
24 create_branch=yes | 27 create_branch=yes |
25 shift | 28 shift |
26 ;; | 29 ;; |
27 -q|--quiet) | 30 -q|--quiet) |
28 quiet=yes | 31 quiet=yes |
29 ;; | 32 ;; |
30 -r|--revision) | 33 -r|--revision) |
31 svn_lkgr="$2" | 34 svn_lkgr="$2" |
32 shift | 35 shift |
33 ;; | 36 ;; |
34 *) | 37 *) |
35 echo "Unknown option: $1" | 38 echo "Unknown option: $1" |
36 echo "Usage:" | 39 echo "Usage:" |
37 echo " --checkout Create a branch and check it out." | 40 echo " --checkout Create a branch and check it out." |
38 echo " --create Create a branch." | 41 echo " --create Create a branch." |
| 42 echo " --closest Use closest git commit to the target svn revisi
on." |
| 43 echo " Otherwise --checkout may be required to creat
e" |
| 44 echo " a git commit for a specific svn revision." |
39 echo " -n, --name <name> Specify the name of branch to create or reset." | 45 echo " -n, --name <name> Specify the name of branch to create or reset." |
40 echo " This will force the branch using 'git branch
-f '." | 46 echo " This will force the branch using 'git branch
-f '." |
41 echo " -q, --quiet Quiet." | 47 echo " -q, --quiet Quiet." |
42 echo " -r, --revision <r> Svn revision number use instead of server provi
ded lkgr." | 48 echo " -r, --revision <r> Svn revision number use instead of server provi
ded lkgr." |
43 exit 1 | 49 exit 1 |
44 ;; | 50 ;; |
45 esac | 51 esac |
46 shift | 52 shift |
47 done | 53 done |
48 | 54 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 closest_commit= | 94 closest_commit= |
89 closest_svn_commit= | 95 closest_svn_commit= |
90 else | 96 else |
91 closest_svn_commit=`git rev-list -n 1 ${closest_commit}^1` | 97 closest_svn_commit=`git rev-list -n 1 ${closest_commit}^1` |
92 if [ $? != 0 -o -z "$closest_svn_commit" ]; then | 98 if [ $? != 0 -o -z "$closest_svn_commit" ]; then |
93 cat <<EOF 1>&2 | 99 cat <<EOF 1>&2 |
94 I am thoroughly confused. Please file a bug report at http://new.crbug.com. | 100 I am thoroughly confused. Please file a bug report at http://new.crbug.com. |
95 EOF | 101 EOF |
96 exit 1 | 102 exit 1 |
97 fi | 103 fi |
| 104 closest_svn=`git svn find-rev ${closest_svn_commit}` |
| 105 fi |
| 106 |
| 107 if [ "${use_closest}" = "yes" ]; then |
| 108 svn_lkgr="${closest_svn}" |
| 109 git_lkgr="${closest_svn_commit}" |
98 fi | 110 fi |
99 | 111 |
100 # Determine lkgr_branch: | 112 # Determine lkgr_branch: |
101 if [ "${branch_name}" != "" ]; then | 113 if [ "${branch_name}" != "" ]; then |
102 # Use the provided name for the branch. | 114 # Use the provided name for the branch. |
103 lkgr_branch="${branch_name}" | 115 lkgr_branch="${branch_name}" |
104 | 116 |
105 # If the branch already exists, force the update to it. | 117 # If the branch already exists, force the update to it. |
106 git rev-parse --verify -q "${branch_name}" >/dev/null | 118 git rev-parse --verify -q "${branch_name}" >/dev/null |
107 if [ $? -eq 0 ]; then | 119 if [ $? -eq 0 ]; then |
(...skipping 21 matching lines...) Expand all Loading... |
129 git branch ${force_branch} "${lkgr_branch}" "${closest_commit}" || exit 1 | 141 git branch ${force_branch} "${lkgr_branch}" "${closest_commit}" || exit 1 |
130 fi | 142 fi |
131 if [ "$checkout_branch" = "yes" ]; then | 143 if [ "$checkout_branch" = "yes" ]; then |
132 git checkout "${lkgr_branch}" | 144 git checkout "${lkgr_branch}" |
133 fi | 145 fi |
134 exit 0 | 146 exit 0 |
135 elif [ "${quiet}" = "yes" ]; then | 147 elif [ "${quiet}" = "yes" ]; then |
136 exit 1 | 148 exit 1 |
137 elif [ "${checkout_branch}" = "no" ]; then | 149 elif [ "${checkout_branch}" = "no" ]; then |
138 echo "There is no master commit which corresponds exactly to svn revision ${sv
n_lkgr}." | 150 echo "There is no master commit which corresponds exactly to svn revision ${sv
n_lkgr}." |
| 151 echo "Call 'git lkgr --checkout' to create a branch with a commit to match ${s
vn_lkgr}." |
139 if [ -n "$closest_commit" ]; then | 152 if [ -n "$closest_commit" ]; then |
140 echo "The closest commit is ${closest_commit}." | 153 echo "The closest commit is r${closest_svn}, ${closest_commit}." |
| 154 echo "Use the --closest option to use the closest instead of the target revi
sion." |
141 fi | 155 fi |
142 echo "Call 'git lkgr --checkout' to create a branch with a commit to match ${s
vn_lkgr}." | |
143 exit 0 | 156 exit 0 |
144 fi | 157 fi |
145 | 158 |
146 current_head=`git branch | grep '^\*' | cut -c3-` | 159 current_head=`git branch | grep '^\*' | cut -c3-` |
147 if [ "${current_head}" = "(no branch)" ]; then | 160 if [ "${current_head}" = "(no branch)" ]; then |
148 current_head=`git rev-parse HEAD` | 161 current_head=`git rev-parse HEAD` |
149 fi | 162 fi |
150 | 163 |
151 git checkout --detach "${git_lkgr}" && | 164 git checkout --detach "${git_lkgr}" && |
152 python tools/deps2git/deps2git.py -d DEPS -o .DEPS.git -w .. && | 165 python tools/deps2git/deps2git.py -d DEPS -o .DEPS.git -w .. && |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 To create a working branch, do this: | 199 To create a working branch, do this: |
187 | 200 |
188 \$ git branch --track my_new_branch $lkgr_branch | 201 \$ git branch --track my_new_branch $lkgr_branch |
189 | 202 |
190 'git-cl upload' will do the right thing, i.e., it will cherry-pick all | 203 'git-cl upload' will do the right thing, i.e., it will cherry-pick all |
191 your changes from my_new_branch, but *not* the .DEPS.git+.gitmodules+submodules | 204 your changes from my_new_branch, but *not* the .DEPS.git+.gitmodules+submodules |
192 commit on $lkgr_branch. | 205 commit on $lkgr_branch. |
193 -------------------------------------------------------------------------------- | 206 -------------------------------------------------------------------------------- |
194 | 207 |
195 EOF | 208 EOF |
OLD | NEW |