How to import eclipse.org’s CVS into git with git-cvsimport

In order to be able to update a local git repository later with changes from the foreign remote repository (which is Eclipse.org’s CVS repository in my case) I have to store CVS metadata somewhere. The first place which pops up in my mind is .git/config and git-svn uses this approach for storing SVN metadata:

mn@tabernacle:~/src/git-mirrors/josm$ cat .git/config 
[core]
        repositoryformatversion = 0
        filemode = true
        bare = false
        logallrefupdates = true
[svn-remote "svn"]
        url = http://josm.openstreetmap.de/svn
        fetch = trunk:refs/remotes/trunk
        branches = branches/*:refs/remotes/*
        tags = tags/*:refs/remotes/tags/*


And this metadata may be retrieved at any time in a standard way using git config command:
mn@tabernacle:~/src/git-mirrors/josm$ git config --get svn-remote.svn.url
http://josm.openstreetmap.de/svn

But for git-cvsimport I’m out of luck. Fortunately there is another solution:

  • create a working directory containing copies of the source files from original CVS repository using cvs checkout command
  • import a CVS module into Git repository using git cvsimport command

So, lets start with importing org.eclipse.jdt.ui project:

cvs -d :pserver:anonymous@dev.eclipse.org:/cvsroot/eclipse co org.eclipse.jdt.ui
cd org.eclipse.jdt.ui
git cvsimport


And a full history of org.eclipse.jdt.ui project since 2001 at my fingertips:

Author: cvs   2001-05-02 20:50:00
Committer: cvs   2001-05-02 20:50:00
Child:  c43be3ba3c0e24ae62dda72232e0d191bcc6e05b (*** empty log message ***)
Branches: JDK_1_5, NewSearchIntegration, Pioneering_5_0, R2_1_maintenance, content_assist_participants, editorWork, linkedPositions_rework, master, origin, pre_3_3_work
Follows: 
Precedes: v0_102+



*** empty log message ***

git cvsimport uses cvsps for generating a patchset information from a CVS repository. A patchset is a set of changes made to a collection of files and all committed at the same time (using a single cvs commit command). And it works, as I can see with git log d27f355 --max-count=3 --name-only:

commit d27f355593d46d301291e9f84ce263d8c19e42b2
Author: mkeller 
Date:   Thu Dec 11 12:46:55 2008 +0000
    239347: Drag and drop any none java file doesn't refactor
core refactoring/org/eclipse/jdt/internal/corext/refactoring/JDTRefactoringDescriptorComment.java
core refactoring/org/eclipse/jdt/internal/corext/refactoring/RefactoringCoreMessages.java
core refactoring/org/eclipse/jdt/internal/corext/refactoring/refactoring.properties
core refactoring/org/eclipse/jdt/internal/corext/refactoring/rename/RenameCompilationUnitProcessor.java
core refactoring/org/eclipse/jdt/internal/corext/refactoring/rename/RenameFieldProcessor.java
core refactoring/org/eclipse/jdt/internal/corext/refactoring/rename/RenameJavaProjectProcessor.java
core refactoring/org/eclipse/jdt/internal/corext/refactoring/rename/RenameLocalVariableProcessor.java
core refactoring/org/eclipse/jdt/internal/corext/refactoring/rename/RenameMethodProcessor.java
core refactoring/org/eclipse/jdt/internal/corext/refactoring/rename/RenamePackageProcessor.java
core refactoring/org/eclipse/jdt/internal/corext/refactoring/rename/RenameTypeParameterProcessor.java
core refactoring/org/eclipse/jdt/internal/corext/refactoring/rename/RenameTypeProcessor.java
core refactoring/org/eclipse/jdt/internal/corext/refactoring/reorg/IReorgPolicy.java
core refactoring/org/eclipse/jdt/internal/corext/refactoring/reorg/JavaMoveProcessor.java
core refactoring/org/eclipse/jdt/internal/corext/refactoring/reorg/ReorgPolicyFactory.java
core refactoring/org/eclipse/jdt/internal/corext/refactoring/tagging/IReferenceUpdating.java
ui refactoring/org/eclipse/jdt/internal/ui/refactoring/reorg/RenameInputWizardPage.java
ui refactoring/org/eclipse/jdt/internal/ui/refactoring/reorg/ReorgMoveWizard.java

commit 8ee13e0e34d9ab201abdfc0722a25cd8614dc796
Author: dmegert 
Date:   Thu Dec 11 10:32:36 2008 +0000

    Require com.ibm.icu until Bidi is part of icu.base.

.settings/org.eclipse.pde.prefs
META-INF/MANIFEST.MF

commit 4769cf70021ece07bce67cdc3563b0928dd50d87
Author: dmegert 
Date:   Wed Dec 10 09:10:57 2008 +0000

    Fixed bug 258238: Typo in Delete Working Set dialog: space before '?'

ui refactoring/org/eclipse/jdt/internal/ui/refactoring/reorg/ReorgMessages.properties


It took me about a one day and 1G(?) of data transfer (but who counts all these bytes in our days?) for a full import and now I can work on stuff offline. And Git is really disk-space-friendly. Only 54M of disk space is been used for 19000+ commits which had been made to org.eclipse.jdt.ui project since 2001.

And to update my local git repository with changes from the remote CVS I can just run git cvsimport from the project’s working directory:

Fetching ui/org/eclipse/jdt/internal/ui/workingsets/ConfigureWorkingSetAssignementAction.java   v 1.19
Update ui/org/eclipse/jdt/internal/ui/workingsets/ConfigureWorkingSetAssignementAction.java: 25116 bytes
Tree ID bad5edfd1a0dac40fa3a2c865cd2a3e4401380bb
Parent ID fcf05781ae88bf413904aca54a9c4ee745c7f3cb
Committed patch 19257 (origin +0000 2008-12-15 10:23:40)
Commit ID 1e13114d7f01024110c0495de0350d8cfb43d1d6
DONE.
Updating fcf0578..1e13114
Fast forward
 .../ConfigureWorkingSetAssignementAction.java      |   37 +++++++++++++++++++-
 1 files changed, 36 insertions(+), 1 deletions(-)