Migrating from CS-RCS to Mercurial - version-control

I've been using ComponentSoftware's CS-RCS Basic for many years now to manage my various single-developer projects. It's worked very well for me, but now I want to migrate to a modern revision-control system, and after studying my options I decided on Mercurial.
The problem is that I've always used a central repository for CS-RCS, and I'd now like to use individual Mercurial repositories for individual projects, keeping the history from my RCS repository.
After some in-depth Googling I concluded that the only way to do this is to convert my RCS repository to individual CVS repositories, then convert those to Mercurial. These two sites were probably the most helpful:
Converting a directory from RCS to Mercurial
Convert Extension for Mercurial
In keeping with Jeff Atwood's idea of asking and answering my own question, I'm going to answer this for anyone else stuck in this situation, and in case I have to find it again later. As you'll see, though I did find a solution, it's clunky and has at least one significant problem. If anyone else has any better method I'd certainly like to hear about it.

Here's the method I came up with, warts and all. It's a bit 'cargo culty', since I basically know nothing about CVS and not much (yet) about Mercurial:
I have a Windows XP virtual machine that I can take snapshots of, so I did that and then installed CVSNT and the Windows command-line version of Mercurial (I use TortoiseHg on my main machine). I did this in a VM so I could easily get rid of CVSNT, Mercurial, and anything else I had to create while doing this one-time migration. Yeah, I probably didn't have to do this, but the VM was already available and I've already got enough odd bits of apps left over from install/uninstall cycles over the years. :-)
As far as I could tell, CVSNT was the only program available that could easily set up a CVS server on a Windows machine. It seems that this was free at one time but the owner's current site now asks for money. That's not a bad thing, but I really couldn't justify spending money just to do a one-time conversion. I did eventually track down an older version of CVSNT with a Google search and installed that without problems.
Here are the notes I took while learning how to make this conversion work:
The Long Version
Copy the source-code folder you need from the main computer's drive to the VM's drive. Copy the various ",v" files from the C:\RCS folder structure to this same source-code folder on the VM. Just copy the ,v files from the corresponding folder in C:\RCS.
Open a Command Prompt box on the VM and type the following:
path %PATH%;C:\Program Files\cvsnt
mkdir \cvs-repo [or clean the folder out if it already exists]
cvs -d \cvs-repo init
[A DIR of \cvs-repo should show a CVSROOT folder in there.]
Make a copy of your source code folder in \cvs-repo. \cvs-repo should now just have two folders: CVSROOT and your new folder. Copy in the appropriate ",v" files as well.
mkdir \cvs-checkout [or clean that folder out if it already exists]
cd \cvs-checkout
cvs -d \cvs-repo co name_of_your_source_code_folder
A DIR of "\cvs-checkout\name_of_your_source_code_folder" should show all of your source code files, which are now checked out of CVS.
If you haven't already done so, download Mercurial from https://www.mercurial-scm.org/ and install it. Open a copy of Notepad and drag the file "C:\Program Files\Mercurial\hgrc.d\Mercurial.rc" into it. Under "[extensions]", remove the semicolon at the start of the line ";convert =". Save the file to "C:\Documents and Settings\user_name\Mercurial.ini"
Back at the VM command line:
path %PATH%;C:\Program Files\Mercurial
mkdir \my-repo.hg [or clean that folder out if it already exists]
hg convert --datesort \cvs-checkout\source_code_folder_name \my-repo.hg
cd \my-repo.hg
[A DIR of \my-repo.hg should show a new ".hg" folder.]
hg update
[A DIR should now show the ".hg" folder and all the checked-out files.]
Copy the ".hg" folder from \my-repo to the source code folder on your main computer's hard drive. The destination folder will now show up in TortoiseHg with all of the appropriate change history, but all files marked as Changed (icon overlay of an exclamation mark in a red circle). This is because the new Mercurial repository thinks the files were checked in with Unix line endings (0x0A) instead of Windows (0x0D,0x0A). This seems to happen in the "hg convert" process, and I haven't found any way around it.
The Short Version
Once everything's set up in the VM, here's what to do:
Delete everything in \cvs-repo, \cvs-checkout, and \my-repo.hg.
At the command line, cvs -d \cvs-repo init.
Back on your main machine, copy the source-code folder into your Virtual Machine's shared folder (that's how you do it in VirtualBox; other VM software might let you just drag-and-drop the folder into the VM).
Copy the appropriate ",v" files into the source-code folder in the Virtual Machine shared folder.
Back in the VM, move the source-code folder to \cvs-repo.
cd \cvs-checkout
cvs -d \cvs-repo co name_of_your_source_code_folder
hg convert --datesort \cvs-checkout\name_of_your_source_code_folder \my-repo.hg
cd \my-repo.hg
hg update
Copy the .hg folder from \my-repo to the L: drive on the VM (L is the mapped drive letter of my VM shared folder).
Move that folder from the Virtual Machine transfer folder to the final source-code folder on the host computer.
Handy Batch File
Once I got this working, I set up this batch file on the VM to automate the process as much as possible:
#echo off
rem Converts source code under RCS control to a Mercurial repository.
rem This batch takes one argument: the name of the source-code folder (in quotes if necessary).
rem
rem This is for a VirtualBox VM that already has CVSNT and Mercurial installed, and has a Shared Folder mapped to drive L.
#echo On the host, copy the source-code folder into the Virtual Machine Transfer folder. Copy the appropriate ",v" files into the source-code folder in the Virtual Machine Transfer folder.
pause
#echo on
cd \
rmdir /S/Q \cvs-repo
mkdir \cvs-repo
rmdir /S/Q \cvs-checkout
mkdir \cvs-checkout
rmdir /S/Q \my-repo.hg
mkdir \my-repo.hg
cvs -d \cvs-repo init
xcopy L:\%1 \cvs-repo\%1 /E/I
cd \cvs-checkout
cvs -d \cvs-repo co %1
hg convert --datesort %1 \my-repo.hg
cd \my-repo.hg
hg update
xcopy \my-repo.hg\.hg L:\.hg /E/I
Conclusion
So, this all worked but left me with files that had the wrong line endings. Looking at this question, I see I'm not the only one with this problem. I can live with this, but I'd still like to fix it if anyone knows of a solution.

