为什么 Subversion 会跳过包含 @ 符号的文件?

发布于 2024-08-16 10:06:28 字数 515 浏览 10 评论 0原文

当我尝试执行这样的命令时(从命令行或 Perl 脚本 - 没关系):

svn revert "build\[email protected]"

SVN 跳过此文件并输出:

Skipped 'build\myfile'

我尝试这样做:

svn revert "build\*.meta"

但它给出了相同的结果。

我可以从 GUI 恢复这些文件。我可以通过执行以下操作来恢复这些文件(但它恢复的程度比我想要的要多):

svn revert --recursive "build"

有解决方法吗?

when I try to execute command like this (from a command-line or Perl script - it doesn't matter):

svn revert "build\[email protected]"

SVN skips this file and outputs:

Skipped 'build\myfile'

I tried doing:

svn revert "build\*.meta"

But it gives the same result.

I can revert these files from the GUI. And I can revert these files by doing (but it reverts more than I want):

svn revert --recursive "build"

Is there a workaround for this?

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

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

发布评论

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

评论(4

橘味果▽酱 2024-08-23 10:06:28

Subversion 中文件名中的 @ 符号实际上具有特殊含义 - 固定修订号。引用Subversion 书籍

此时,敏锐的读者可能想知道挂钩修订语法是否会导致工作副本路径或实际包含 at 符号的 URL 出现问题。毕竟,svn 如何知道 news@11 是我的树中的目录名称还是只是“新闻修订版 11”的语法?值得庆幸的是,虽然 svn 总是假设后者,但有一个简单的解决方法。您只需在路径末尾附加一个 at 符号,例如 news@11@。 svn 只关心参数中的最后一个 at 符号,并且在该 at 符号之后省略文字挂钩修订说明符并不被认为是非法的。此解决方法甚至适用于以 at 符号结尾的路径 - 您可以使用 filename@@ 来谈论名为 filename@ 的文件。

因此,您应该在脚本中的文件名后附加一个 @ 符号,如下所示:

svn revert "build\[email protected]@"

The @ sign in filenames in Subversion actually has a special meaning - a pegged revision number. To quote the Subversion book:

The perceptive reader is probably wondering at this point whether the peg revision syntax causes problems for working copy paths or URLs that actually have at signs in them. After all, how does svn know whether news@11 is the name of a directory in my tree or just a syntax for “revision 11 of news”? Thankfully, while svn will always assume the latter, there is a trivial workaround. You need only append an at sign to the end of the path, such as news@11@. svn cares only about the last at sign in the argument, and it is not considered illegal to omit a literal peg revision specifier after that at sign. This workaround even applies to paths that end in an at sign—you would use filename@@ to talk about a file named filename@.

So, you should append an @ sign to filenames in scripts, like this:

svn revert "build\[email protected]@"
舞袖。长 2024-08-23 10:06:28

只是为了添加上面的正确答案,如果您有很多名称中带有“@”符号的文件,您想要批量处理(即使用 * 通配符),您可以在 OS X 终端中执行类似的操作(或者任何 Linux 机器):

find . -name "*@*" | xargs -I % svn add %@

上面的命令将使用 find 实用程序列出文件名中带有 @ 的每个文件,然后使用 XARGS 将文件路径通过管道传输到 SVN。 XARGS 将用路径替换每个出现的 %,并在文件名末尾附加特殊的“@”,以便 SVN 接受它。

希望这会有所帮助 - 我不得不绞尽脑汁来添加我的应用程序升级到 iOS4.0 所需的 gazzilion @2x.png 文件

Just to add to the above correct answer, if you have lots of files with the "@" symbol in their name that you want to process in a batch (i.e. use * wildcard), you can do something like this in OS X Terminal (or any Linux box really):

find . -name "*@*" | xargs -I % svn add %@

The above command will use the find utility to list out each file with @ in its filename and then pipe the path to the file to SVN using XARGS. XARGS will replace each occurrence of % with the path and append the special "@" at the end of the filename so that SVN will accept it.

Hope this helps - I had to whack my head for a bit to add the gazzilion @2x.png files that were needed for my app to be upgraded for iOS4.0

放赐 2024-08-23 10:06:28

刚刚使用 cmd.exe shell 在 Windows 上正确测试了它 - 将名称用双引号引起来是有效的:

ctmkx> svn revert "trunk\[email protected]"
Reverted 'trunk\[email protected]'

Just tested it properly on windows using the cmd.exe shell - enclosing the name in double quotes works:

ctmkx> svn revert "trunk\[email protected]"
Reverted 'trunk\[email protected]'
白鸥掠海 2024-08-23 10:06:28

什么操作系统?如果是 *nix 系统,请尝试使用“single@quotes”引用您的文件。

What operating system? If it is a *nix system, try quoting your file with 'single@quotes'.

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