我正在编写一段代码,一旦在SVN工作副本中执行,就会找到根目录:
File workingDirectory = new File(".").getCanonicalFile();
File wcRoot = SVNWCUtil.getWorkingCopyRoot(workingDirectory, true);
Run Code Online (Sandbox Code Playgroud)
获取给定此根的存储库URL,构建SVNClientManager给定的此信息,现在我停留在如何获取工作副本中不在存储库中的任何内容的列表 - 这包括本地修改的文件,未解析的合并,未版本控制的文件我很乐意听到任何我可能错过的事情.
我怎么做 ?这个代码片段似乎需要访问存储库本身,而不是WC:
clientManager.getLookClient().doGetChanged(...)
Run Code Online (Sandbox Code Playgroud)
Mah*_*mar 10
public static List<File> listModifiedFiles(File path, SVNRevision revision) throws SVNException {
SVNClientManager svnClientManager = SVNClientManager.newInstance();
final List<File> fileList = new ArrayList<File>();
svnClientManager.getStatusClient().doStatus(path, revision, SVNDepth.INFINITY, false, false, false, false, new ISVNStatusHandler() {
@Override
public void handleStatus(SVNStatus status) throws SVNException {
SVNStatusType statusType = status.getContentsStatus();
if (statusType != SVNStatusType.STATUS_NONE && statusType != SVNStatusType.STATUS_NORMAL
&& statusType != SVNStatusType.STATUS_IGNORED) {
fileList.add(status.getFile());
}
}
}, null);
return fileList;
}
Run Code Online (Sandbox Code Playgroud)
这为您提供了本地修改,即,它不会查看存储库中已更改但不在您的工作副本中的内容
static def isModded(SvnConfig svn, File path, SVNRevision rev) {
SVNClientManager mgr = newInstance(null, svn.username, svn.password)
logger.debug("Searching for modifications beneath $path.path @ $rev")
mgr.statusClient.doStatus(path, rev, INFINITY, false, false, false, false, { SVNStatus status ->
SVNStatusType statusType = status.contentsStatus
if (statusType != STATUS_NONE && statusType != STATUS_NORMAL && statusType != STATUS_IGNORED) {
lmodded = true
logger.debug("$status.file.path --> lmodded: $statusType")
}
} as ISVNStatusHandler, null)
lmodded
}
Run Code Online (Sandbox Code Playgroud)
我为此编写的代码很普通,但是希望svnkit api的使用足够明显。SvnConfig只是一个本地值对象,其中包含有关存储库本身的各种详细信息。
| 归档时间: |
|
| 查看次数: |
3035 次 |
| 最近记录: |