Add initial version of import script
The script creates new Git repository with complete SVN history of DOSBox project, using correct authorship information and importing tags as real Git tags.
This commit is contained in:
parent
c86cd28b32
commit
963dfbb053
4 changed files with 143 additions and 0 deletions
1
scripts/import-from-svn/.gitignore
vendored
Normal file
1
scripts/import-from-svn/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
dosbox-git-svn-*
|
11
scripts/import-from-svn/copied-from.xslt
Normal file
11
scripts/import-from-svn/copied-from.xslt
Normal file
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
This file transforms svn log xml into path@rev representing copied-from information.
|
||||
You can use it with xsltproc(1): $ svn log -xml -v -l 1 | copied-from.xslt -
|
||||
-->
|
||||
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
|
||||
<xsl:output method="text"/>
|
||||
<xsl:template match="/">
|
||||
<xsl:value-of select="log/logentry/paths/path/@copyfrom-path"/>@<xsl:value-of select="log/logentry/paths/path/@copyfrom-rev"/>
|
||||
</xsl:template>
|
||||
</xsl:stylesheet>
|
122
scripts/import-from-svn/import-from-svn.sh
Executable file
122
scripts/import-from-svn/import-from-svn.sh
Executable file
|
@ -0,0 +1,122 @@
|
|||
#!/bin/bash
|
||||
|
||||
readonly svn_url=https://svn.code.sf.net/p/dosbox/code-0/dosbox
|
||||
|
||||
echo_err () {
|
||||
echo "$@" 1>&2
|
||||
}
|
||||
|
||||
# SVN repository revision. By comparing repo revision we can detect if there
|
||||
# was any activity on any svn path.
|
||||
#
|
||||
svn_get_repo_revision () {
|
||||
svn info "$svn_url" | grep "Revision:" | cut -d' ' -f2
|
||||
}
|
||||
|
||||
# Example usage:
|
||||
#
|
||||
# svn_get_copied_from branches/0_74_3
|
||||
#
|
||||
svn_get_copied_from () {
|
||||
local -r repo_path=$1
|
||||
svn log -v --stop-on-copy --xml "$svn_url/$repo_path" \
|
||||
| xsltproc copied-from.xslt -
|
||||
}
|
||||
|
||||
# Full import takes ~40 minutes
|
||||
#
|
||||
git_svn_clone_dosbox () {
|
||||
local -r repo_name=$1
|
||||
|
||||
git svn init \
|
||||
--stdlayout \
|
||||
"$svn_url" \
|
||||
"$repo_name"
|
||||
|
||||
local -r authors_file=$PWD/svn-dosbox-authors
|
||||
git -C "$repo_name" svn fetch \
|
||||
--authors-file="$authors_file"
|
||||
}
|
||||
|
||||
# Remove UUID of SVN server to avoid issues in case SourceForge will change
|
||||
# it's infrastructure.
|
||||
#
|
||||
git_rewrite_import_links () {
|
||||
local -r repo_name=$1
|
||||
git -C "$repo_name" filter-branch \
|
||||
--msg-filter 'sed "s|git-svn-id: \([^ ]*\) .*|Imported-from: \1|"' \
|
||||
-- --all
|
||||
}
|
||||
|
||||
list_svn_branch_paths () {
|
||||
echo trunk
|
||||
for branch in $(svn ls "$svn_url/branches") ; do
|
||||
echo "${branch///}"
|
||||
done
|
||||
}
|
||||
|
||||
list_svn_tag_paths () {
|
||||
for branch in $(svn ls "$svn_url/tags") ; do
|
||||
echo "${branch///}"
|
||||
done
|
||||
}
|
||||
|
||||
# Go through SVN "branches", that were not removed from SVN yet and create
|
||||
# Git branches out of them using name prefix "svn/" in local repository.
|
||||
#
|
||||
name_active_branches () {
|
||||
local -r repo_name=$1
|
||||
for path in $(list_svn_branch_paths) ; do
|
||||
git -C "$repo_name" branch "svn/$path" "origin/$path"
|
||||
done
|
||||
}
|
||||
|
||||
find_tagged_git_commit () {
|
||||
git -C "$1" log \
|
||||
--grep="$svn_copied_path" \
|
||||
--branches=svn/* \
|
||||
--format=%H
|
||||
}
|
||||
|
||||
# Import SVN "tags" as proper Git tags
|
||||
#
|
||||
# Hopefully upstream never committed to tags…
|
||||
#
|
||||
import_svn_tagpaths_as_git_tags () {
|
||||
local -r repo_name=$1
|
||||
local svn_copied_path
|
||||
local svn_tagged_commit
|
||||
for path in $(list_svn_tag_paths) ; do
|
||||
svn_copied_path=$(svn_get_copied_from "tags/$path")
|
||||
svn_tagged_commit=$(find_tagged_git_commit "$repo_name")
|
||||
git_tag_name="svn/$path"
|
||||
echo "$path: $svn_copied_path -> $svn_tagged_commit -> $git_tag_name"
|
||||
git -C "$repo_name" tag \
|
||||
"$git_tag_name" \
|
||||
"$svn_tagged_commit"
|
||||
done
|
||||
}
|
||||
|
||||
# Remove any unnecessary refs left behind in imported repo
|
||||
#
|
||||
cleanup () {
|
||||
git -C "$1" checkout svn/trunk
|
||||
git -C "$1" branch -D master
|
||||
}
|
||||
|
||||
# main
|
||||
#
|
||||
main () {
|
||||
readonly repo=dosbox-git-svn-$(svn_get_repo_revision)
|
||||
if [ -e "$repo" ] ; then
|
||||
echo_err "Repository '$repo' exists already."
|
||||
exit 1
|
||||
fi
|
||||
git_svn_clone_dosbox "$repo"
|
||||
git_rewrite_import_links "$repo"
|
||||
name_active_branches "$repo"
|
||||
import_svn_tagpaths_as_git_tags "$repo"
|
||||
cleanup "$repo"
|
||||
}
|
||||
|
||||
main "$@"
|
9
scripts/import-from-svn/svn-dosbox-authors
Normal file
9
scripts/import-from-svn/svn-dosbox-authors
Normal file
|
@ -0,0 +1,9 @@
|
|||
qbix79 = Peter Veenstra <qbix79@users.sourceforge.net>
|
||||
harekiet = Sjoerd van der Berg <harekiet@users.sourceforge.net>
|
||||
finsterr = Ulf Wohlers <finsterr@users.sourceforge.net>
|
||||
canadacow = Dean Beeler <canadacow@users.sourceforge.net>
|
||||
yot = Felix Jakschitsch <yot@users.sourceforge.net>
|
||||
c2woody = Sebastian Strohhäcker <c2woody@users.sourceforge.net>
|
||||
h-a-l-9000 = Ralf Grillenberger <h-a-l-9000@users.sourceforge.net>
|
||||
ripsaw8080 = ripsaw8080 <ripsaw8080@users.sourceforge.net>
|
||||
uid83799 = uid83799 <uid83799@users.sourceforge.net>
|
Loading…
Add table
Reference in a new issue