Convert CVS to Git

Jun 11, 2014
2 min read
May 31, 2023 18:15 EEST

Install cvs2svn with git support:

cd /usr/ports/devel/cvs2svn
make install
make clean
mkdir migrate-old-repos-to-git
cd !$
cp /usr/local/share/examples/cvs2svn/cvs2git-example.options cvs2git.options

Edit the file like this:

 diff -ud cvs2git.options.old cvs2git.options                                                  idefix@server
--- cvs2git.options.old 2014-06-11 13:00:54.939373946 +0200
+++ cvs2git.options     2014-06-11 13:04:39.698356333 +0200
@@ -188,7 +188,7 @@ ctx.trunk_only = False
 ctx.cvs_author_decoder = CVSTextDecoder(
     [
         #'utf8',
-        #'latin1',
+        'latin1',
         'ascii',
         ],
     #fallback_encoding='ascii'
@@ -196,7 +196,7 @@ ctx.cvs_author_decoder = CVSTextDecoder(
 ctx.cvs_log_decoder = CVSTextDecoder(
     [
         #'utf8',
-        #'latin1',
+        'latin1',
         'ascii',
         ],
     #fallback_encoding='ascii',
@@ -207,7 +207,7 @@ ctx.cvs_log_decoder = CVSTextDecoder(
 ctx.cvs_filename_decoder = CVSTextDecoder(
     [
         #'utf8',
-        #'latin1',
+        'latin1',
         'ascii',
         ],
     #fallback_encoding='ascii'
@@ -513,7 +513,7 @@ ctx.retain_conflicting_attic_files = Fal
 # (name, email).  Please substitute your own project's usernames here
 # to use with the author_transforms option of GitOutputOption below.
 author_transforms={
-    'jrandom' : ('J. Random', 'jrandom@example.com'),
-    'mhagger' : 'Michael Haggerty <mhagger@alum.mit.edu>',
-    'brane' : (u'Branko Čibej', 'brane@xbc.nu'),
-    'ringstrom' : 'Tobias Ringström <tobias@ringstrom.mine.nu>',
-    'dionisos' : (u'Erik Hülsmann', 'e.huelsmann@gmx.net'),
+    'idefix' : ('Matthias Fechner', 'spam@fechner.net'),
@@ -561,7 +561,7 @@ run_options.set_project(
     # The filesystem path to the part of the CVS repository (*not* a
     # CVS working copy) that should be converted.  This may be a
     # subdirectory (i.e., a module) within a larger CVS repository.
-    r'test-data/main-cvsrepos',
+    r'/usr/local/cvs/bericht_pra2',

     # A list of symbol transformations that can be used to rename
     # symbols in this project.
export repo=bericht_pra2

mkdir cvs2git-tmp
cvs2git --options=cvs2git.options
mkdir ${repo}.git
cd ${repo}.git
git init --bare
git fast-import --export-marks=../cvs2git-tmp/git-marks.dat < ../cvs2git-tmp/git-blob.dat
git fast-import --import-marks=../cvs2git-tmp/git-marks.dat < ../cvs2git-tmp/git-dump.dat
git gc
git remote add origin git@localhost:${repo}
git push origin
cd ..

rm -Rf ${repo}.git cvs2git-tmp
rm -Rf /usr/local/cvs/${repo}

Related Posts