你們應該都用過SVN,多個小組開發時,分小組提交代碼,但是有特殊狀況的,小組要穿插提交增量文件,該怎麼作呢?SVN補丁是一種能導出變動增量的方法。

1.建立補丁java


2.導出補丁(選導出到文件系統就是個文件了,第3步能夠讀取解析源碼路徑)數組

補丁說明:eclipse

#項目內修改過的文件全路徑svn

Index: src/sgcc/htjs/bussiness_examine_rule/action/RuleExamineAction.java
===================================================================spa

#這個應該是和svn進行對比的版本信息
--- src/sgcc/htjs/bussiness_examine_rule/action/RuleExamineAction.java    (revision 7495)
+++ src/sgcc/htjs/bussiness_examine_rule/action/RuleExamineAction.java    (working copy)
@@ -16,6 +16,7 @@
 import sgcc.htjs.bussiness_examine_rule.util.RuleExamineConstants;
 import sgcc.htjs.bussiness_examine_rule.vo.BusinessRulesVo;
 import sgcc.htjs.bussiness_examine_rule.vo.BusinessTypeVo;
+import sgcc.htjs.bussiness_examine_rule.vo.ConSupconProStand;
 import venus.frames.base.action.DefaultDispatchAction;
 import venus.frames.base.action.IForward;
 import venus.frames.base.action.IRequest;.net

#這個應該是修改內容相關的一些地址信息
@@ -43,11 +44,10 @@
      */
     public IForward listBusinessTypePage(DefaultForm formBean, IRequest request, IResponse response) throws Exception {
 #-表示刪除的內容 +新增的內容。若是是更新原有內容,則是先-(刪除) 再 +(新增)
-        String queryCondition = getQueryCondition(request);  //從request中得到查詢條件
-        Object business_type= request.getParameter("business_type");
-        if(null != business_type && business_type.toString().length() > 0){
-            queryCondition += " business_type = " + business_type;
-        }
+//        Object business_type= request.getParameter("business_type");
+//        if(null != business_type && business_type.toString().length() > 0){
+//            queryCondition += " business_type = " + business_type;
+//        }
         if( !RmJspHelper.transctPageVo(request) ){  //翻頁處理
           RmJspHelper.transctPageVo(request,0,getBs().getBusinessTypeCount(queryCondition));        
         }
@@ -331,4 +331,70 @@
         }
         return queryCondition;
     }
+    /**
+     * 合同變動工時設置列表頁面
+     * @param formBean
+     * @param request
+     * @param response
+     * @return
+     * @throws Exception
+     */
+    public IForward con_cha_work_hour_list(DefaultForm formBean, IRequest request, IResponse response)throws Exception {
+        String queryCondition = getQueryCondition(request);  //從request中得到查詢條件
+        Object business_type= request.getParameter("business_type");
+        if(null != business_type && business_type.toString().length() > 0){
+            queryCondition += " business_type = " + business_type;
+        }
+        List beans = getBs().getCon_cha_work_hour_list(queryCondition); 
+        request.setAttribute(REQUEST_BEANS, beans); 
+        request.setAttribute(REQUEST_WRITE_BACK_FORM_VALUES, RmVoHelper.getMapFromRequest((HttpServletRequest) request));  //回寫表單
+        return request.findForward("con_cha_work_hour_list");
+    }
 }

3.執行文件導出代碼中的源碼或部署文件(這個能夠自行定義路徑信息)orm

import java.io.BufferedInputStream;  
import java.io.BufferedOutputStream;  
import java.io.BufferedReader;  
import java.io.File;  
import java.io.FileInputStream;  
import java.io.FileOutputStream;  
import java.io.IOException;  
import java.io.InputStreamReader;  
import java.util.ArrayList;  
import java.util.List;  ip

public class FreePatchUtil {
      
    /** 
     * @param args 
     * @throws Exception  
     */  
    public static void main(String[] args) throws Exception {  
        String patchFile="D:/bosp2_htjs_gxl_2017-10-30/patchx.txt";//補丁文件,由eclipse svn plugin生成  
        List<String> updateFileList = getPatchFileList(patchFile);
//        String updateFile = "";
//        for(int i = 0,len=updateFileList.size();i<len;i++){
//            updateFile = updateFileList.get(i);
//            System.out.println(updateFile);
//        }
        copyFiles(updateFileList);  
        System.out.println("totals:"+updateFileList.size());
    }  
      
    public static List<String> getPatchFileList(String patchFile) throws Exception{  
        List<String> fileList=new ArrayList<String>();  
        FileInputStream f = new FileInputStream(patchFile);   
        BufferedReader dr=new BufferedReader(new InputStreamReader(f,"utf-8"));  
        String line;  
        while((line=dr.readLine())!=null){   
            if(line.indexOf("Index:") > -1){  
                line=line.replaceAll(" ","");  
                line=line.substring(line.indexOf(":")+1,line.length());  
                fileList.add(line);  
            }  
        }   
        return fileList;  
    }  
      
    private static String project_path="C:/VenusTools2010/workspace/BOSP_2v2";//源碼項目路徑  
    
    public static String des_project_path="D:/bosp2_htjs_gxl_2017-10-30/bosp_v2";//目標項目目錄
    
    public static void copyFiles(List<String> list){  
        for(String fullFileName:list){  
            String source_file_path = project_path+ File.separator + fullFileName;  
            String des_file_path= des_project_path + File.separator + fullFileName;  
            File sourceFile=new File(source_file_path);  
            if(!sourceFile.exists()){
                System.out.println("sorry,file dose not exists:"+source_file_path);
                continue;
            }
            File desFile=new File(des_file_path);  
            if(!desFile.exists()){  
                String parent_parth = desFile.getParent();
                boolean file_create = new File(parent_parth).mkdirs();
                if(file_create){
                    try {
                        desFile.createNewFile();
                    } catch (IOException e) {
                        // XXX Auto-generated catch block
                        e.printStackTrace();
                    }    
                }
            }  
            copyFile(source_file_path, des_file_path);  
            System.out.println("copy done:");
            System.out.println(source_file_path);
            System.out.println("->"+des_file_path);
        }  
    }  utf-8

    private static void copyFile(String sourceFileNameStr, String desFileNameStr) {  
        File srcFile=new File(sourceFileNameStr);  
        File desFile=new File(desFileNameStr);  
        try {  
            copyFile(srcFile, desFile);  
        } catch (IOException e) {  
            e.printStackTrace();  
        }  
    }  
      
     public static void copyFile(File sourceFile, File targetFile) throws IOException {  
         BufferedInputStream inBuff = null;  
         BufferedOutputStream outBuff = null;  
         try {  
             // 新建文件輸入流並對它進行緩衝  
             inBuff = new BufferedInputStream(new FileInputStream(sourceFile));  
   
             // 新建文件輸出流並對它進行緩衝  
             outBuff = new BufferedOutputStream(new FileOutputStream(targetFile));  
   
             // 緩衝數組  
             byte[] b = new byte[1024 * 5];  
             int len;  
             while ((len = inBuff.read(b)) != -1) {  
                 outBuff.write(b, 0, len);  
             }  
             // 刷新此緩衝的輸出流  
             outBuff.flush();  
         } finally {  
             // 關閉流  
             if (inBuff != null)  
                 inBuff.close();  
             if (outBuff != null)  
                 outBuff.close();  
         }  
     }  部署

}
4.導出項目中的源碼和指定路徑的目錄結構相同的目錄文件信息(項目中能夠比較方便的覆蓋)

相關文章
相關標籤/搜索