Code updates are synchronized between SVN and CVS in the same project.

Source: Internet
Author: User

Between SVN and CVSCodeSynchronous update

This title is not very accurate, but I cannot think of a different title, so I have to pay attention to it.

 

Recently, I have been maintaining a project. The company uses the source code management tool CVs, and the customer uses SVN.

It is also possible to modify the code on both sides, which makes it difficult to update the code. It is often done manually.

In eclipse, only one team management tool can be used for a project, instead of CVs or SVN. Therefore, I have created two projects, one being CVS (internal) and the other being SVN (external ).

 

Every update of Svn in eclipse will output logs in the console, which is roughly what files are added/updated/deleted.

What we need to do is to analyze the log-related files of each line in the log and copy them to the corresponding directory of the CVS project.

This is also a small one written in ruby.ProgramRecently I want to learn and use groovy, so I have rewritten it.

The general logic is:

1. Use eclipse to update the modifications submitted by the customer from SVN, and then save the logs/content output by Svn in eclipse in the console to a text

2. Read SVN logs in text lines by program and analyze the involved files,

3. Copy or mkdir files to overwrite the latest files in the svn project.

  1. Public ClassSvn2cvs {
  2. Public Static VoidMain (string [] ARGs ){
  3. Svn2cvs ("Adreel");
  4. }
  5. Static VoidSvn2cvs (string project ){
  6. File infile =NewFile ("Svn_log.txt");
  7. Infile. eachline () {string line->
  8. Line = line. substring (7)// Remove indent and A/u character
  9. Line = line. replaceall ('/',"////")// Replace forwardslash with backwardslash
  10. String newline = line. replacefirst (/$ Project /,"$ {Project }_cvs")// Build new line
  11. If(Line. indexof ('.') =-1){// It's a dir
  12. Println"Mkdir/" $ newline /""
  13. }
  14. Else{
  15. Println"Copy/y/" $ line/"/" $ newline /""
  16. }
  17. }
  18. }
  19. }

 

The following is an example of the log when SVN is updated:

    1. U e:/workspaces/myworkspace/svnproject/src/a/A. Java
    2. A e:/workspaces/myworkspace/svnproject/src/a/B
    3. A e:/workspaces/myworkspace/svnproject/src/a/B/B. Java

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.