General comments
For the purpose of converting SVN repo to GIT I’ve used a local Xubuntu 14.04 64bit machine.
Prerequisites:
- librarian access to SVN repo (in our case it will be
libtotsw
account)
- write access to empty GIT repository (in our case it will be repository called
cms-totem-offline
)
We will also need 3 directories:
- svn2git where conversion tool will be compiled
- svnrepo directory with whole SVN repo to be converted
- gitrepo directory where conversion will take place
Migration procedure
Fetching SVN repository
Using librarian account, fetch whole SVN repository to
svnrepo
directory
mkdir svnrepo
rsync -avz libtotsw@lxplus.cern.ch:/afs/cern.ch/project/svn/reps/totem/ svnrepo/
(...)
sent 349,296 bytes received 1,117,648,102 bytes 2,697,219.30 bytes/sec
total size is 1,173,106,973 speedup is 1.05
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1655) [generator=3.1.0]
rsync will complain, as some of the files cannot be copied (i.e.
hooks/*.tmpl
). Ignore it.
Preparing conversion tool
Having some troubles with ruby svn2git tool (
https://github.com/nirvdrum/svn2git
) I decided to use simpler tool (
https://gitorious.org/svn2git
), working on local copies.
For the purpose of migration I used version 1.0.10 which needed some fixes.
Run following commands to download and compile svn2git tool.
git clone git://gitorious.org/svn2git/svn2git.git
cd svn2git
git checkout 1.0.10
qmake -project
qmake
make
You might expect following output:
(...)
g++ -c -m64 -(...) QtCore -I. -o main.o src/main.cpp
src/main.cpp: In function ‘int main(int, char**)’:
src/main.cpp:158:37: error: ‘VER’ was not declared in this scope
printf("Git version: %s\n", VER);
^
make: *** [main.o] Error 1
Fix
Makefile
by adding paths to libraries:
INCPATH = -I/usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++-64 -I. -I. -Isrc -I/usr/include/qt5 -I/usr/include/qt5/QtGui -I/usr/include/qt5/QtCore -I/usr/include/subversion-1/ -I/usr/include/apr-1.0/ -I.
LIBS = $(SUBLIBS) -L/usr/X11R6/lib64 -lQt5Gui -L/usr/lib/x86_64-linux-gnu -lQt5Core -lGL -lpthread -lsvn_fs-1 -lsvn_subr-1 -lapr-1 -lsvn_repos-1
Fix
src/main.cpp
by removing line 158 (
printf("Git version: %s\n", VER);
)
make
Compilation will produce many warnings, simply ignore them.
Migration
Go to
gitrepo
directoryL
cd ..
mkdir gitrepo
cd gitrepo
svn2git
need a set of rules (you can think of them as of mapping between SVN and GIT structure). For every directory there should be a corresponding rule, otherwise svn2git will complain.
Here we provide a set of rules which will copy all contents of SVN repository into new local GIT repository called
full and a single branch from SVN into another local GIT repository called
part. Note that SVN repository structure had in past one element outside normal structure (/dbpop).
Copy template of rules file to local directory
cp ../svn2git/samples/standardlayout.rules subdir.rules
Edit
subdir.rules
to have following content:
create repository full
end repository
create repository part
end repository
match /branches/CMSSW_6_2_0/offline/cmssw/src/
repository part
branch master
end match
match /trunk/
repository full
branch master
end match
match /branches/([^/]+)/
repository full
branch \1
end match
match /tags/([^/]+)/
repository full
branch refs/tags/\1
end match
match /
end match
Run conversion tool (might take some time):
../svn2git/svn2git --identity-domain cern.ch --rules subdir.rules --add-metadata ../svnrepo/
Now it is time to push newly created repo to remote GIT repo at CERN, let us do it with repo called
part
:
cd part
git remote add origin https://git.cern.ch/reps/cms-totem-offline
git push --all
git push --tags
Hints
- default size of newly created repo at CERN is 100MB. If you are planning to migrate larger structure, increase GIT repo size first.
- if something goes wrong and you are planning to clean GIT repo, read this first: Knowledge Base Article: KB0002015
and StackOverflow article
- Let us assume you have Fisheye linked to GIT repo. If you remove something from GIT it will be still visible in Fisheye. You need to request Re-indexing by sending a message to administrators.