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

3

8

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\[email protected]"

gives me that error:

svn: E200009: 'C:/SomeTests/[email protected]': a peg revision is not allowed here

and this:

svn add "C:\SomeTests\[email protected]@"

works for me.

also this works for me:

svn info "C:\SomeTests\[email protected]@"

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\[email protected]"

I get this filename:

C:\SomeTests\[email protected]

with:

svn mv "C:\SomeTests\test.txt" "C:\SomeTests\[email protected]@"

I get this filename:

[email protected]@

with:

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

I get this filename:

[email protected]

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.)

Pulp answered 5/12, 2014 at 9:1 Comment(0)
P
2

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. :)

Pulp answered 16/12, 2014 at 7:2 Comment(0)
H
2

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 "[email protected]@gmail.com@" "[email protected]@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

Hoptoad answered 24/5, 2015 at 17:23 Comment(0)
S
0

I tried to rename a bunch of files, all of them containing an "@".
This PowerShell command worked for me:

Get-ChildItem | ForEach-Object {svn mv ($_.Name+'@') $_.Name.replace("abc", "def")}

It renames all files in the current folder. If a filename does not change, an error message is displayed for that file, but the operation continues.

Singlehanded answered 4/9, 2021 at 16:49 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.