If Mercurial has fast-import/fast-export support, and if your multi-file repositories do not use branches, you can probably try using my rcs-fast-export tool (available # http://git.oblomov.eu/rcs-fast-export ). Although I've only used it to export from RCS to git so far, I am not aware of any git-specific fast-export commands being used so it might work.

Related

git rm -f after add, before commit, on windows cmd line. Was open earlier in STS (Eclipse). Can recover?

I wanted to unstage files (as my .gitignore was not set up to ignore some of my IDE files) but in hurry did :
git add w3
//got some .settings etc folder and files added, in newly added sub folder w3
//the repo here already had sub folders w1 & w2.
Then issued:
git rm -f w3/*
I'm on windows 8. The files are hard deleted (not in the recycle bin). Any thing I can do with git or any other (free) way?
Edit Add
* Also it was opened in STS(eclipse) but now deleted the pom, settings everything. Anyway to restore from within eclipse?
Un-commited but added files are still in a repository for a while, however it would be quite tricky to restore it especially for a large old repository as usually it has a lot of garbage. So, if you don't mind dig into garbage, start with git fsck and look for dangling blob.
However, seems you cannot restore names of lost files, only content.
If the file was not versioned you can't restore it. See the documentation of git-rm. See here for how to undo adding a file to the staging area.
If the file was versioned you can retrieve it from a past commit. See this answer for more information.
Of course if you back up your drive you might be able to restore it with your back up program. For that you might get help over at SuperUser.

How to remove a specific directory from GitHub using Eclipse

I've looked all around for a few days now trying to figure this out because our .gitignore even though it lists /bin/ folder it still keeps freaking commiting the whole folder and its getting annoying.
Now we have a whole bunch of crap in a /bin/ folder in our GitHub repository and I have no idea how to remove it. I've tried looking at other peoples examples but they keep talking about a shell command that I don't have in eclipse (or at least don't know how to access)
The sad news is that if a file has been already committed to GitHub, git will continue to version that file.
This means if I commit the entire bin/ then add it to .gitignore, the files will still persist in GitHub. And, if these files in bin/ change, they will also be pushed in the commit because they are versioned.
Luckily, you can remove files and directories from GitHub completely. You need, though, to get to a command line running git. If you have the GitHub application installed, that probably means you have git.
Open command prompt in Windows or Terminal in Mac OS.
Navigate to the directory (ie. cd ~/Workspace/Project) and run the following:
git rm bin/* -f
git commit --amend
git push -f
This should work. Check out this article on the GitHub that also outlines the process.
Hope this helps you!
Disclaimer: always make sure you do your research before working with git. If you have various branches / other complicated stuff going on, this process might be different

Can I separate `.hg` from working directory?

I would like to put directory C:\WorkDir under Mercurial version control, but have the repository located somewhere else than C:\WorkDir\.hg perhaps D:\Repositories\WorkDir.hg. Is that possible in Mercurial?
This answer on the Mercurial mailing list by Martin Geisler is quite clear about it:
You cannot move the .hg folder outside of where your working files
reside. That is by definition: the "working copy" is the parent
directory of the .hg folder. So if you want to version files in
C:\inetpub\laravel\app
you must have
C:\inetpub\laravel\app\.hg
If you want to avoid having the drive with the "real" working copy filled up with the repository data, you can use the share extension: https://www.mercurial-scm.org/wiki/ShareExtension .
E.g. if you want to version control C:\WorkingDir, but want the big repository data to reside on D:\Repositories\WorkDir, just do the following:
cd D:\Repositories
hg init WorkDir
cd C:\
hg share D:\Repositories\WorkDir WorkingDir
You will still have a .hg directory on C:, but it will remain really small (around 1MB), while the repo on D: will be the one that grows with time.
Have you tried creating a Junction?
Let's say your repo is c:\test\.hg but you want to put .hg directory in c:\shadow
mkdir c:\shadow
mv c:\test\.hg c:\shadow\.hg
mklink /j c:\test\.hg c:\shadow\.hg

Can tortoise cvs individually work without cvsnt?

I want to create a local repository using tortoise tortoise cvs without making a server...
Is it possible??
You can create a local repository on your computer. You create an empty directory, and call cvs init within there (I guess ther is a cvs.exe or cvsnt.exe lying around somewhere in the installation directory of TortoiseCVS. If not you need to get it). Then you can import any local folder into this repository. You enter the file path of the top folder when you are asked for the CVSROOT.
:: create the repository
c:
mkdir c:\repo
cvs -dc:\repo init
:: import something
mkdir initial
cd initial
echo 23>42
cvs -dc:\repo import first-module useless-tag-1 useless-tag-2
There might be issues with the '\' chars in the path names, you can then try with forward slashes.
But honestly, today I use Mercurial and TortoiseHg for version control, which has lots more features and is less painful.

No such directory when committing files using CVS from Eclipse

I am using Eclipse solely as a CVS client. Mostly it works very good, but once in a while, when I am right-clicking a file to commit it (a file that it itself says is changed and ready for commit), it tells me "cvs [server aborted]: no such directory `...'
But the directory DOES exist?! If I navigate to the folder using tortoise CVS and right click for commit, it works fine? (this is the way I finally have to get those files committed)
Has anyone experienced this as well, and more importantly - has anyone solved it? :)
I am running Vista on the client PC and the CVS server is a Windows Server 2003 (please dont tell me to just switch to Linux - that is not much help).
Thank you very much for your help!
Not sure about Eclipse but I faced the same issue with WinCVS client. I could do CVS operations once I copied the CVS folder in each directory along the path.
For example: Suppose I am at C:\source\dir1. I select the flat-view and find the file with path C:\source\dir1\dir2\dir3\file.cpp, I should have the CVS folder present in each of following directories: dir1, dir2 and dir3. If the one/more folders are not present, we see below error.
cvs diff -u -- dir2\dir3\file.cpp (in directory C:\Source\dir1\)
cvs [diff aborted]: no such directory `dir2/dir3'
My solution -
backup files you have changed in notepad or ...
delete folder from eclipse.
Synchronise again(eclipse shows files in minus)
override and update now.
copy contents of changed file
commit