Commit 1d23a428 authored by szager@google.com's avatar szager@google.com

Add option to synthesize a consistent lkgr commit by running deps2git.py

and deps2submodules.py.

Depends on https://codereview.chromium.org/11085027
Review URL: https://codereview.chromium.org/11090038

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@161305 0039d316-1c4b-4281-b951-d872f2087c98
parent b848d5b7
......@@ -4,6 +4,24 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
force_branch=no
quiet=no
while [ $# -gt 0 ]; do
case "$1" in
--force-branch)
force_branch=yes
;;
-q|--quiet)
quiet=yes
;;
*)
echo "Unknown option: $1"
;;
esac
shift
done
svn_lkgr=`curl -s http://chromium-status.appspot.com/lkgr`
if [ $? != 0 -o -z "$svn_lkgr" ]; then
echo 'Could not get svn lkgr from chromium-status.appspot.com/lkgr'
......@@ -52,13 +70,82 @@ EOF
exit 1
fi
# Pick a name for the new branch. Use `git rev-parse` to make sure the branch
# doesn't already exist; if it does, iterate an integer suffix to uniquify it.
lkgr_branch="git_lkgr_r${svn_lkgr}"
digit=1
git rev-parse --verify -q "${lkgr_branch}" >/dev/null
while [ $? -eq 0 ]; do
lkgr_branch="git_lkgr_r${svn_lkgr}_${digit}"
digit=`expr $digit + 1`
git rev-parse --verify -q "${lkgr_branch}" >/dev/null
done
if [ "${closest_svn_commit}" = "${git_lkgr}" ]; then
echo "${closest_commit}"
if [ "$force_branch" = "yes" ]; then
git checkout -b "${lkgr_branch}" "${closest_commit}"
fi
exit 0
else
cat <<EOF 1>&2
elif [ "${quiet}" = "yes" ]; then
exit 1
elif [ "${force_branch}" = "no" ]; then
cat <<EOF
There is no master commit which corresponds exactly to lkgr.
The closest commit is ${closest_commit}.
EOF
read -n 1 -p 'Would you like to create a new branch based on lkgr? (y/N) '
echo
if [ "x$REPLY" != "xy" -a "x$REPLY" != "xY" ]; then
exit 0
fi
fi
current_head=`git branch | grep '^\*' | cut -c3-`
if [ "${current_head}" = "(no branch)" ]; then
current_head=`git rev-parse HEAD`
fi
git checkout --detach "${git_lkgr}" &&
python tools/deps2git/deps2git.py -d DEPS -o .DEPS.git -w .. &&
git add .DEPS.git &&
python tools/deps2git/deps2submodules.py .DEPS.git &&
git commit -m "SVN changes up to revision $svn_lkgr" &&
git checkout -b "${lkgr_branch}" HEAD
if [ $? != 0 ]; then
cat <<EOF
--------------------------------------------------------------------------------
Something went wrong! Restoring your previous state by checking out
$current_head
Please file a bug report at http://new.crbug.com.
--------------------------------------------------------------------------------
EOF
git checkout --force $current_head
exit 1
fi
cat <<EOF
--------------------------------------------------------------------------------
The new branch "$lkgr_branch" was branched from this commit:
$git_lkgr
... which maps to the svn lkgr commit r${svn_lkgr}. The new branch
has one additional commit, to bring .DEPS.git, .gitmodules, and the
invisible git submodule files up to date with DEPS.
To create a working branch, do this:
\$ git branch --track my_new_branch $lkgr_branch
'git-cl upload' will do the right thing, i.e., it will cherry-pick all
your changes from my_new_branch, but *not* the .DEPS.git+.gitmodules+submodules
commit on $lkgr_branch.
--------------------------------------------------------------------------------
EOF
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment