Don't show svn:externals in svn status

2019-03-22 23:10发布

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?

标签: svn externals
3条回答
Luminary・发光体
2楼-- · 2019-03-22 23:29

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...

查看更多
Rolldiameter
3楼-- · 2019-03-22 23:31

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

查看更多
萌系小妹纸
4楼-- · 2019-03-22 23:35

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%
查看更多
登录 后发表回答