SVN 创建分支

来源:互联网 发布:js settimeout原理 编辑:程序博客网 时间:2024/06/02 03:11

2种方法:

创建分支之前一定要先更新到最新版本。

1.你用tortoiseSVN点版本库浏览,在需要建立分支的路径(比如trunk)点copy to + 新分支名称(注意:必须与trunk不能同名,你可以新建一个名称比如branch),然后在分支文件夹的根目录update。

2.tortoiseSVN点版本库浏览,你在需要创建的路径下右键tortoiseSVN 选择create folder 然后创建新路径名称(文件夹)然后把主干或者其他分支路径的代码(拉分支这种情况估计想并行开发)导入到这个路径下就可以了,然后在分支文件夹的根目录update。

创建分支是否成功,在分支文件夹里面 TortoiseSVN  ---->版本库浏览器  定位的是分支路径那就对了,如果还是主干路径那创建分支就有问题了。

注意:1、如果分支目录在没有分支的情况下check out下来的项目,这时候工作副本对应版本库的路径仍为原来对应的主干的目录。所以在客户端文本夹中删除之后 再从服务器Update分支的项目。不能用客户端SVN delete,这样会删除主干上的项目。


2、如果是多个项目,只保留几个项目做分支,那就从版本浏览器中分支的项目右键删除,不能从本地svn delete,这样会删除主干上的项目。


修改相关文件项目名,这样就能引入eclipse 了

/gjmj/mallv2/branchs/gjmj_20141110/shop/.classpath
/gjmj/mallv2/branchs/gjmj_20141110/shop/.project
/gjmj/mallv2/branchs/gjmj_20141110/shop/WebRoot/WEB-INF/web.xml
/gjmj/mallv2/branchs/gjmj_20141110/shop/config/boot.xml
/gjmj/mallv2/branchs/gjmj_20141110/shop/config/ui/path.xml


下面修改相关文件项目名的代码根据具体需要改动

import java.io.BufferedReader;import java.io.BufferedWriter;import java.io.File;import java.io.FileInputStream;import java.io.FileOutputStream;import java.io.InputStreamReader;import java.io.OutputStreamWriter;import java.io.PrintWriter;import java.util.ArrayList;import java.util.HashMap;import java.util.Iterator;import java.util.List;import java.util.Map;import java.util.Set;/** * 1、修改多个项目的路径,以便导入eclipse * 2、全部替换gjmj_20141110为分支文件夹 * @author Coco * */public class FileContentReplace { private static String REPLACE_SRC_FILE = "E:\\workspaces\\gjmj\\mallv2\\branchs\\gjmj_20141110"; private static String REPLACE_EXCLUDE_FILE = "E:\\Workspaces\\gjmj\\mallv2\\branchs\\gjmj_20141110\\core\\WebRoot\\sr;E:\\Workspaces\\gjmj\\mallv2\\branchs\\gjmj_20141110\\core\\WebRoot\\upload;E:\\Workspaces\\gjmj\\mallv2\\branchs\\gjmj_20141110\\core\\WebRoot\\WEB-INF\\lib;toruk.xml";  private static String REPLACE_CONTENT = "gjmj_mallv2->gjmj_20141110;E:/Workspaces/gjmj/mallv2/project/->E:/Workspaces/gjmj/mallv2/branchs/gjmj_20141110/;E:/workspaces/gjmj/mallv2/project/->E:/workspaces/gjmj/mallv2/branchs/gjmj_20141110/";  public static List<String> EXCLUDE_FILE_LIST = null;  public static Map<String,String> getReplaceMaping()  {   Map<String,String> map = new HashMap<String,String>();   if(REPLACE_CONTENT!=null){     String[] repContentArr = REPLACE_CONTENT.split(";");     for(String repMap:repContentArr){       String[] arg = repMap.split("->");       if(arg.length!=2){         throw new RuntimeException(repMap+"不正确");       }else{         map.put(arg[0], arg[1]);       }     }   }   return map; }  public static List<String> excludeFileList(){   if(EXCLUDE_FILE_LIST==null){     EXCLUDE_FILE_LIST = new ArrayList<String>();     if(REPLACE_EXCLUDE_FILE!=null){       String[] strArr = REPLACE_EXCLUDE_FILE.split(";");       for(String str:strArr){         EXCLUDE_FILE_LIST.add(str.trim());       }     }     return EXCLUDE_FILE_LIST;   }else{    return EXCLUDE_FILE_LIST;   } } public static void handFile(File infile,String fromCharSet,String toCharSet) throws Exception{      if(infile.getName().equals(".svn")){        return;      }      if(infile.getName().contains("!")){        return;      }      for(String excludeFile:excludeFileList()){        if(infile.getPath().toLowerCase().contains(excludeFile.toLowerCase())||infile.getName().equals(excludeFile)){          return;        }      }            BufferedReader in = new BufferedReader(new InputStreamReader(      new FileInputStream(infile), fromCharSet));      String reading;      String  content = "";      while ((reading = in.readLine()) != null) {        content +=reading+"\r\n";      }      boolean flag = false;      Map<String,String> replaceMapping = getReplaceMaping();      if(replaceMapping!=null){        Set<Map.Entry<String, String>> replaceEntrys =   replaceMapping.entrySet();        for(Iterator<Map.Entry<String, String>> it = replaceEntrys.iterator();it.hasNext();){          Map.Entry<String, String> entry = it.next();          String key = entry.getKey();          if(content.contains(key)){            flag = true;          }        }      }            if(flag){        File outfile = new File(infile + ".tmp");        PrintWriter out = new PrintWriter(new BufferedWriter(        new OutputStreamWriter(new FileOutputStream(outfile), toCharSet)));                if(replaceMapping!=null){          Set<Map.Entry<String, String>> replaceEntrys =   replaceMapping.entrySet();          for(Iterator<Map.Entry<String, String>> it = replaceEntrys.iterator();it.hasNext();){            Map.Entry<String, String> entry = it.next();            String key = entry.getKey();            String value = entry.getValue();            content = content.replaceAll(key, value);          }          System.out.println("替换文件:"+infile.getPath());        }                out.println(content);        out.flush();        out.close();        in.close();        infile.delete();        outfile.renameTo(infile);      }else{        in.close();      }            }     public static void main(String[] args) throws Exception {     replaceFile(new File(REPLACE_SRC_FILE),"UTF-8","UTF-8");  }  public static void replaceFile(File filePath,String fromCharSet,String toCharSet) throws Exception{    if(filePath.exists()==false){      new RuntimeException(filePath.getPath()+"不存在");    }        if(filePath.getName().equals(".svn")){      return;    }    for(String excludeFile:excludeFileList()){      if(filePath.getPath().toLowerCase().contains(excludeFile.toLowerCase())){        return;      }    }        if(filePath.isDirectory()){      File[] childFiles = filePath.listFiles();      if(childFiles!=null){        for(File childFile:childFiles){          if(childFile.isFile()){            handFile(childFile,fromCharSet, toCharSet);          }else{            replaceFile(childFile,fromCharSet, toCharSet);          }        }      }    }else{      handFile(filePath,fromCharSet, toCharSet);    }  }}


0 0
原创粉丝点击