Mac Pro uses PHP to export files that have been added or modified by SVN

Source: Internet
Author: User
Tags diff tortoisesvn

Previously, under the Windows operating system, used to export new or modified files with TortoiseSVN ("quite useful" how to let TortoiseSVN export new or modified files), recently replaced with a Mac Pro laptop, did not find a similar TortoiseSVN Useful Client Tools. Well, use PHP to write an export gadget:

1, tool file name: svn.php , its contents are as follows:

<?php/** * Export diff files between specified versions, such as differences between 100 and 200 export 100 (not included)-200 (including) all modifications * "SVN command line" * 1, view differences between versions * SVN diff-r 2,359:2,360- -summarize--username Simon--password simonfit Svn://112.73.80.56/sjf/source * 2, export a version file to local * SVN export-r 2360 SVN://1 12.73.80.56/sjf/source/common/controller/wechatbasecontroller.class.php/root/2/files_2359_2360/common/ controller/wechatbasecontroller.class.php--username Wenjianbao--password wjb888 * * @example svn.php * @author 5 2php.cnblogs.com *///root directory define (' Site_path ', DirName (__file__));//SVN account information $svn_url = ' Svn://112.73.80.56/sjf/source ' ; $svn _username = ' Wenjianbao '; $svn _password = ' 5c95e61387c478c85ccf45e6a8ae6de3 '; $error _msg = ' You must useage like '. $_server[' argv '][0]. ' Old_version (not included) new_version (including) '; if ($_server[' argc ']! = 3) {echo $error _msg;exit (1);} if ($_server[' argv '][1] > $_server[' argv '][2]) {echo $error _msg;exit (1);} $old _version = $_server[' argv '][1]; $new _version = $_server[' argv '][2]; $work _path = Site_path. "/file_${old_vErsion}_${new_version} "; echo" starts analyzing version differences ... \ n "; $diff _cmd =" svn diff-r ${old_version}:${new_version}--summarize-- Username ${svn_username}--password ${svn_password} ${svn_url} "; exec ($diff _cmd, $diff _list, $return); $diff _list = ( Array) $diff _list;foreach ($diff _list as $diff _info) {echo $diff _info. "\ n";} # Empty old data @system (' RM-RF '). Site_path. '/file_* '); @system (' Rm-rf '). Site_path. '/diff_* '); # New Folder Dir_mkdir ($work _path), $diff _count = count ($diff _list), if ($diff _count < 1) {echo "Version no difference"; Exit (1 );} $diff _count = 0; $diff _file_path = Site_path. "/diff_${old_version}_${new_version}.txt"; # Export Version file echo "Start export ... \ n"; foreach ($diff _list as $diff _info) {if (Preg_match ('/([\w]+) \s+ (svn:.+)/', $diff _info, $matches)] {$SVN _file_mode = $matches [1]; $SVN _file_name = $matches [2];//A, M, D, am is incremented and modified//file deleted if ($svn _file_mode = = ' D ') {continue ;} $diff _count++;//Write Log file_write ($diff _file_path, $matches [0]. "\ n", ' a ');//download to local $local_file_path = $work _path. Str_replace ($svn _url, ", $svn _file_name); $local _fIle_dir = dirname ($local _file_path);d ir_mkdir ($local _file_dir); $export _cmd = "svn export-r ${new_version} ${svn_file_ Name} ${local_file_path}--username ${svn_username}--password ${svn_password} "; system ($export _cmd);}} echo "co-export ${diff_count} diff file"; exit (0);/** * Create Folder * * @param string $path folder path * @param int $mode access * @par AM BOOL $recursive Recursive creation * @return bool */function dir_mkdir ($path = ", $mode = 0777, $recursive = True) {Clearstatcach E (); if (!is_dir ($path)) {mkdir ($path, $mode, $recursive), return chmod ($path, $mode);} return true;} /** * Write File * * @param string $filename file name * @param string $text text string to write * @param string $openmod text Write mode (' W ': Overwrite override, ' A ': Text append) * @return bool */function file_write ($filename = ", $text =", $openmod = ' W ') {if (@ $fp = fopen ($filename, $open MoD) {flock ($fp, 2); Fwrite ($fp, $text); fclose ($fp); return true;} Else{return false;}}

2. How to use

In the svn.php file, modify the address and account of your SVN server, run in command line mode, such as export version number 100 to 200 difference file,

PHP svn.php 100 200

Mac Pro uses PHP to export files that have been added or modified by SVN

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.