How to escape @ characters in Subversion managed file names?

SvnEscaping

Svn Problem Overview


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.

However, when the name of the file contains an @, it is incorrectly interpreted by Subversion as a revision specifier:

> svn info '[email protected]' svn: Syntax error parsing revision '.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?

Svn Solutions


Solution 1 - Svn

From the SVN book (emphasis added):

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

Solution 2 - Svn

The original answer is correct, but perhaps not explicit enough. The particular unix command line options are as follows:

svn info '[email protected]@'

or

svn info "[email protected]@"

or

svn info image\@2x.png\@

I just tested all three.

Solution 3 - Svn

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.

Solution 4 - Svn

to add the following file : [email protected] do the following: svn add [email protected]@

Solution 5 - Svn

Simply add

> @

at the of the file you need to use, no matter what SVN command it is, e.g.:

file@2x.jpg

to

file@2x.jpg@

Solution 6 - Svn

In my case I needed to remove files from a SVN repo that contained an @ sign:

This wouldn't work:

svn remove 'src/assets/images/hi_res/[email protected]'

But this did:

svn remove 'src/assets/images/hi_res/[email protected]@'

Solution 7 - Svn

To add multiple files, there is alternative solution:

svn status | grep \.png | awk '{print $2"@"}'| xargs svn add

Solution 8 - Svn

For svn commands with 2 arguments like "move", you must append "@" only at left (first) parameter. For example:

$ 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

As you can see, we don't need to append "@" at "README2@txt"

Solution 9 - Svn

@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

Solution 10 - Svn

The only solution that worked for me was the same suggested by @NPike

svn revert 'path/to/filename@ext@'

Solution 11 - Svn

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

 svn add  $(find . -name "*@*.png" -printf "%p@ ")

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionwestonView Question on Stackoverflow
Solution 1 - SvnRob KennedyView Answer on Stackoverflow
Solution 2 - SvnDavid HView Answer on Stackoverflow
Solution 3 - SvnLcskyView Answer on Stackoverflow
Solution 4 - SvnMalek BelkahlaView Answer on Stackoverflow
Solution 5 - SvnAlejandro Pablo TkachukView Answer on Stackoverflow
Solution 6 - SvnNPikeView Answer on Stackoverflow
Solution 7 - SvnliruqiView Answer on Stackoverflow
Solution 8 - SvnSrdjanView Answer on Stackoverflow
Solution 9 - SvnQazzianView Answer on Stackoverflow
Solution 10 - SvnJonyx4View Answer on Stackoverflow
Solution 11 - SvnMichel BillaudView Answer on Stackoverflow