svn update:我可以迭代结果吗?

发布于 2024-08-13 16:36:27 字数 571 浏览 4 评论 0原文

我在脚本(Windows 脚本 .cmd 文件)中使用 svn。

目前,它将所有文件检出到一个文件夹中,然后迭代该文件夹,将所有文件添加到主文件中,作为构建过程的一部分。类似的事情:

svn checkout --username %username% %SVNURL% %workingfolder%
FOR %%i IN (%workingfolder%\*.*) DO TYPE %%i >> %DESTFILE%

我想在初始构建之后对构建执行的操作是生成一个“更改”文件,该文件仅包含自上次构建以来已更改的文件。

我可以使用 svn update 命令而不是签出,这会给我一个正在更新的文件列表。 svn 更新参考 (svnbook.red-bean. com)

我想做的是迭代 svn 更新的结果列表,在工作文件夹中找到这些文件并将它们复制到更改文件中。

I'm using svn in a script (Windows scripting .cmd file).

Currently it checks out all files to a folder, then iterates that folder adding all the files to a master file as part of a build process. Something like:

svn checkout --username %username% %SVNURL% %workingfolder%
FOR %%i IN (%workingfolder%\*.*) DO TYPE %%i >> %DESTFILE%

What I would like to do for builds after the inital build is produce a "change" file, that only has the files included which have changed since the last build.

I can use the svn update command instead of checkout, and this gives me a list of files being updated. svn update Reference (svnbook.red-bean.com)

What I would like to do is iterate this list of results from the svn update, find these files within the working folder and copy them to a change file.

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

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

发布评论

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

评论(2

陌上青苔 2024-08-20 16:36:27

您可以非常轻松地找到更新的文件:

svn up | findstr /r /c:"^U"

您可以使用 for 命令迭代该文件的输出:

for /f "tokens=2* delims= " %%x in ('svn up ^| findstr /r /c:"^U"') do copy "%%x" change

You can find updated files pretty easily:

svn up | findstr /r /c:"^U"

You can iterate over the output of that with the for command:

for /f "tokens=2* delims= " %%x in ('svn up ^| findstr /r /c:"^U"') do copy "%%x" change
假扮的天使 2024-08-20 16:36:27

很抱歉回答我自己的问题,这也只是部分答案,但这就是我目前所处的位置。

首先,空格的问题不仅仅是 %SVNExecutable% 中的文件路径,问题根本在于命令中的空格。

解决这个问题的方法(适用于Windows XP)是使用usebackq开关,并使用反引号`而不是普通引号。使用这个,我设法让 svn update 命令工作:

for /f "usebackq tokens=2* delims= " %%x in (`%SVNExecutable%svn up --username %username% %SVNURL% %workfolder%`) do ECHO "%%x"

这更新了测试文件,并从初始更新结果:

U    full\path\to\file\file.sql
Updated to revision 36793.
Summary of conflicts:
Skipped paths: 1

这产生了结果:

"full\path\to\file\file.sql"
"to"
"of"
"paths:"

我无法开始工作的最后一个剩余部分是带有正则表达式的 findstr 。当我重新添加此问题并尝试此操作时:

for /f "usebackq tokens=2* delims= " %%x in (`%SVNExecutable%svn up --username %username% %SVNURL% %workfolder% ^| findstr /r /c:"^U"`) do ECHO "%%x"

我收到此错误:

The filename, directory name, or volume label syntax is incorrect.

有两种想法是否要将此作为一个新问题开始,现在我已将此问题标记为已回答......无论如何,感谢所有帮助

Apologies for answering my own question, this is also only a partial answer but it's where I'm at currently.

Firstly, the problem with the spaces is not just with the file path in %SVNExecutable%, the problem is with spaces in the command at all.

The way to solve this problem (works on windows XP) is to use the usebackq switch, and use back quotes ` instead of normal quotes. Using this, I have managed to get the svn update command to work:

for /f "usebackq tokens=2* delims= " %%x in (`%SVNExecutable%svn up --username %username% %SVNURL% %workfolder%`) do ECHO "%%x"

This updated the test file, and from an initial update result of:

U    full\path\to\file\file.sql
Updated to revision 36793.
Summary of conflicts:
Skipped paths: 1

This produces a result of:

"full\path\to\file\file.sql"
"to"
"of"
"paths:"

The last remaining piece of the puzzle that I can't get to work is the findstr with regex. When I add this back in and try this:

for /f "usebackq tokens=2* delims= " %%x in (`%SVNExecutable%svn up --username %username% %SVNURL% %workfolder% ^| findstr /r /c:"^U"`) do ECHO "%%x"

I get this error:

The filename, directory name, or volume label syntax is incorrect.

Was in 2 minds whether to start this as a new question now I've marked this one as answered...anyway, all help gratefully received

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