Java automatically updates the svn program. Note that the system ignores files by default.

Source: Internet
Author: User

A previously written small program is used to automatically update SVN and automatically edit SWF files to replace tedious manual operations. Flash SDK and csvn must be installed first.

Recently I found that the. o file does not work, and the update operation is fine. If it is a newly added file, it cannot be identified. first look at the previous program:

Import Java. io. bufferedreader; import Java. io. ioexception; import Java. io. inputstreamreader; import Java. util. hashmap; import Java. util. using list; import Java. util. list; import Java. util. map; import Java. util. regEx. matcher; import Java. util. regEx. pattern; /*** tool class *** @ author monitor * created on **************************/public class tools {Private Static final pattern P = pattern. compile ("([M |? | A]) \ s + (. *) "); Private Static string userpass =" -- username yourname -- password yourpass "; /*** call the SDK tool to edit the SWF file ** @ Param update whether to automatically update SVN * @ Param filename the name of the file to be compiled * @ Param sourpath Source Path * @ Param destpath target path * /public static void compileswf (Boolean update, string filename, string sourpath, string destpath) {string line = NULL; process; bufferedreader BR; runtime = runtime. getruntime (); String cmd = "mxmlc" + sourpath + filename + ". as-output "+ destpath + filename + ". data "; outputmsg. append (New outputmsg (msgtype. info, "client", "[terminal]: Prepare to Run Command" + cmd); try {process=runtime.exe C (CMD); BR = new bufferedreader (New inputstreamreader (process. getinputstream (), "gb2312"); While (line = BR. readline ())! = NULL) {outputmsg. append (New outputmsg (msgtype. info, "client", "[terminal]:" + line);} BR. close (); process. destroy (); If (update) updatedatatosvn (destpath, "Update" + filename + ". SWF ");} catch (ioexception e) {outputmsg. append (New outputmsg (msgtype. error, "client", "Run" + cmd + "error:" + E. getmessage ();}/*** call the cvsn command to automatically update the svn ** @ Param dir file (folder) * @ Param commitmsg log */public static void updatedatatosvn (stri Ng Dir, string commitmsg) {matcher; List <string> msglist = NULL; Map <string, list <string> map = new hashmap <string, list <string> (); outputmsg. append (New outputmsg (outputmsg. msgtype. info, "client", "detected updatable files:"); msglist = runcmd ("SVN status" + dir + "" + userpass); If (msglist! = NULL) {map. Put ("M", new vertex list <string> (); map. Put ("? ", New topology list <string> (); map. put ("A", new vertex list <string> (); For (string MSG: msglist) {matcher = P. matcher (MSG); If (matcher. matches () {If (matcher. group (1 ). equals ("M") {map. get ("M "). add (matcher. group (2);} else if (matcher. group (1 ). equals ("A") {map. get (""). add (matcher. group (2); runcmd ("SVN add" + matcher. group (2) + userpass); map. get ("M "). add (matcher. group (2);} else if (matcher. group (1 ). equal S ("? ") {Map. Get ("? "). Add (matcher. group (2); runcmd ("SVN add" + matcher. group (2) + userpass); map. get ("M "). add (matcher. group (2) ;}}} if (! Map. get ("M "). isempty () {stringbuilder cmd = new stringbuilder ("SVN commit-m \" [automatic program update] "+ commitmsg +" \ ""); For (string STR: map. get ("M") {cmd. append (STR ). append ("");} cmd. append (userpass); runcmd (CMD. tostring (); outputmsg. append (New outputmsg (outputmsg. msgtype. info, "client", "SVN updated successfully !! ");} Else {outputmsg. append (New outputmsg (outputmsg. msgtype. info," client "," No file to be updated !! "));}} /*** Run the CMD command * @ Param cmd command * @ return the Output Message list */public static list <string> runcmd (string cmd) {string line = NULL; process; bufferedreader BR; List <string> msglist = new queue list <string> (); runtime = runtime. getruntime (); try {process=runtime.exe C (CMD); BR = new bufferedreader (New inputstreamreader (process. getinputstream (), "gb2312"); While (line = BR. readline ())! = NULL) {msglist. add (line); outputmsg. append (New outputmsg (msgtype. info, "client", "[terminal]:" + line);} BR. close (); process. destroy ();} catch (ioexception e) {e. printstacktrace (); outputmsg. append (New outputmsg (msgtype. error, "client", "Run" + cmd + "error:" + E. getmessage ();} return msglist ;}}

The principle is actually very simple. It is to call the svn commands of csvn, mainly status and commit. The status command is used to obtain the File status to determine whether to update. Common statuses include:

'A'

Item is scheduled for addition.

'D'

Item is scheduled for deletion.

'M'

The project has been modified.

'R'

The project has been replaced in the work copy. This means that the file is scheduled to be deleted, and a file with the same name must be replaced in the same location.

'C'

The project content (relative to the property) conflicts with the updated data.

'X'

The project is related to external definitions.

'I'

Item is being ignored (e.g., withsvn:ignoreProperty ).

'?'

The project is not under version control.

'!'

The project has been lost (for example, if you useSVNMove or delete it ). This also indicates that a directory is not complete (a check-out or update is interrupted ).

This small program used to work normally. However, the suffix of the file to be submitted recently adopts the. O suffix, and cannot be submitted. Even the File status is not output. I checked the information online,

SVN ignores some files by default, such as. O files.

If the file is ignored, the file cannot be submitted. If the file is ignored, the -- no-ignore parameter is added to the status file so that the file status is displayed, but the file is 'I' and cannot be submitted.

You can only change the config file. Go to c: \ Users \ monitor \ appdata \ roaming \ subversion, open config, and find:

# global-ignores = *.o *.lo *.la *.al .libs *.so *.so.[0-9]* *.a *.pyc *.pyo

Changed:

global-ignores = *.lo *.la *.al .libs *.so *.so.[0-9]* *.a *.pyc *.pyo

OK.

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.