Cvs2svn include one branch and head?

I am using cvs2svn to convert my repository. I have done this successfully on one repository and now my new problem is the second repository.

In my new conversion, I only want to convert the HEAD and one branch. cvs2svn has an exclude feature for branches, but not include. I have many different branches and it will take a lot of work to eliminate each one ...

Is there a way to convert just a tuba (HEAD) and only one branch?

thanks, Oded

+2


source to share


2 answers


If you only want to keep one branch and there are no tags, then this is easy. The first rule that matches the symbol is used, so specify the branch you want to include and exclude everything else:

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

      

If you want to include not only a branch, but also as many tags as possible, then this is a little more complicated. Not only do you know the names of all tags, but you also cannot include tags that depend 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 named "symbol-info.out" containing information about all the CVS symbols. In your editor, open that file, find all the lines corresponding to the branches you want to exclude, and change the third column of those lines to exclude. Make sure that the third column of the line for the branch you want to include contains the word "branch" and its fourth column contains the path you want it to end on.

Now start cvs2svn again, starting in pass 3 and using the edited symbolic information file as the symbol hints file:



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

      

you will get many errors like:

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

      

Now go back to the editor and change the listed tags (BAR_TAG and BAZ_TAG in the example) to exclude them too, and then try running pass3 again. This procedure may need to be repeated several times, but it should not be cumbersome because pass3 is very fast.

When you've got pass3 to complete without error, run the rest of the conversion:

cvs2svn --symbol-hints=symbol-info.out --passes=4: ...

      

+1


source


One problem is that cvs2svn not only has to determine whether to include a branch or not, but (at the same time) whether a symbol is a branch or a tag in the first place. Therefore, if you want to include this branch, as well as some tags, it is more difficult than just saying "include only this branch" - it will kill all tags.

IOW, cvs2svn doesn't really support this. You can work 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 it a lot of work ...

+1


source







All Articles