For many Subversion operations, appending the '@' symbol to the end of a file or URL argument allows you to target a specific revision of that file. For example, "svn info test.txt@1234" will give information about test.txt as it existed in revision 1234.
对于许多Subversion操作,将“@”符号附加到文件或URL参数的末尾允许您定位该文件的特定修订。例如,“svn info test.txt@1234”将提供有关test.txt的信息,因为它存在于修订版1234中。
However, when the name of the file contains an @, it is incorrectly interpreted by Subversion as a revision specifier:
但是,当文件名包含@时,Subversion会将其错误地解释为修订说明符:
svn info 'test@.txt' svn: Syntax error parsing revision '.txt'
svn info'test @ .txt'svn:语法错误解析修订版'.txt'
I've tried double and single quotes as well as escaping with '/', '\', and '@'. How can I tell Subversion to treat the @ symbols as part of the file name?
我尝试过双引号和单引号以及使用'/','\'和'@'转义。如何告诉Subversion将@符号视为文件名的一部分?
11 个解决方案
#1
From the SVN book (emphasis added):
来自SVN的书(重点补充):
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 asnews@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 usefilename@@
to talk about a file named filename@.感知读者可能在这一点上想知道,peg修订版语法是否会导致工作副本路径或实际上有符号的URL出现问题。毕竟,svn如何知道news @ 11是我树中目录的名称还是只是“新闻修订版11”的语法?值得庆幸的是,虽然svn将始终假设后者,但有一个简单的解决方法。您只需要在路径的末尾附加一个at符号,例如news @ 11 @。 svn只关心参数中的最后一个符号,并且在符号之后省略文字peg修订说明符并不被认为是非法的。这种解决方法甚至适用于以符号结尾的路径 - 您将使用filename @@来讨论名为filename @的文件。
#2
The original answer is correct, but perhaps not explicit enough. The particular unix command line options are as follows:
原始答案是正确的,但可能不够明确。特定的unix命令行选项如下:
svn info 'image@2x.png@'
or
svn info "image@2x.png@"
or
svn info image\@2x.png\@
I just tested all three.
我刚测试了这三个。
#3
Solution for adding multiple files in different sub-folders:
在不同子文件夹中添加多个文件的解决方案:
for file in $(find ./ -type f -name "*@*.png"); do svn add $file@; done
Just replace the "png" in "@.png" to the kind of files you want to add.
只需将“@ .png”中的“png”替换为您要添加的文件类型即可。
#4
to add the following file : image@2x.png do the following: svn add image\@2x.png@
添加以下文件:image@2x.png执行以下操作:svn add image \ @ 2x.png @
#5
In my case I needed to remove files from a SVN repo that contained an @ sign:
在我的情况下,我需要从包含@符号的SVN仓库中删除文件:
This wouldn't work:
这不起作用:
svn remove 'src/assets/images/hi_res/locales-usa@2x.png'
But this did:
但这样做:
svn remove 'src/assets/images/hi_res/locales-usa@2x.png@'
#6
Simply add
@
at the of the file you need to use, no matter what SVN command it is, e.g.:
在你需要使用的文件中,无论SVN命令是什么,例如:
file@2x.jpg
to
file@2x.jpg@
#7
To add multiple files, there is alternative solution:
要添加多个文件,还有其他解决方案:
svn status | grep \.png | awk '{print $2"@"}'| xargs svn add
#8
For svn commands with 2 arguments like "move", you must append "@" only at left (first) parameter. For example:
对于带有2个参数(如“move”)的svn命令,必须仅在left(first)参数中附加“@”。例如:
$ svn add README@txt@
A README@txt
$ svn move README@txt@ README2@txt
A README2@txt
D README@txt
$ svn status
A README2@txt
$ svn commit -m "blah"
Adding README2@txt
Transmitting file data .
Committed revision 168.
$ svn delete README2@txt@
D README2@txt
$ svn commit -m "blahblah"
*Deleting README2@txt
Committed revision 169.
This line is important: $ svn move README@txt@ README2@txt
这一行非常重要:$ svn move README @txt @ README2 @txt
As you can see, we don't need to append "@" at "README2@txt"
如您所见,我们不需要在“README2 @ txt”附加“@”
#9
@David H
I just tried a similar command without escaping the @ symbols and it still works fine
我只是尝试了一个类似的命令而没有转义@符号,它仍然工作正常
svn ci splash.png splash@2x.png@
This is on GNU bash, version 3.2.48(1)-release (x86_64-apple-darwin10.0) and svn 1.6.16
这是在GNU bash上,版本3.2.48(1)-release(x86_64-apple-darwin10.0)和svn 1.6.16
#10
The only solution that worked for me was the same suggested by @NPike
对我有用的唯一解决方案与@NPike建议的相同
svn revert 'path/to/filename@ext@'
svn还原'path / to / filename @ ext @'
#11
I had the problem today with filenames generated from email addresses (not a very good idea!).
今天我遇到了从电子邮件地址生成的文件名的问题(不是一个好主意!)。
Solution, using printf
options of find
, and shell expansion
解决方案,使用find的printf选项和shell扩展
svn add $(find . -name "*@*.png" -printf "%p@ ")
#1
From the SVN book (emphasis added):
来自SVN的书(重点补充):
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 asnews@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 usefilename@@
to talk about a file named filename@.感知读者可能在这一点上想知道,peg修订版语法是否会导致工作副本路径或实际上有符号的URL出现问题。毕竟,svn如何知道news @ 11是我树中目录的名称还是只是“新闻修订版11”的语法?值得庆幸的是,虽然svn将始终假设后者,但有一个简单的解决方法。您只需要在路径的末尾附加一个at符号,例如news @ 11 @。 svn只关心参数中的最后一个符号,并且在符号之后省略文字peg修订说明符并不被认为是非法的。这种解决方法甚至适用于以符号结尾的路径 - 您将使用filename @@来讨论名为filename @的文件。
#2
The original answer is correct, but perhaps not explicit enough. The particular unix command line options are as follows:
原始答案是正确的,但可能不够明确。特定的unix命令行选项如下:
svn info 'image@2x.png@'
or
svn info "image@2x.png@"
or
svn info image\@2x.png\@
I just tested all three.
我刚测试了这三个。
#3
Solution for adding multiple files in different sub-folders:
在不同子文件夹中添加多个文件的解决方案:
for file in $(find ./ -type f -name "*@*.png"); do svn add $file@; done
Just replace the "png" in "@.png" to the kind of files you want to add.
只需将“@ .png”中的“png”替换为您要添加的文件类型即可。
#4
to add the following file : image@2x.png do the following: svn add image\@2x.png@
添加以下文件:image@2x.png执行以下操作:svn add image \ @ 2x.png @
#5
In my case I needed to remove files from a SVN repo that contained an @ sign:
在我的情况下,我需要从包含@符号的SVN仓库中删除文件:
This wouldn't work:
这不起作用:
svn remove 'src/assets/images/hi_res/locales-usa@2x.png'
But this did:
但这样做:
svn remove 'src/assets/images/hi_res/locales-usa@2x.png@'
#6
Simply add
@
at the of the file you need to use, no matter what SVN command it is, e.g.:
在你需要使用的文件中,无论SVN命令是什么,例如:
file@2x.jpg
to
file@2x.jpg@
#7
To add multiple files, there is alternative solution:
要添加多个文件,还有其他解决方案:
svn status | grep \.png | awk '{print $2"@"}'| xargs svn add
#8
For svn commands with 2 arguments like "move", you must append "@" only at left (first) parameter. For example:
对于带有2个参数(如“move”)的svn命令,必须仅在left(first)参数中附加“@”。例如:
$ svn add README@txt@
A README@txt
$ svn move README@txt@ README2@txt
A README2@txt
D README@txt
$ svn status
A README2@txt
$ svn commit -m "blah"
Adding README2@txt
Transmitting file data .
Committed revision 168.
$ svn delete README2@txt@
D README2@txt
$ svn commit -m "blahblah"
*Deleting README2@txt
Committed revision 169.
This line is important: $ svn move README@txt@ README2@txt
这一行非常重要:$ svn move README @txt @ README2 @txt
As you can see, we don't need to append "@" at "README2@txt"
如您所见,我们不需要在“README2 @ txt”附加“@”
#9
@David H
I just tried a similar command without escaping the @ symbols and it still works fine
我只是尝试了一个类似的命令而没有转义@符号,它仍然工作正常
svn ci splash.png splash@2x.png@
This is on GNU bash, version 3.2.48(1)-release (x86_64-apple-darwin10.0) and svn 1.6.16
这是在GNU bash上,版本3.2.48(1)-release(x86_64-apple-darwin10.0)和svn 1.6.16
#10
The only solution that worked for me was the same suggested by @NPike
对我有用的唯一解决方案与@NPike建议的相同
svn revert 'path/to/filename@ext@'
svn还原'path / to / filename @ ext @'
#11
I had the problem today with filenames generated from email addresses (not a very good idea!).
今天我遇到了从电子邮件地址生成的文件名的问题(不是一个好主意!)。
Solution, using printf
options of find
, and shell expansion
解决方案,使用find的printf选项和shell扩展
svn add $(find . -name "*@*.png" -printf "%p@ ")