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 force_branch=no |
| 8 quiet=no |
| 9 |
| 10 while [ $# -gt 0 ]; do |
| 11 case "$1" in |
| 12 --force-branch) |
| 13 force_branch=yes |
| 14 ;; |
| 15 -q|--quiet) |
| 16 quiet=yes |
| 17 ;; |
| 18 *) |
| 19 echo "Unknown option: $1" |
| 20 ;; |
| 21 esac |
| 22 shift |
| 23 done |
| 24 |
7 svn_lkgr=`curl -s http://chromium-status.appspot.com/lkgr` | 25 svn_lkgr=`curl -s http://chromium-status.appspot.com/lkgr` |
8 if [ $? != 0 -o -z "$svn_lkgr" ]; then | 26 if [ $? != 0 -o -z "$svn_lkgr" ]; then |
9 echo 'Could not get svn lkgr from chromium-status.appspot.com/lkgr' | 27 echo 'Could not get svn lkgr from chromium-status.appspot.com/lkgr' |
10 exit 1 | 28 exit 1 |
11 fi | 29 fi |
12 | 30 |
13 # Run a trivial git-svn command to force it to update the revision cache | 31 # Run a trivial git-svn command to force it to update the revision cache |
14 # (which causes spew that might otherwise confuse the next command). | 32 # (which causes spew that might otherwise confuse the next command). |
15 git svn info > /dev/null | 33 git svn info > /dev/null |
16 if [ $? != 0 ]; then | 34 if [ $? != 0 ]; then |
(...skipping 28 matching lines...) Expand all Loading... |
45 fi | 63 fi |
46 | 64 |
47 closest_svn_commit=`git rev-list -n 1 ${closest_commit}^1` | 65 closest_svn_commit=`git rev-list -n 1 ${closest_commit}^1` |
48 if [ $? != 0 -o -z "$closest_svn_commit" ]; then | 66 if [ $? != 0 -o -z "$closest_svn_commit" ]; then |
49 cat <<EOF 1>&2 | 67 cat <<EOF 1>&2 |
50 I am thoroughly confused. Please file a bug report at http://new.crbug.com. | 68 I am thoroughly confused. Please file a bug report at http://new.crbug.com. |
51 EOF | 69 EOF |
52 exit 1 | 70 exit 1 |
53 fi | 71 fi |
54 | 72 |
| 73 # Pick a name for the new branch. Use `git rev-parse` to make sure the branch |
| 74 # doesn't already exist; if it does, iterate an integer suffix to uniquify it. |
| 75 lkgr_branch="git_lkgr_r${svn_lkgr}" |
| 76 digit=1 |
| 77 git rev-parse --verify -q "${lkgr_branch}" >/dev/null |
| 78 while [ $? -eq 0 ]; do |
| 79 lkgr_branch="git_lkgr_r${svn_lkgr}_${digit}" |
| 80 digit=`expr $digit + 1` |
| 81 git rev-parse --verify -q "${lkgr_branch}" >/dev/null |
| 82 done |
| 83 |
55 if [ "${closest_svn_commit}" = "${git_lkgr}" ]; then | 84 if [ "${closest_svn_commit}" = "${git_lkgr}" ]; then |
56 echo "${closest_commit}" | 85 echo "${closest_commit}" |
| 86 if [ "$force_branch" = "yes" ]; then |
| 87 git checkout -b "${lkgr_branch}" "${closest_commit}" |
| 88 fi |
57 exit 0 | 89 exit 0 |
58 else | 90 elif [ "${quiet}" = "yes" ]; then |
59 cat <<EOF 1>&2 | 91 exit 1 |
| 92 elif [ "${force_branch}" = "no" ]; then |
| 93 cat <<EOF |
60 There is no master commit which corresponds exactly to lkgr. | 94 There is no master commit which corresponds exactly to lkgr. |
61 The closest commit is ${closest_commit}. | 95 The closest commit is ${closest_commit}. |
62 EOF | 96 EOF |
| 97 read -n 1 -p 'Would you like to create a new branch based on lkgr? (y/N) ' |
| 98 echo |
| 99 if [ "x$REPLY" != "xy" -a "x$REPLY" != "xY" ]; then |
| 100 exit 0 |
| 101 fi |
| 102 fi |
| 103 |
| 104 current_head=`git branch | grep '^\*' | cut -c3-` |
| 105 if [ "${current_head}" = "(no branch)" ]; then |
| 106 current_head=`git rev-parse HEAD` |
| 107 fi |
| 108 |
| 109 git checkout --detach "${git_lkgr}" && |
| 110 python tools/deps2git/deps2git.py -d DEPS -o .DEPS.git -w .. && |
| 111 git add .DEPS.git && |
| 112 python tools/deps2git/deps2submodules.py .DEPS.git && |
| 113 git commit -m "SVN changes up to revision $svn_lkgr" && |
| 114 git checkout -b "${lkgr_branch}" HEAD |
| 115 |
| 116 if [ $? != 0 ]; then |
| 117 cat <<EOF |
| 118 |
| 119 -------------------------------------------------------------------------------- |
| 120 Something went wrong! Restoring your previous state by checking out |
| 121 $current_head |
| 122 |
| 123 Please file a bug report at http://new.crbug.com. |
| 124 -------------------------------------------------------------------------------- |
| 125 |
| 126 EOF |
| 127 git checkout --force $current_head |
63 exit 1 | 128 exit 1 |
64 fi | 129 fi |
| 130 |
| 131 cat <<EOF |
| 132 |
| 133 -------------------------------------------------------------------------------- |
| 134 The new branch "$lkgr_branch" was branched from this commit: |
| 135 |
| 136 $git_lkgr |
| 137 |
| 138 ... which maps to the svn lkgr commit r${svn_lkgr}. The new branch |
| 139 has one additional commit, to bring .DEPS.git, .gitmodules, and the |
| 140 invisible git submodule files up to date with DEPS. |
| 141 |
| 142 To create a working branch, do this: |
| 143 |
| 144 \$ git branch --track my_new_branch $lkgr_branch |
| 145 |
| 146 'git-cl upload' will do the right thing, i.e., it will cherry-pick all |
| 147 your changes from my_new_branch, but *not* the .DEPS.git+.gitmodules+submodules |
| 148 commit on $lkgr_branch. |
| 149 -------------------------------------------------------------------------------- |
| 150 |
| 151 EOF |
OLD | NEW |