aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/roll_autogen.sh
blob: 2567a1307faebb913c88d3d71d61b8410dfb4444 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#/bin/bash
# Copyright (c) 2012 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

# roll_autogen.sh: Helper script for removing old revisions from an svn
# repository.  Unfortunately, the only way to discard old revisions is to clone
# the repository locally, use svnadmin to dump a range of commits from the local
# copy, re-import them into a brand-new repository, "reset" the original repo,
# and then import the commits from the new repository into the original.  This
# script automates all of that except for resetting the original repository.

REPO=${REPO:-"https://skia-autogen.googlecode.com"}
REVS_TO_KEEP=${REVS_TO_KEEP:-50}
REPO_SVN="${REPO}/svn"
CLONE_DIR="local_clone_dir"
LOCAL_CLONE="$(pwd)/${CLONE_DIR}"

echo "Creating local repository in ${LOCAL_CLONE}"
svnadmin create ${LOCAL_CLONE}
pushd ${LOCAL_CLONE}/hooks > /dev/null
echo "#!/bin/sh" > pre-revprop-change
chmod 755 pre-revprop-change 
popd > /dev/null

# Determine the latest revision.  Note that any revisions committed while we
# were syncing will be lost forever!
END=`svn info ${REPO_SVN} | grep Revision | cut -c11-`
START=$((END-REVS_TO_KEEP))
DUMPFILE="skia-autogen_r${START}-${END}.dump"

echo "Cloning ${REPO_SVN} into ${LOCAL_CLONE}..."
svnsync init file://${LOCAL_CLONE} ${REPO_SVN}
svnsync --non-interactive sync file://${LOCAL_CLONE}

echo "Dumping revisions ${START} to ${END} to ${DUMPFILE}."
svnadmin dump --revision ${START}:${END} ${LOCAL_CLONE} > ${DUMPFILE}

echo "Removing temporary local clone."
rm -rf ${LOCAL_CLONE}

echo "Re-creating local clone from ${DUMPFILE}."
svnadmin create ${LOCAL_CLONE}
svnadmin load ${LOCAL_CLONE} < ${DUMPFILE}

echo "Deleting ${DUMPFILE}"
rm ${DUMPFILE}

echo "Now you need to reset the remote repository. Typically, a link to do this"
echo "can be found at (${REPO}/adminSource).
echo "Please do so and press any key to continue."
read -n 1 -s

echo "Syncing ${LOCAL_CLONE} to ${REPO_SVN}."
svnsync init ${REPO_SVN} file://${LOCAL_CLONE}
svnsync sync ${REPO_SVN}

echo "Removing temporary local clone."
rm -rf ${LOCAL_CLONE}

echo "Removing local checkout."
rm -rf ${CHECKOUT_DIR}

echo "Finished!"