46

I have a 20-year-old project that I would like to migrate from RCS to git, without losing the history. All web pages suggest that the One True Path is through CVS. But after an hour of Googling and trying different scripts, I have yet to find anything that successfully converts my RCS project tree to CVS. I'm hoping the good people at Stackoverflow will know what actually works, as opposed to what is claimed to work and doesn't.

(I searched Stackoverflow using both the native SO search and a Google search, but if there's a helpful answer in the database, I missed it.)

UPDATE: The rcs-fast-export tool at http://git.oblomov.eu/rcs-fast-export was repaired on 14 April 2009, and this version seems to work for me. This tool converts straight to git with no intermediate CVS. Thanks Giuseppe and Jakub!!!


Things that did not work that I still remember:

  • The rcs-to-cvs script that ships in the contrib directory of the CVS sources

  • The rcs-fast-export tool at http://git.oblomov.eu/rcs-fast-export in versions before 13 April 2010

  • The rcs2cvs script found in a document called "CVS-RCS- HOW-TO Document for Linux"

Kai
  • 38,985
  • 14
  • 88
  • 103
Norman Ramsey
  • 198,648
  • 61
  • 360
  • 533
  • 7
    If you've found many ways that *don't* work, and you're asking for ways that do, I think it would be smart to list the ways that didn't work so no one wastes more time :) – Josh Lee Oct 25 '09 at 08:29
  • As a side note, some people reckon the best way from CVS (once you get there) to git is via subversion. http://stackoverflow.com/questions/881158/is-there-a-migration-tool-from-cvs-to-git/881185#881185 – Andrew Grimm Oct 25 '09 at 10:05
  • 1
    Why exactly do you have to keep the history? – hasen Oct 26 '09 at 04:24
  • 14
    Why does anyone keep history? I'm a scientist and engineer and I study software. An artifact with 20 years' worth of history represents irreplaceable data! – Norman Ramsey Oct 26 '09 at 16:35
  • 1
    After reading this post, I was able to convert an RCS repository (with one file) to git. For newcomers, the following Unix commands might help you get started. Make sure that ruby and git are installed. Go to the directory containing your comma-v file (called something like file.txt,v). Type "git --bare init" to create a bare git repository. Type "ruby your/path/to/rcs-fast-export.rb | git fast-import". – Winston C. Yang Jun 27 '10 at 20:23
  • 1
    When I've converted RCS repositories to CVS, I just created a CVS repository and copied the RCS `*,v` files into it. A CVS repository is basically a directory tree with a bunch of RCS-style `*,v` files in it. The `CVSROOT` directory is special, but that's created when the CVS repository is created. – Keith Thompson Feb 03 '12 at 10:35
  • Make sure you use 'git config --global user.name "yourname" ', replacing yourname with your GIT user id. If you don't do this, you will have a failure in the script on Windows machines. Something to do with "gecos". – Rick Papo Dec 17 '21 at 20:24

6 Answers6

26

See Interfaces, frontends, and tools page on Git Wiki, in "Tools", "Interaction with other Revision Control Systems", "Other". There you would find a description and a link to rcs-fast-export (gitweb) Ruby script by Giuseppe "Oblomov" Bilotta.

(Web search would find also Ohloh page and announcement for mentioned project).

wrothe
  • 25
  • 1
  • 6
Jakub Narębski
  • 309,089
  • 65
  • 217
  • 230
  • 3
    to clarify for Norman, a "fast-export" tool is a modern de facto standard for communcating across VCS systems, git's tool to read this data is called `git fast-import` – u0b34a0f6ae Oct 25 '09 at 12:36
  • Unfortunately this tool bombs with a stack trace, starting with an error at line 420. This is fairly typical of my sad experiences. Did I mention that the RCS history covers 20 years? – Norman Ramsey Oct 26 '09 at 04:15
  • Did you try to contact author of rcs-fast-export? It is probable however that it was one-shot conversion tool for author, and script is not maintained. – Jakub Narębski Oct 27 '09 at 00:41
  • 1
    Worked great for me as long as I imported into a fresh/empty git repo (as the command line help implies). But if that didn't work, it sounds like the way to go is `git fast-import`. – dsummersl Jun 18 '12 at 19:58
  • This script works perfectly if you follow its command line instructions. Thanks! – barfuin Aug 27 '14 at 22:09
2

OK, after a little tinkering, I found it was trivial to convert RCS to CVS. The files are in the same format, so it's simply a matter of moving the files into an existing CVS root. This assumes you have access to the RCS files.

# Create CVS root dir. You only need to do this once.
mkdir $HOME/cvs/
cd $HOME/cvs/
cvs init

# Import a repository from RCS to CVS
cp -a _projectname_/RCS $HOME/cvs/_projectname_
Edward Falk
  • 9,991
  • 11
  • 77
  • 112
1

Here I elaborate on Edward Falk's answer by trivially converting from RCS to CVS, then convert CVS to Git. This example uses git-cvsimport to convert from CVS to Git, but any other CVS to Git conversion method should work.

mkdir $HOME/mydir/  # Any directory name will do.
cd $HOME/mydir/
cvs -d $HOME/mydir/ init

# Trivially import an RCS project into CVS.
cp -a /path/to/_projectname_/RCS $HOME/mydir/_projectname_

# Convert the CVS project to Git.
git cvsimport -d $HOME/mydir/ -C mynewgitrepository _projectname_
Flux
  • 9,805
  • 5
  • 46
  • 92
0

I had this problem too and wrestled with cvs2svn, parsecvs and whatnot. parsecvs got the closest but Keith seems to have left it behind and now random forks are popping up. The problem I struck with it was it would parse the RCS files just fine but the last thing it did was git rm the file, so I would have had to muck around with git reset to undo the deletion.

Then I discovered mercurial's convert: https://www.mercurial-scm.org/wiki/ConvertExtension Problem solved!

I tried to incrementally add some stuff from separate RCS trees, it seems to have worked.

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
0

Just found this, which worked fine for me:

http://cynic.cc/blog/posts/migrate-from-rcs-to-git/

Just note that "cvs-source-dir" on that page needs to be a absolute path.

Jonas Berlin
  • 3,344
  • 1
  • 27
  • 33
0

As a general rule you should be careful as to what scripts you run. For RCS -> GIT it may be in your best interest to follow the RCS->CVS->GIT methodology.

Took a quick look at rcs-fast-export.rb as of 2011-01-12 and ran across this portion of the code. This is scary at best.

# steal username/email data from other init files that may contain the
# information
def steal_username
    [
            # the user's .hgrc file for a username field
            ['~/.hgrc',   /^\s*username\s*=\s*(["'])?(.*)\1$/,       2],
            # the user's .(g)vimrc for a changelog_username setting
            ['~/.vimrc',  /changelog_username\s*=\s*(["'])?(.*)\1$/, 2],
            ['~/.gvimrc', /changelog_username\s*=\s*(["'])?(.*)\1$/, 2],
            []
    ].each do |fn, rx, idx|
...
md0
  • 37
  • 2
  • 2
    The terminology may be scary, but there is nothing nefarios going on here. RCS uses unix user names and git wants "First Last " style names. – Ben Martin Feb 04 '15 at 19:00