Project

General

Profile

Using cvs2git » History » Version 1

Marc Mengel, 11/15/2012 05:54 PM

1 1 Marc Mengel
h1. Using cvs2git
2 1 Marc Mengel
3 1 Marc Mengel
p. Some users have expressed an interest in migrating their existing CVS repositories
4 1 Marc Mengel
to Git.  This wiki page will attempt to walk you through the process. 
5 1 Marc Mengel
6 1 Marc Mengel
p. There are a few steps to converting CVS modules to Git here on cdcvs: 
7 1 Marc Mengel
8 1 Marc Mengel
* Finding your existing cvs module
9 1 Marc Mengel
* checking for space requirements
10 1 Marc Mengel
* environment setup
11 1 Marc Mengel
* running cvs2git
12 1 Marc Mengel
* secondary cleanup
13 1 Marc Mengel
14 1 Marc Mengel
We'll go through them in detail.
15 1 Marc Mengel
16 1 Marc Mengel
h2. Finding your existing module
17 1 Marc Mengel
18 1 Marc Mengel
You need to know the $CVSROOT value for your repository for this part.  You can look in a checked-out
19 1 Marc Mengel
copy at the CVS/Root file if  you're not sure what it is.  The examples here will be as if you had a Redmine-created
20 1 Marc Mengel
repository 'myproject', which would have a $CVSROOT value of p-myproject@cdcvs.fnal.gov/cvs/projects/myproject.
21 1 Marc Mengel
22 1 Marc Mengel
You want to ssh into cdcvs using the user@cdcvs part of your $CVSROOT. 
23 1 Marc Mengel
24 1 Marc Mengel
<pre>
25 1 Marc Mengel
$ ssh p-myproject@cdcvs.fnal.gov
26 1 Marc Mengel
Last login: ...
27 1 Marc Mengel
$
28 1 Marc Mengel
</pre>
29 1 Marc Mengel
30 1 Marc Mengel
Then change directories to the directory part of your $CVSROOT.  
31 1 Marc Mengel
32 1 Marc Mengel
<pre>
33 1 Marc Mengel
$ cd /cvs/projects/myproject
34 1 Marc Mengel
$ ls
35 1 Marc Mengel
CVSROOT myproject
36 1 Marc Mengel
$
37 1 Marc Mengel
</pre>
38 1 Marc Mengel
39 1 Marc Mengel
h2. Check for space
40 1 Marc Mengel
41 1 Marc Mengel
There needs to be at least double the space your package takes free for the conversion.
42 1 Marc Mengel
43 1 Marc Mengel
<pre>
44 1 Marc Mengel
$ du -sk myproject
45 1 Marc Mengel
800	myproject
46 1 Marc Mengel
-bash-4.1$ df -k .
47 1 Marc Mengel
Filesystem           1K-blocks      Used Available Use% Mounted on
48 1 Marc Mengel
blue1:/cdcvs         314572800 240312928  74259872  77% /cvs
49 1 Marc Mengel
</pre>
50 1 Marc Mengel
51 1 Marc Mengel
So the Available space (the 74259872 in the above example) must be atleast double the size of the project (800 in the above example) to consider proceeding.  If it isn't, or it's within 10% or so, please put in a servicedesk ticket, and ask us to 
52 1 Marc Mengel
make grow the filesystem. 
53 1 Marc Mengel
54 1 Marc Mengel
h2. Setup your environment
55 1 Marc Mengel
56 1 Marc Mengel
You'll probably need to use the cvs 1.12 that we use behind Redmine to do the conversion, and with
57 1 Marc Mengel
our /usr/local/bin/cvs_wrap script to hide some WARNINGS it gives that cvs2git doesn't like.
58 1 Marc Mengel
59 1 Marc Mengel
<pre>
60 1 Marc Mengel
$ . /fnal/ups/etc/setups.sh
61 1 Marc Mengel
$ setup cvs v1_12_13p1
62 1 Marc Mengel
$ echo $CVS_DIR
63 1 Marc Mengel
/fnal/ups/db/../prd/cvs/v1_12_13p1/Linux-2
64 1 Marc Mengel
$ setup git
65 1 Marc Mengel
$ echo $GIT_UPS_DIR
66 1 Marc Mengel
/fnal/ups/db/../prd/git/v1_6_4/Linux-2
67 1 Marc Mengel
68 1 Marc Mengel
</pre>
69 1 Marc Mengel
70 1 Marc Mengel
h2. Run the cvs2git tool
71 1 Marc Mengel
72 1 Marc Mengel
<pre>
73 1 Marc Mengel
$ cvs2git \
74 1 Marc Mengel
    --blobfile=cvs2svn-tmp/git-blob.dat \
75 1 Marc Mengel
    --dumpfile=cvs2svn-tmp/git-dump.dat \
76 1 Marc Mengel
    --username=cvs2git \
77 1 Marc Mengel
    --cvs=/usr/local/bin/cvs_wrap \
78 1 Marc Mengel
   `pwd`/my-module
79 1 Marc Mengel
Examining all CVS ',v' files...
80 1 Marc Mengel
/cvs/projects/myproject...,v
81 1 Marc Mengel
/cvs/projects/myproject...,v
82 1 Marc Mengel
...
83 1 Marc Mengel
Timings (seconds):
84 1 Marc Mengel
------------------
85 1 Marc Mengel
 9.43   pass1    CollectRevsPass
86 1 Marc Mengel
 0.03   pass2    CleanMetadataPass
87 1 Marc Mengel
 0.01   pass3    CollateSymbolsPass
88 1 Marc Mengel
...
89 1 Marc Mengel
10.05   total
90 1 Marc Mengel
$ 
91 1 Marc Mengel
</pre>
92 1 Marc Mengel
93 1 Marc Mengel
Then actually setup the git repository, and pull in the dump that cvs2git made
94 1 Marc Mengel
95 1 Marc Mengel
<pre>
96 1 Marc Mengel
$ mkdir myproject.git
97 1 Marc Mengel
$ cd myproject.git
98 1 Marc Mengel
$ git init --bare --shared
99 1 Marc Mengel
$ git update-server-info
100 1 Marc Mengel
$ cat ../cvs2svn-tmp/git-blob.dat ../cvs2svn-tmp/git-dump.dat | git fast-import
101 1 Marc Mengel
$ git gc --prune=now
102 1 Marc Mengel
</pre>
103 1 Marc Mengel
104 1 Marc Mengel
h2. Clean up
105 1 Marc Mengel
106 1 Marc Mengel
<pre>
107 1 Marc Mengel
$ cd ..
108 1 Marc Mengel
$ rm -rf cvs2svn-tmp
109 1 Marc Mengel
</pre>