views:

268

answers:

2

Hi,

I'm using cvs2svn to convert my repository. I've done it with success in one repository, and now my new problem is a second repository.

In my new conversion, I want to convert only the HEAD and one branch. cvs2svn only have "exclude" function for branches, but not "include". I have many many branches and excluding each and every one of them will take A LOT of work....

is there any way to convert only the trunk (HEAD) and only one branch?

thanks, Oded

+1  A: 

One problem is that cvs2svn not only needs to determine whether to include a branch or not, but (simultaneously) whether a symbol is a branch or a tag in the first place. So if you want to include that one branch, and also some tags, it's more difficult than just saying "include only that branch" - doing so would kill all tags.

IOW, cvs2svn doesn't really support that. You can work around by editing its source code. In cvs2svn_lib.symbol_strategy.BranchIfCommits, change the case where it returns Branch(symbol) to

   if symbol.name == 'my_branch':
       return Branch(symbol)
   else:
       return ExcludedSymbol(symbol)

IIUC, BranchIfCommits should be used by default.

Personally, I would use a different strategy:

 1. convert the repository once, with all branches.
 2. do a "svn ls" on branches, and redirect that into a file.
 3. edit the file to construct an exclude regex out of it, of the form `b1|b2|...|bn`

I wouldn't call that a LOT of work...

Martin v. Löwis
I saw somewhere the option of writing --froce-branch=NAME --exclude=.*what do you think?
Oded
I don't think it will work. If I read the code correctly, they are evaluated from left to right, so the branch gets first included, then excluded. It might work to pass the options in reverse order, though.
Martin v. Löwis
+1  A: 

If you only want to retain the one branch and no tags, then this is easy. The first rule that matches a symbol is used, so specify the branch that you want to be included then exclude everything else:

cvs2svn --force-branch=mybranch --exclude='.*' ...

If you want to include not only the branch but also as many tags as possible, then it is a little bit trickier. Not only don't you necessarily know the names of all of the tags, but you also cannot include tags that are dependent on excluded branches. In this case, it is easiest to work with the --write-symbol-info and --symbol-hints options:

cvs2svn --write-symbol-info=symbol-info.out --passes=1:3 ...

This will create a file called "symbol-info.out" containing information about all CVS symbols. In your editor, open this file, find all of the lines corresponding to branches that you want to exclude, and change the third column of those lines to the word "exclude". Make sure that the third column of the line for the branch that you want to include contains the word "branch" and its fourth column is the path where you want it to end up.

Now run cvs2svn again, starting at pass 3, and using the edited symbol-info file as a symbol hints file:

cvs2svn --symbol-hints=symbol-info.out --passes=3 ...

you will get a lot of errors like:

ERROR: ExcludedSymbol('FOO_BRANCH') cannot be excluded because the following symbols depend on it:
    BAR_TAG
    BAZ_TAG

Now go back into the editor and change the listed tags (BAR_TAG and BAZ_TAG in the example) to be excluded too, then try running pass3 again. This procedure might need to be iterated a couple of times, but it should not be cumbersome because pass3 runs very quickly.

When you have gotten pass3 to complete without errors, run the rest of the conversion:

cvs2svn --symbol-hints=symbol-info.out --passes=4: ...
mhagger
The option you mentioned about --force-branch does not work. HOWEVER, the second option, with the symbol-info, works perfectly!Thanks!
Oded