java调用svn的方法(基本操作,并不全) (二)

2014-11-24 11:22:31 · 作者: · 浏览: 25
= true;

/**
* @description: svn 先做清理,再做更新
*/
public SvnApp() {

try {
SvnClient = new SVNClient();
SvnClient.cleanup(SVN_DES_PATH);

svn_update(SVN_DES_PATH);
} catch (Exception e) {
log.error(e.toString(), e);
}

}

/**
* @description: 使用用户名和密码登陆svn
*/
public SvnApp(String userid, String password) {
try {
SvnClient = new SVNClient();
SvnClient.username(userid);
SvnClient.password(password);
auth = new SvnUserPassPromptImpl(userid, password);
SvnClient.setPrompt(auth);
svn_update(SVN_DES_PATH);
} catch (Exception e) {
setAuthFlag(false);
log.error(e.toString(), e);

}

}

/**@description: svn delete文件
* @author:yehui
* @param paths 需要delete的文件路径
* @param message 如果delete成功,将提交一条信息
* void
*/

public void svn_delete(String[] paths, String message) {

try {
Map revmap = new HashMap();
SvnClient.remove(paths, message, false, false, revmap);
} catch (ClientException e) {
log.error(e.toString(), e);
}

}

/**
* @description: svn add文件
* @return:void
*/
public void svn_add(String File_Path) {
try {

SvnClient.add(File_Path, Depth.infinity, false, false, false);
} catch (ClientException e) {
log.error(e.toString(), e);
}
}

/**
* @description: svn commit文件
* @return:long
*/
public long svn_commit(String[] path, String message) {
long num = 0;
try {

String[] array = new String[1];
Map revmap = new HashMap();
num = SvnClient.commit(path, message, Depth.infinity, false, false,
null, revmap);
} catch (ClientException e) {
log.error(e.toString(), e);
}
return num;
}

/**
* @description: svn update文件
* @return:void
*/
public void svn_update(String path) throws ClientException {

SvnClient.update(path, Revision.HEAD, Depth.infinity, false, false,
false);

}

/**
* @description: svn checkout文件
* @return:void
*/
public void svn_checkout(String Svn_Checkout_Path, String Svn_Des_Path) {
try {

SvnClient.checkout(Svn_Checkout_Path, Svn_Des_Path, Revision.HEAD,
Revision.HEAD, Depth.infinity, false, false);

} catch (ClientException e) {
log.error(e.toString(), e);
}

}

/**
* @description: svn lock文件
* @return:void
*/
public void svn_lockSingleFile(String path, String comment, boolean force) {
try {
SvnClient.lock(new String[] { path }, comment, force);

} catch (ClientException e) {
log.error(e.toString(), e);
}

}

/**
* @description: svn unlock文件
* @return:void
*/
public void svn_unlock(String path, boolean force) {
try {
SvnClient.unlock(new String[] { path }, force);
} catch (ClientException e) {
log.error(e.toString(), e);
}
}