如何使用svnkit列出本地修改/未版本控制的文件? [英] How to list locally-modified/unversioned files using svnkit?

查看:952
本文介绍了如何使用svnkit列出本地修改/未版本控制的文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一段代码,一旦在SVN工作副本中执行,就会找到根目录:

I'm writing a piece of code that, once executed anywhere inside an SVN working copy, locates the root:

File workingDirectory = new File(".").getCanonicalFile();
File wcRoot = SVNWCUtil.getWorkingCopyRoot(workingDirectory, true);

获取给定此根的存储库URL,构建 SVNClientManager 给出这个信息,现在我坚持如何获取工作副本中不在存储库中的任何内容的列表 - 这包括本地修改的文件,未解析的合并,无版本的文件,我会很高兴听到我可能错过的任何其他内容。

gets the repository url given this root, builds an SVNClientManager given this info and now I'm stuck at how to get a list of anything in the working copy that is not in the repository - this includes locally-modified files, unresolved merges, unversioned files and I'll be happy to hear any anything else I might have missed.

我该怎么做?
这个代码段似乎需要访问存储库本身,而不是WC:

How do I do that ? This snippet seems to require access to the repository itself, not the WC:

clientManager.getLookClient().doGetChanged(...)


推荐答案

这为您提供本地修改,即,它不会查看存储库中已更改的内容,而这些内容不在您的工作副本中

This gives you local modifications, i.e. it doesn't look at things that have changed in the repository that are not in your working copy

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
}

我对此的代码是groovy,但希望使用svnkit api足够明显。 SvnConfig只是一个本地值对象,包含有关存储库本身的各种详细信息。

The code I have for this is in groovy but hopefully the use of the svnkit api is obvious enough to work with. SvnConfig is just a local value object containing various details about the repository itself.

这篇关于如何使用svnkit列出本地修改/未版本控制的文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