不要在 svn 状态中显示 svn:externals

发布于 2024-08-31 21:11:38 字数 277 浏览 11 评论 0原文

我在我的存储库中创建了一个 svn:external 。除了 svn status 命令的输出之外,一切正常。在输出中有很多我不需要的信息:

$ svn st
X      lib

Performing status on external item at 'lib'

我可以运行 svn st --ignore-externals -q ,我可以将此行放在一个小脚本中,但也许有更好的解决方案。如何在不查看外部信息的情况下查看工作副本的状态?

I've made one svn:external in my repository. Everything works fine, except the output of the svn status command. In the output there is lot of information I don't need:

$ svn st
X      lib

Performing status on external item at 'lib'

I can run svn st --ignore-externals -q and I can place this line in a small script, but maybe there is better solution. How can I see status of my working copy without seeing info about externals?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

但可醉心 2024-09-07 21:11:38

这似乎是忽略 svn status 输出中出现的外部内容的正确方法。

参考:

http://svnbook.red-bean.com/ en/1.4/svn.ref.svn.html

That seems to be the proper way to ignore externals to appear in your svn status output.

Reference:

http://svnbook.red-bean.com/en/1.4/svn.ref.svn.html

娇女薄笑 2024-09-07 21:11:38

搜索发现了一个聪明的Bash脚本实现,它覆盖了带有脚本的 svn 命令。不过,我想在 Windows 中做类似的事情。从 PATH 中删除 svn 目录,然后创建一个名为 svn.bat 的批处理脚本,并将其放在 PATH 中的某个位置代码>(如C:\Windows):

@echo off
setlocal

if (%1)==(st) goto :match
if (%1)==(stat) goto :match
if (%1)==(status) goto :match

:: If not running Status command, just pass the args along
"C:\Program Files\SlikSvn\bin\svn" %*
goto :eof

:match

:: Init variables
set svnargs1=
set svnargs2=--ignore-externals

:: Loop through arguments
:loop
if "%~1"=="" goto :cont

:: Look for ignore externals flag
if "%~1"=="--examine-externals" (
    set svnargs2=
) else (
    if "%~1"=="-h" (
        set svnargs2=
    )

    set svnargs1=%svnargs1% %1%
)


shift & goto :loop
:cont

:: Call svn
"C:\Program Files\SlikSvn\bin\svn" %svnargs1% %svnargs2%

Searching turns up a clever Bash script implementation that overrides the svn command with a script. However, I wanted to do something similar in Windows. Remove the svn directory from your PATH, then create a batch script named svn.bat and put it somewhere in your PATH (like C:\Windows):

@echo off
setlocal

if (%1)==(st) goto :match
if (%1)==(stat) goto :match
if (%1)==(status) goto :match

:: If not running Status command, just pass the args along
"C:\Program Files\SlikSvn\bin\svn" %*
goto :eof

:match

:: Init variables
set svnargs1=
set svnargs2=--ignore-externals

:: Loop through arguments
:loop
if "%~1"=="" goto :cont

:: Look for ignore externals flag
if "%~1"=="--examine-externals" (
    set svnargs2=
) else (
    if "%~1"=="-h" (
        set svnargs2=
    )

    set svnargs1=%svnargs1% %1%
)


shift & goto :loop
:cont

:: Call svn
"C:\Program Files\SlikSvn\bin\svn" %svnargs1% %svnargs2%
无风消散 2024-09-07 21:11:38

我认为还没有答案真正解决问题,因为如果 svn:externals 的一部分发生了变化,它们当然应该被显示。这对于真正的外部存储库来说可能没有意义。但我使用 svn:externals 将同一存储库中的通用构建文件夹添加到项目中(因为不存在模块的通用层次结构)。而且我不想使用选项 --ignore-externals -q 因为我丢失了有关未添加文件的信息以及我在该项目中所做的常规构建脚本中的更改(我可能想要犯罪)。我的解决方案是修补 subversion java 命令行实现 svnkit

AbstractSVNCommand.registerCommand(new SVNStatusCommand());
final ByteArrayOutputStream bos = new ByteArrayOutputStream();
final PrintStream stream = new PrintStream(bos);

final SVNCommandLine commandLine = new SVNCommandLine();
commandLine.init(new String[] { "status", "PATH..." });

final SVNCommandEnvironment env = new SVNCommandEnvironment("mySvn", stream, stream, System.in);
env.init(commandLine);
env.initClientManager();

final SVNStatusCommand svnStatusCall = new SVNStatusCommand();
svnStatusCall.init(env);
svnStatusCall.run();
stream.flush();
String result = new String(bos.toByteArray());

StringBuffer buffer = new StringBuffer();
Scanner scanner = new Scanner(result);
while (scanner.hasNextLine()) {
    String line = scanner.nextLine();
    if (line.startsWith("X") || line.startsWith("Performing status on external item at")) {
        // ignore this output
    } else if (line.trim().isEmpty() == false) {
        buffer.append(line + "\n");
    }
}

System.out.println(buffer.toString());

这解决了问题,因为外部的更改也标记为“M”以表示修改......

I think no answer yet really solves the problem in the sense that if changes in a part of svn:externals has been made, they of course should be displayed. This propably makes no sense for really external repositories. But I use svn:externals to add a general build folder from the same repository into projects (because no general hierarchie of the modules exist). And I don't want to use the options --ignore-externals -q as I loose information about unadded files and changes in the general build script I have done in this project (which I might want to commit). My solution was to patch the subversion java command line implemantation svnkit.

AbstractSVNCommand.registerCommand(new SVNStatusCommand());
final ByteArrayOutputStream bos = new ByteArrayOutputStream();
final PrintStream stream = new PrintStream(bos);

final SVNCommandLine commandLine = new SVNCommandLine();
commandLine.init(new String[] { "status", "PATH..." });

final SVNCommandEnvironment env = new SVNCommandEnvironment("mySvn", stream, stream, System.in);
env.init(commandLine);
env.initClientManager();

final SVNStatusCommand svnStatusCall = new SVNStatusCommand();
svnStatusCall.init(env);
svnStatusCall.run();
stream.flush();
String result = new String(bos.toByteArray());

StringBuffer buffer = new StringBuffer();
Scanner scanner = new Scanner(result);
while (scanner.hasNextLine()) {
    String line = scanner.nextLine();
    if (line.startsWith("X") || line.startsWith("Performing status on external item at")) {
        // ignore this output
    } else if (line.trim().isEmpty() == false) {
        buffer.append(line + "\n");
    }
}

System.out.println(buffer.toString());

This solves the problem because changes in externals are also marked with 'M' for modified...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文