Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Howdy, In our lab we are now using software packages that need to go through two seperate CVS processes...one in our internal lab and one through the organization that created the original software. The problem we are running into is that our CVS tags conflict with the CVS tags from the organization. Every folder in the software stores the CVS tags in a subfolder (called CVS). We have two copies of the software...one with only our CVS tags one with the other CVS tags. What we need is a way to swap the contents of these CVS folders. We'd appreciate any help you could offer.

Replies are listed 'Best First'.
Re: CVS and Folder Manipulation
by InfiniteSilence (Curate) on Sep 14, 2005 at 21:58 UTC
    Well, to get you started:

    perl -MFile::Find -e "$|++; sub wanted{if((-d $_)&&($_ eq 'CVS')){prin +t qq|$File::Find::dir\\$_\n|}} find(\&wanted,'.',follow=>1);" ./a\CVS ./b\CVS ./c\CVS

    Then you change the wanted() subroutine to remove/replace the directories under your current directory (where the old CVS' are) with shell commands like rmdir, xcopy, cp -R, or whatever you have available.

    What's the reason no-one on your staff knows any scripting?

    Celebrate Intellectual Diversity

Re: CVS and Folder Manipulation
by bluto (Curate) on Sep 14, 2005 at 22:09 UTC
    Every folder in the software stores the CVS tags in a subfolder (called CVS).

    It stores more than just that there. CVS uses these to store state about the local sandbox (e.g. where the repository is located). It almost sounds like you've clobbered the data that was supposed to be there and now want to put the correct data back -- otherwise I'm not sure how CVS would be confused about the tags. If you need to alter anything in the CVS directories you are probably doing something wrong. It's usually a much better idea to copy the source files (i.e. everything else but the CVS directories) around, check them in/out, tag them, etc.

Re: CVS and Folder Manipulation
by rvosa (Curate) on Sep 15, 2005 at 09:57 UTC
    If both repositories write the same keywords on every commit this problem will keep coming up. Perhaps you can make your local repo only write $Rev: $ tags, and the other $Id: $ tags, or something like that?
Re: CVS and Folder Manipulation
by tphyahoo (Vicar) on Sep 15, 2005 at 10:46 UTC
    Sounds like you are in version controlling hell. Instead of going deeper into hell, back yourself out. Both your offices should be using the same repository. Then you should identify the differences between yours and theirs, document it, and put this documentation under version controlling as well.

    Maybe you should look into a third party hoster such as cvs dude or python hosting, to get this up and running cheap and quick.

    If cvs isn't meeting your needs, maybe you should try switching over to a more modern system such as subversion. (Both the above offer subversion hosting as well as cvs hosting.)

Re: CVS and Folder Manipulation
by halley (Prior) on Sep 15, 2005 at 14:11 UTC
    I agree that the original poster is in version-control hell, but I have a different approach to working it out.
    • In the terms CVS uses, your local files are a sandbox. The CVS tool makes ./CVS/ metadata directories in each actual directory in your sandbox. The metadata in these files is specific to the repository from which you collected this sandbox.
    • Therefore, all CVS sandboxes are inextricably associated with a given repository. Don't muck with that, or you'll go crazy. Any tweak which doesn't work flawlessly can really mess up each repository you're trying to touch. And any tweak you're performing which is CVS-specific will just tie you into the aging CVS solution instead of alternatives like Subversion, Perforce, etc.
    • Instead of hacking CVS metadata, work with TWO sandboxes. Sandbox A for Repository A. Sandbox B for Repository B. When you sync up your Sandbox A and find a bundle of changes, merge it over into your Sandbox B as a unit, test the Sandbox B for functionality, and if they pass, then commit Sandbox B.
    • There are tools which help you deal with merging two sandboxes. For the Windows platform, I would recommend Beyond Compare by Beyond software. Very visual, very easy to compare two whole sandboxes and pick-and-choose what needs to get merged where. For the Unix platform, you should get familiar with diff -ruN and various post-processors like xdiff which can help you visualize and manage the differences.
    In short, don't try to multi-purpose one sandbox. It'll just lead to major headaches.

    --
    [ e d @ h a l l e y . c c ]

      Thanks for your input folks....we actually ended up doing a solution much like halley suggested and it seems to be working out well.
        no. you can mv all CVS out and replace with another set. I am doing this way and it's good. (with eclipse will be easier)
Re: CVS and Folder Manipulation
by sh1tn (Priest) on Sep 14, 2005 at 20:12 UTC
    And what is the Perl question?


      The perl question is how we would go about doing such a thing in perl. None of us has a background with scripting languages, but we thought that this kind of problem was something that perl would be good at handling.
        First, the caveats:
        1) We're not likely to write your program for you, at least not without some more info and help from you.
        2) If you don't know Perl, Perl may not be the right choice for you.

        Now, something more useful.

        For those of us who don't use CVS, give a brief description of what you're trying to do, without invoking CVS as an explanation.

        Also, what operating system are you on? It may be that a simple shell or batch file will do what you want. For example:

        rename CVS1 CVStemp rename CVS2 CVS1 rename CVStemp CVS2

        -QM
        --
        Quantum Mechanics: The dreams stuff is made of