简体   繁体   中英

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

From the SVN 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@.


According to this description, you only need to add an @ sign to the path.

so this:

svn add "C:\\SomeTests\\my@file.txt"

gives me that error:

svn: E200009: 'C:/SomeTests/my@file.txt': a peg revision is not allowed here

and this:

svn add "C:\\SomeTests\\my@file.txt@"

works for me.

also this works for me:

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

more here: How to escape @ characters in Subversion managed file names?


Ok, fine. But when I want to rename or move a file with @-characters. It provides strange results:

with:

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

I get this filename:

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

with:

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

I get this filename:

my@file.txt@

with:

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

I get this filename:

somefolder@myfile.txt

with:

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

I get this filename:

@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. And add a / (Forwardslash) to the destination path.

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. Also I'm renaming a directory using svn with and at symbol in the name on 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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