tools: Remove obsolete svn information.
Reviewed by: jhb@ Differential Revision: https://reviews.freebsd.org/D30720 Sponsored by: Netflix
This commit is contained in:
parent
ab6d05336c
commit
07d72396f8
@ -1,7 +1,7 @@
|
||||
# $FreeBSD$
|
||||
|
||||
This directory contains tools intended to help committers use git when
|
||||
interacting with standard FreeBSD project resources like Differential or svn.
|
||||
interacting with standard FreeBSD project resources like Differential.
|
||||
|
||||
I. arcgit
|
||||
|
||||
@ -113,54 +113,3 @@ commits. The intended workflow is:
|
||||
|
||||
At this point, you are ready to commit your changes to head. The importgit
|
||||
script can be used to import your commits directly into git.
|
||||
|
||||
II. importgit
|
||||
|
||||
importgit is a script that can take a series of commits from git and commit them
|
||||
to a svn repository. The script uses the git commit messages for the svn commit
|
||||
message, which allows importgit to be fully automated. This does mean that once
|
||||
you start importgit, it will start commit things to svn without giving any
|
||||
further chance to sanity check what it's doing.
|
||||
|
||||
importgit only supports importing commits that add or modify files. It does not
|
||||
support importing commits that rename or delete files, to ensure that git's
|
||||
rename detection heuristics do not introduce an error in the import process.
|
||||
importgit also does not support importing merge commits. Only linear history
|
||||
can be imported into svn.
|
||||
|
||||
importgit must be run from a clean subversion checkout. You should ensure that
|
||||
the working tree is up-to-date with "svn up" before running importgit.
|
||||
importgit will run svn directly, so make sure that your ssh-agent is running
|
||||
and has your ssh key loaded already. Run importgit as follows:
|
||||
|
||||
$ importgit -r D1~..D2 -g /path/to/git/repo
|
||||
|
||||
This will import every commit between D1 and D2, including both D1 and D2. The
|
||||
invocation is very similar to the invocation given to arcgit but there is an
|
||||
important point to note. When you rebased your commits as you followed steps 4
|
||||
and 5, the commit hashes of all of your commits changed, including C1 and C2.
|
||||
You must go back and find the new commit hashes of your commits to pass to
|
||||
importgit. Passing -r C1~..C2 would import your commits as they were *before*
|
||||
your code review fixes were applied.
|
||||
|
||||
III. git-svn-rebase
|
||||
|
||||
git-svn-rebase is a script that helps you keep current when using git
|
||||
plus subversion as outline in https://wiki.freebsd.org/GitWorkflow/GitSvn
|
||||
since it's otherwise a pain to have many branches active. It will rebase
|
||||
those branches that haven't been merged yet. Some tweaking may be needed
|
||||
if you have other, weird branches in your tree (including any stable
|
||||
branches). To run it just cd into the git subversion tree somewhere and
|
||||
type
|
||||
$ git-svn-rebase
|
||||
and it will do its thing and leave the tree on the master branch.
|
||||
|
||||
Your tree must be clean to start this, and while it tries to catch
|
||||
some failures, not all of them have been allowed for.
|
||||
|
||||
IV. git-svn-init
|
||||
git-svn-init is a script that initializes the right git-svn connection as
|
||||
outlined in https://wiki.freebsd.org/GitWorkflow/GitSvn. It would be a precursor
|
||||
to the script git-svn-rebase. The script contains help, but generally you can
|
||||
run the script with no arguments and it will attempt to set up both src and
|
||||
ports repositories.
|
||||
|
@ -1,211 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
# $FreeBSD$
|
||||
|
||||
# SPDX-License-Identifier: BSD-2-Clause-FreeBSD
|
||||
#
|
||||
# Copyright(c) 2018 Intel Corporation.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
# SUCH DAMAGE.
|
||||
|
||||
# This is the codified version of what was/is on the wiki page for using git in
|
||||
# your workflow. It sets up proper repositories, with the correct remotes.
|
||||
|
||||
# Environment variables which can be overridden if desired. Not worth
|
||||
# parameterizing them.
|
||||
GIT_IN_PATH=$(which git)
|
||||
GIT=${GIT-${GIT_IN_PATH}}
|
||||
|
||||
GIT_DOCS_REPO=${GIT_DOCS_REPO-git://github.com/freebsd/freebsd-doc.git}
|
||||
GIT_SVN_DOCS_ROOT_URI=${GIT_SVN_DOCS_ROOT_URI-svn.freebsd.org/doc}
|
||||
GIT_SVN_DOCS_URI=${GIV_SVN_DOCS_URI-repo.freebsd.org/doc}
|
||||
|
||||
GIT_PORTS_REPO=${GIT_PORTS_REPO-git://github.com/freebsd/freebsd-ports.git}
|
||||
GIT_SVN_PORTS_ROOT_URI=${GIT_SVN_PORTS_ROOT_URI-svn.freebsd.org/ports}
|
||||
GIT_SVN_PORTS_URI=${GIT_SVN_PORTS_URI-repo.freebsd.org/ports}
|
||||
|
||||
GIT_SRC_REPO=${GIT_SRC_REPO-git://github.com/freebsd/freebsd.git}
|
||||
GIT_SVN_SRC_ROOT_URI=${GIT_SVN_SRC_ROOT_URI-svn.freebsd.org/base}
|
||||
GIT_SVN_SRC_URI=${GIT_SVN_SRC_URI-repo.freebsd.org/base}
|
||||
|
||||
GIT_SVN_DOCS_PUSH_URI=$GIT_SVN_DOCS_URI
|
||||
GIT_SVN_PORTS_PUSH_URI=$GIT_SVN_PORTS_URI
|
||||
GIT_SVN_SRC_PUSH_URI=$GIT_SVN_SRC_URI
|
||||
|
||||
usage()
|
||||
{
|
||||
cat <<EOF
|
||||
Usage: git-svn-init: [-b base_path] [-n] [-p] [-s]
|
||||
|
||||
git-svn-init will instantiate git repositories for src, and ports and connect
|
||||
them to the upstream SVN repository. By default it will attempt to do this for
|
||||
both ports and src under freebsd in the current working directory.
|
||||
-b Base path for the clone operation (default: freebsd)
|
||||
-n Dry run
|
||||
-p Exclude ports
|
||||
-s Exclude src
|
||||
-d Exclude docs
|
||||
|
||||
EOF
|
||||
}
|
||||
|
||||
clone()
|
||||
{
|
||||
echo "Cloning ${3}"
|
||||
${GIT} clone "$repo" -o upstream "$base"/${3}
|
||||
}
|
||||
|
||||
svn_init()
|
||||
{
|
||||
# init git-svn to point to the subversion repo:
|
||||
${GIT} svn init -Thead --rewrite-root=svn+ssh://$1 svn+ssh://$2 .
|
||||
|
||||
# Replace to use upstream instead of the default origin
|
||||
# TODO: Do this from git svn init
|
||||
${GIT} config svn-remote.svn.fetch head:refs/remotes/upstream/trunk
|
||||
|
||||
# Committers need to use proper URL for dcommit
|
||||
${GIT} config svn-remote.svn.pushurl svn+ssh://$3
|
||||
|
||||
}
|
||||
|
||||
svn_check()
|
||||
{
|
||||
cat <<EOF
|
||||
[svn-remote "svn"]
|
||||
url = svn+ssh://repo.freebsd.org/base
|
||||
rewriteRoot = svn+ssh://svn.freebsd.org/base
|
||||
pushurl = svn+ssh://repo.freebsd.org/base
|
||||
fetch = head:refs/remotes/upstream/trunk
|
||||
EOF
|
||||
[ -z ${DRY_RUN} ] && grep -A4 'svn-remote "svn"' .git/config
|
||||
}
|
||||
|
||||
svn_connect()
|
||||
{
|
||||
# Now make a git branch 'trunk' for git-svn to follow. What we want to
|
||||
# do it set it to point to the final commit in upstream/svn_head.
|
||||
local svn_head_sha=$(git show-ref upstream/svn_head|cut -d" " -f1)
|
||||
${GIT} update-ref refs/remotes/upstream/trunk $svn_head_sha # git-svn really needs this branch
|
||||
}
|
||||
|
||||
svn_fetch()
|
||||
{
|
||||
${GIT} svn fetch
|
||||
}
|
||||
|
||||
git_pulls()
|
||||
{
|
||||
# Get pull requests from the repos:
|
||||
${GIT} config --add remote.upstream.fetch '+refs/pull/*:refs/remotes/upstream/pull/*'
|
||||
${GIT} fetch
|
||||
}
|
||||
|
||||
git_checkout()
|
||||
{
|
||||
# Arrange to have 'master' reference 'trunk'
|
||||
${GIT} checkout trunk
|
||||
|
||||
# Make master reference trunk
|
||||
${GIT} branch --force master trunk
|
||||
${GIT} checkout master
|
||||
}
|
||||
|
||||
rebase()
|
||||
{
|
||||
${GIT} svn rebase
|
||||
}
|
||||
|
||||
doit()
|
||||
{
|
||||
local repo=${1}
|
||||
local base=${2}
|
||||
|
||||
if [ "$3" = "src" ] ; then
|
||||
local svn_root_uri=$GIT_SVN_SRC_ROOT_URI
|
||||
local svn_uri=$GIT_SVN_SRC_URI
|
||||
local svn_push_uri=$GIT_SVN_SRC_PUSH_URI
|
||||
elif [ "$3" = "docs" ] ; then
|
||||
local svn_root_uri=$GIT_SVN_DOCS_ROOT_URI
|
||||
local svn_uri=$GIT_SVN_DOCS_URI
|
||||
local svn_push_uri=$GIT_SVN_DOCS_PUSH_URI
|
||||
elif [ "$3" = "ports" ] ; then
|
||||
local svn_root_uri=$GIT_SVN_PORTS_ROOT_URI
|
||||
local svn_uri=$GIT_SVN_PORTS_URI
|
||||
local svn_push_uri=$GIT_SVN_PORTS_PUSH_URI
|
||||
fi
|
||||
|
||||
clone ${repo} ${base} ${3}
|
||||
|
||||
cd "$base"/${3}
|
||||
svn_init $svn_root_uri $svn_uri $svn_push_uri
|
||||
svn_check $(basename $svn_uri) # get base or ports, not src/ports.
|
||||
svn_connect
|
||||
svn_fetch
|
||||
git_pulls
|
||||
git_checkout
|
||||
rebase
|
||||
|
||||
cd -
|
||||
}
|
||||
|
||||
ports=1
|
||||
source=1
|
||||
docs=1
|
||||
while getopts "hb:nr:sdp" opt; do
|
||||
case "$opt" in
|
||||
b)
|
||||
base_path="$OPTARG"
|
||||
;;
|
||||
n)
|
||||
DRY_RUN=1
|
||||
;;
|
||||
p)
|
||||
ports=0
|
||||
;;
|
||||
s)
|
||||
source=0
|
||||
;;
|
||||
d)
|
||||
docs=0
|
||||
;;
|
||||
h|*)
|
||||
usage
|
||||
exit 0
|
||||
esac
|
||||
done
|
||||
|
||||
if [ ! -z "${DRY_RUN}" ] ; then
|
||||
GIT='echo git'
|
||||
fi
|
||||
|
||||
if [ "$source" -eq 1 ]; then
|
||||
doit ${GIT_SRC_REPO} ${base_path:-freebsd} "src"
|
||||
fi
|
||||
|
||||
if [ "$ports" -eq 1 ]; then
|
||||
doit ${GIT_PORTS_REPO} ${base_path:-freebsd} "ports"
|
||||
fi
|
||||
|
||||
if [ "$docs" -eq 1 ]; then
|
||||
doit ${GIT_DOCS_REPO} ${base_path:-freebsd} "docs"
|
||||
fi
|
@ -1,57 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
# $FreeBSD$
|
||||
|
||||
# SPDX-License-Identifier: BSD-2-Clause-FreeBSD
|
||||
#
|
||||
# Copyright (c) 2018 M. Warner Losh <imp@FreeBSD.org>
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
# SUCH DAMAGE.
|
||||
|
||||
#
|
||||
# simple script to keep all my branches up to date while tracking
|
||||
# FreeBSD (or any upstream svn source) with git. Run it often, and it
|
||||
# will rebase all the branches so they don't get too stale.
|
||||
# Takes no args, and acts goofy if you have really old branches
|
||||
# which is why stable/* and mfc* are excluded. Caution to should be taken
|
||||
# when using this.
|
||||
#
|
||||
|
||||
FAIL=
|
||||
echo ----------------- Checkout master for svn rebase ------------
|
||||
git checkout master
|
||||
echo ----------------- Rebasing our master to svn upstream ------------
|
||||
git svn rebase
|
||||
for i in $(git branch --no-merge | grep -v stable/ | grep -v mfc); do
|
||||
echo ----------------- Rebasing $i to the tip of master ------------
|
||||
git rebase master $i || {
|
||||
echo "****************** REBASE OF $i FAILED, ABORTING *****************"
|
||||
FAIL="$FAIL $i"
|
||||
git rebase --abort
|
||||
}
|
||||
done
|
||||
echo ----------------- Checkout out master again ------------
|
||||
git checkout master
|
||||
git branch
|
||||
if [ -n "$FAIL" ]; then
|
||||
echo Failed branches: $FAIL
|
||||
fi
|
@ -1,182 +0,0 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Copyright (c) 2015 Ryan Stone. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
# SUCH DAMAGE.
|
||||
#
|
||||
# $FreeBSD$
|
||||
|
||||
usage()
|
||||
{
|
||||
echo "Usage: importgit <-c commit | -r c1..c2> -g /path/to/git/repo [-n]" >&2
|
||||
}
|
||||
|
||||
error()
|
||||
{
|
||||
local print_usage
|
||||
|
||||
if [ "$1" = "-u" ]
|
||||
then
|
||||
shift
|
||||
print_usage=1
|
||||
else
|
||||
print_usage=
|
||||
fi
|
||||
|
||||
echo "$@" >&2
|
||||
if [ -n "$print_usage" ]
|
||||
then
|
||||
usage
|
||||
fi
|
||||
exit 1
|
||||
}
|
||||
|
||||
unset git_repo range commit dry_run
|
||||
|
||||
while getopts ":c:g:nr:" o
|
||||
do
|
||||
case "$o" in
|
||||
c)
|
||||
range="${OPTARG}~..${OPTARG}"
|
||||
;;
|
||||
g)
|
||||
git_repo=$OPTARG
|
||||
;;
|
||||
n)
|
||||
dry_run=1
|
||||
;;
|
||||
r)
|
||||
range=$OPTARG
|
||||
;;
|
||||
*)
|
||||
error -u "Unrecognized argument '-$OPTARG'"
|
||||
esac
|
||||
done
|
||||
|
||||
shift $((OPTIND - 1))
|
||||
OPTIND=1
|
||||
|
||||
if [ -n "$1" ]
|
||||
then
|
||||
error -u "Unrecognized argument $1"
|
||||
fi
|
||||
|
||||
if [ -z "$range" ]
|
||||
then
|
||||
error -u "-c or -r argument is mandatory"
|
||||
fi
|
||||
|
||||
if ! echo "$range" | egrep -qs '^[^.]+\.\.[^.]*$'
|
||||
then
|
||||
error -u "$range is not a range of commits. Did you mean '-c $range'?"
|
||||
fi
|
||||
|
||||
if [ -z "$git_repo" ]
|
||||
then
|
||||
error -u "-g <repo> argument is mandatory"
|
||||
fi
|
||||
|
||||
if ! type git > /dev/null 2> /dev/null
|
||||
then
|
||||
error "Install devel/git first"
|
||||
fi
|
||||
|
||||
GIT="git -C $git_repo"
|
||||
|
||||
if ! $GIT rev-parse --git-dir 2> /dev/null > /dev/null
|
||||
then
|
||||
error "$git_repo does not seem to be a git repo"
|
||||
fi
|
||||
|
||||
if ! type svn > /dev/null 2> /dev/null
|
||||
then
|
||||
error "Install devel/subversion first"
|
||||
fi
|
||||
|
||||
if [ -n "$(svn status)" ]
|
||||
then
|
||||
error "Working tree is not clean"
|
||||
fi
|
||||
|
||||
if ! svn --non-interactive ls > /dev/null
|
||||
then
|
||||
error "Could not communicate with svn server. Is your ssh key loaded?"
|
||||
fi
|
||||
|
||||
$GIT log --format=%H $range | tail -r | while read -r commit
|
||||
do
|
||||
echo "Applying `$GIT show -s --oneline $commit`"
|
||||
|
||||
if [ -n "$($GIT show --diff-filter=CDRTUXB $commit)" ]
|
||||
then
|
||||
error "Commit performed unsupported change (e.g. delete/rename)"
|
||||
fi
|
||||
|
||||
if [ "$($GIT show -s --format=%P $commit | wc -w)" -ne 1 ]
|
||||
then
|
||||
error "Cannot import merge commits"
|
||||
fi
|
||||
|
||||
$GIT diff --diff-filter=A --name-only \
|
||||
${commit}~..$commit | while read -r newfile
|
||||
do
|
||||
if [ -f "$newfile" ]
|
||||
then
|
||||
error "New file $newfile already exists in tree"
|
||||
fi
|
||||
done
|
||||
|
||||
# The previous while loop ran in a subshell, so we have to check if it
|
||||
# exited with an error and bail out if so.
|
||||
ret=$?
|
||||
if [ "$ret" -ne 0 ]
|
||||
then
|
||||
exit $ret
|
||||
fi
|
||||
|
||||
if [ -n "$dry_run" ]
|
||||
then
|
||||
continue
|
||||
fi
|
||||
|
||||
$GIT show $commit | patch -p 1 -s || \
|
||||
error "Failed to apply patch"
|
||||
|
||||
$GIT diff --diff-filter=A --name-only \
|
||||
${commit}~..$commit | while read -r newfile
|
||||
do
|
||||
svn add --parents --depth=infinity $newfile || \
|
||||
error "Failed to add new file"
|
||||
done
|
||||
|
||||
# The previous while loop ran in a subshell, so we have to check if it
|
||||
# exited with an error and bail out if so.
|
||||
ret=$?
|
||||
if [ "$ret" -ne 0 ]
|
||||
then
|
||||
exit $ret
|
||||
fi
|
||||
|
||||
$GIT show -s --format='%B' $commit | svn commit -F - || \
|
||||
error "Failed to commit"
|
||||
done
|
||||
|
Loading…
x
Reference in New Issue
Block a user