Project

General

Profile

Using cvs2git » History » Version 13

Marc Mengel, 01/02/2013 05:27 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 7 Marc Mengel
to Git.  This wiki page will attempt to walk you through the process.   We'll be showing
5 7 Marc Mengel
the commands you type and the output you get in the following format:
6 7 Marc Mengel
7 7 Marc Mengel
p{border:1px solid black}. *@command you type@*
8 7 Marc Mengel
@output you get@
9 1 Marc Mengel
10 8 Marc Mengel
h2. Overview
11 8 Marc Mengel
12 1 Marc Mengel
p. There are a few steps to converting CVS modules to Git here on cdcvs: 
13 1 Marc Mengel
14 1 Marc Mengel
* Finding your existing cvs module
15 1 Marc Mengel
* checking for space requirements
16 1 Marc Mengel
* environment setup
17 1 Marc Mengel
* running cvs2git
18 2 Marc Mengel
* undumping into the repository
19 2 Marc Mengel
* cleanup
20 1 Marc Mengel
21 1 Marc Mengel
We'll go through them in detail.
22 1 Marc Mengel
23 1 Marc Mengel
h2. Finding your existing module
24 1 Marc Mengel
25 1 Marc Mengel
You need to know the $CVSROOT value for your repository for this part.  You can look in a checked-out
26 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
27 1 Marc Mengel
repository 'myproject', which would have a $CVSROOT value of p-myproject@cdcvs.fnal.gov/cvs/projects/myproject.
28 1 Marc Mengel
29 1 Marc Mengel
You want to ssh into cdcvs using the user@cdcvs part of your $CVSROOT. 
30 1 Marc Mengel
31 4 Marc Mengel
p{border:1px solid black}. *@ssh p-myproject@@@cdcvs.fnal.gov@*
32 2 Marc Mengel
@Last login: ...@
33 1 Marc Mengel
34 2 Marc Mengel
35 1 Marc Mengel
Then change directories to the directory part of your $CVSROOT.  
36 1 Marc Mengel
37 1 Marc Mengel
38 3 Marc Mengel
p{border:1px solid black}. *@cd /cvs/projects/myproject@*
39 2 Marc Mengel
*@ls@*
40 2 Marc Mengel
@CVSROOT myproject@
41 2 Marc Mengel
42 1 Marc Mengel
h2. Check for space
43 1 Marc Mengel
44 1 Marc Mengel
There needs to be at least double the space your package takes free for the conversion.
45 1 Marc Mengel
46 4 Marc Mengel
p{border:1px solid black}. *@du -sk myproject@*
47 2 Marc Mengel
@800	myproject@
48 2 Marc Mengel
*@df -k .@*
49 6 Marc Mengel
@Filesystem            1K-blocks        Used Available Use% Mounted on@
50 2 Marc Mengel
@blue1:/cdcvs         314572800 240312928  74259872  77% /cvs@
51 1 Marc Mengel
52 1 Marc Mengel
53 6 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 grow the filesystem. 
54 1 Marc Mengel
55 1 Marc Mengel
h2. Setup your environment
56 1 Marc Mengel
57 1 Marc Mengel
You'll probably need to use the cvs 1.12 that we use behind Redmine to do the conversion, and with
58 1 Marc Mengel
our /usr/local/bin/cvs_wrap script to hide some WARNINGS it gives that cvs2git doesn't like.
59 1 Marc Mengel
60 3 Marc Mengel
p{border:1px solid black}. *@. /fnal/ups/etc/setups.sh@*
61 2 Marc Mengel
*@setup cvs v1_12_13p1@*
62 2 Marc Mengel
*@echo $CVS_DIR@*
63 2 Marc Mengel
@/fnal/ups/db/../prd/cvs/v1_12_13p1/Linux-2@
64 2 Marc Mengel
*@setup git@*
65 2 Marc Mengel
*@echo $GIT_UPS_DIR@*
66 2 Marc Mengel
@/fnal/ups/db/../prd/git/v1_6_4/Linux-2@
67 1 Marc Mengel
68 1 Marc Mengel
h2. Run the cvs2git tool
69 1 Marc Mengel
70 2 Marc Mengel
71 3 Marc Mengel
p{border:1px solid black}. *@ cvs2git \@*
72 5 Marc Mengel
*@   --blobfile=cvs2svn-tmp/git-blob.dat \@*
73 5 Marc Mengel
*@   --dumpfile=cvs2svn-tmp/git-dump.dat \@*
74 5 Marc Mengel
*@   --username=cvs2git \@*
75 5 Marc Mengel
*@   --cvs=/usr/local/bin/cvs_wrap \@*
76 5 Marc Mengel
*@   --cvs=/usr/local/bin/cvs_wrap \@*
77 5 Marc Mengel
*@   `pwd`/my-module@*
78 2 Marc Mengel
@Examining all CVS ',v' files...@
79 2 Marc Mengel
@/cvs/projects/myproject...,v@
80 2 Marc Mengel
@/cvs/projects/myproject...,v@
81 2 Marc Mengel
@...@
82 2 Marc Mengel
@Timings (seconds):@
83 2 Marc Mengel
@------------------@
84 2 Marc Mengel
@ 9.43   pass1    CollectRevsPass@
85 2 Marc Mengel
@ 0.03   pass2    CleanMetadataPass@
86 2 Marc Mengel
@ 0.01   pass3    CollateSymbolsPass@
87 2 Marc Mengel
@...@
88 1 Marc Mengel
@10.05   total@
89 1 Marc Mengel
90 1 Marc Mengel
Then actually setup the git repository, and pull in the dump that cvs2git made
91 1 Marc Mengel
92 3 Marc Mengel
p{border:1px solid black}. *@ mkdir myproject.git@*
93 3 Marc Mengel
*@ cd myproject.git@*
94 3 Marc Mengel
*@ git init --bare --shared@*
95 3 Marc Mengel
*@ git update-server-info@*
96 3 Marc Mengel
*@ cat ../cvs2svn-tmp/git-blob.dat ../cvs2svn-tmp/git-dump.dat | git fast-import@*
97 3 Marc Mengel
*@ git gc --prune=now@*
98 1 Marc Mengel
99 13 Marc Mengel
h2. Setup for http access
100 13 Marc Mengel
101 13 Marc Mengel
p{border:1px solid black}. *@cd myproject.git/hooks@*
102 13 Marc Mengel
*@mv post-update.sample post-update@*
103 13 Marc Mengel
104 13 Marc Mengel
105 13 Marc Mengel
106 1 Marc Mengel
h2. Clean up
107 1 Marc Mengel
108 3 Marc Mengel
p{border:1px solid black}. *@ cd .. @*
109 3 Marc Mengel
*@ rm -rf cvs2svn-tmp @*
110 9 Marc Mengel
111 9 Marc Mengel
h2. Update Redmine
112 9 Marc Mengel
113 9 Marc Mengel
If your repository is affiliated with  a Redmine project, you can now set Redmine to look at your new repository.
114 9 Marc Mengel
115 11 Marc Mengel
* Go to the %{background-color:#507AAA;color: #fff; padding: 3px}Settings% tab of your project
116 10 Marc Mengel
117 12 Marc Mengel
* Click on the %{border: 1px  #888; border-style: solid  solid none solid; background: #aaa; padding: 3px}Repositories% sub-tab.
118 10 Marc Mengel
119 10 Marc Mengel
* Click on the %(icon icon-del)Delete%  link next to the current repository (this doesn't delete the actual files, just Redmine's info about where the repository is).
120 10 Marc Mengel
* Click the  %(icon icon-add)New repository% link
121 10 Marc Mengel
* Choose "Git" for the *SCM*
122 10 Marc Mengel
* Check the *Main Repository* checkbox
123 10 Marc Mengel
* Put the full path to your new my-project.git directory in the *Path to repository* box.
124 10 Marc Mengel
125 12 Marc Mengel
* Click %{border: 1px solid #888; padding: 3px; background: #aaa}Save%