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.
- Public ClassSvn2cvs {
-
-
- Public Static VoidMain (string [] ARGs ){
-
- Svn2cvs ("Adreel");
-
- }
-
- Static VoidSvn2cvs (string project ){
- File infile =NewFile ("Svn_log.txt");
-
- Infile. eachline () {string line->
-
-
- Line = line. substring (7)// Remove indent and A/u character
- Line = line. replaceall ('/',"////")// Replace forwardslash with backwardslash
-
- String newline = line. replacefirst (/$ Project /,"$ {Project }_cvs")// Build new line
-
- If(Line. indexof ('.') =-1){// It's a dir
-
- Println"Mkdir/" $ newline /""
-
- }
-
- Else{
- Println"Copy/y/" $ line/"/" $ newline /""
-
- }
-
- }
-
- }
-
-
- }
The following is an example of the log when SVN is updated:
- U e:/workspaces/myworkspace/svnproject/src/a/A. Java
- A e:/workspaces/myworkspace/svnproject/src/a/B
- A e:/workspaces/myworkspace/svnproject/src/a/B/B. Java