简体   繁体   English

如何在Subversion中移动/重命名文件,其中包含@字符

[英]How to move/rename a file in Subversion with @ characters in it

From the SVN book : 来自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. 感知读者可能在这一点上想知道,peg修订版语法是否会导致工作副本路径或实际上有符号的URL出现问题。 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”? 毕竟,svn如何知道news @ 11是否是我树中目录的名称,还是只是“新闻修订版11”的语法? Thankfully, while svn will always assume the latter, there is a trivial workaround. 值得庆幸的是,虽然svn将始终假设后者,但有一个简单的解决方法。 You need only append an at sign to the end of the path , such as news@11@. 您只需要在路径的末尾添加一个at符号 ,例如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. svn只关心参数中的最后一个符号,并且在符号之后省略文字peg修订说明符并不被认为是非法的。 This workaround even applies to paths that end in an at sign—you would use filename@@ to talk about a file named filename@. 此解决方法甚至适用于以符号结尾的路径 - 您将使用filename @@来讨论名为filename @的文件。


According to this description, you only need to add an @ sign to the path. 根据此描述,您只需要在路径中添加@符号。

so this: 所以这:

svn add "C:\\SomeTests\\my@file.txt" svn添加“C:\\ SomeTests \\ my@file.txt”

gives me that error: 给了我那个错误:

svn: E200009: 'C:/SomeTests/my@file.txt': a peg revision is not allowed here svn:E200009:'C:/SomeTests/my@file.txt':此处不允许使用peg修订版

and this: 和这个:

svn add "C:\\SomeTests\\my@file.txt@" svn添加“C:\\ SomeTests \\ my @ file.txt @”

works for me. 适合我。

also this works for me: 这对我有用:

svn info "C:\\SomeTests\\my@file.txt@" svn info“C:\\ SomeTests \\ my @ file.txt @”

more here: How to escape @ characters in Subversion managed file names? 更多这里: 如何在Subversion托管文件名中转义@字符?


Ok, fine. 好的。 But when I want to rename or move a file with @-characters. 但是当我想用@ -characters重命名或移动文件时。 It provides strange results: 它提供了奇怪的结果:

with: 有:

svn mv "C:\\SomeTests\\test.txt" "C:\\SomeTests\\my@file.txt" svn mv“C:\\ SomeTests \\ test.txt”“C:\\ SomeTests \\ my@file.txt”

I get this filename: 我得到这个文件名:

C:\\SomeTests\\my@file.txt C:\\ SomeTests \\ my@file.txt

with: 有:

svn mv "C:\\SomeTests\\test.txt" "C:\\SomeTests\\my@file.txt@" svn mv“C:\\ SomeTests \\ test.txt”“C:\\ SomeTests \\ my @ file.txt @”

I get this filename: 我得到这个文件名:

my@file.txt@ 我@ @ file.txt文件

with: 有:

svn mv "C:\\SomeTests\\test.txt" "C:\\SomeTests\\@myfile.txt" svn mv“C:\\ SomeTests \\ test.txt”“C:\\ SomeTests \\ @ myfile.txt”

I get this filename: 我得到这个文件名:

somefolder@myfile.txt somefolder@myfile.txt

with: 有:

svn mv "C:\\SomeTests\\test.txt" "C:\\SomeTests\\@myfile.txt@" svn mv“C:\\ SomeTests \\ test.txt”“C:\\ SomeTests \\ @ myfile.txt @”

I get this filename: 我得到这个文件名:

@myfile.txt@ @ myfile.txt的@

What should I do that it always works? 它应该怎么做才能始终有效? no matter if the @ sign is in the beginning, in the middle or at the end? 无论@符号是在开头,中间还是在结尾?

(edit: at my present issue the characters are always at the beginning or in second place.) (编辑:在我目前的问题上,角色总是在开头或第二位。)

I have tried everywhere to get some support. 我到处都试图获得一些支持。 But now I have found my solution by trial and error. 但现在我通过反复试验找到了我的解决方案。

Just run the command like this: 只需像这样运行命令:

svn mv "C:\@File.txt@\" "C:\@NewFile.txt/"

Add a @ (At) and a \\ (Backslash) to the source path. 将@ (At)和\\ (反斜杠)添加到源路径。 And add a / (Forwardslash) to the destination path. 并将/ (Forwardslash)添加到目标路径。

It works for me in each option: 它适用于我的每个选项:

@File to NoAtFile
@File to New@File
@File to @NewFile
NoAtFile to New@File
NoAtFile to @NewFile
_@File to NoAtFile
_@File to New@File
_@File to @NewFile

I hope it saves you the trouble I had. 我希望它能为您省去麻烦。 :) :)

Great question; 好问题; questionable answer... This appears to have been mistyped; 可疑答案......这似乎是错误的; maybe not copied from the command line. 也许不会从命令行复制。 I'm not on Windows at the moment so can't test your solution there. 我目前不在Windows上,因此无法在那里测试您的解决方案。 Also I'm renaming a directory using svn with and at symbol in the name on Linux. 此外,我正在使用svn重命名目录,并在Linux上使用名称和符号。

svn mv "WindowListGroup@bcdev.arch@gmail.com@" "AdvancedWindowList@bcdev.arch@gmail.com"

Note that a single @ at the end of the source escapes any number of them in the name. 请注意,源末尾的单个@会在名称中转义任意数量的@。 The destination is taken literally. 目的地按字面意思。

See also: This SO post 另见: 这篇SO帖子

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM