192
votes

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?

11
Why on earth do you have filenames with @ in them? Asking for trouble, if you ask me... :-)JesperE
Very good question! :) I'm taking over a project where this character is a fundamental component of the file naming conventions and unfortunately this cannot be changed in the near future.weston
Apple created this convention for all its iOS developers as of iOS 4+. All assets should be named @2x if they are for a high res display...Dimitris
Standard for ghetto old-style Matlab OOChinasaur
Also, if you save your private key or revocation key from Thunderbird's Enigmail, it creates a file name -- not unreasonably, given the application -- containing an at signPeter Flynn

11 Answers

284
votes

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

83
votes

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.

14
votes

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.

12
votes

to add the following file : [email protected] do the following: svn add image\@2x.png@

12
votes

Simply add

@

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

[email protected]

to

[email protected]@
8
votes

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]@'
6
votes

To add multiple files, there is alternative solution:

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

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"

0
votes

@David H

I just tried a similar command without escaping the @ symbols and it still works fine

svn ci splash.png [email protected]@

This is on GNU bash, version 3.2.48(1)-release (x86_64-apple-darwin10.0) and svn 1.6.16

0
votes

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

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

0
votes

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@ ")