194

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 'test@.txt' 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?

weston
  • 2,878
  • 3
  • 24
  • 23
  • 3
    Why on earth do you have filenames with @ in them? Asking for trouble, if you ask me... :-) – JesperE Apr 16 '09 at 18:28
  • 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 Apr 16 '09 at 18:43
  • 57
    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 Sep 14 '10 at 13:57
  • 2
    Standard for ghetto old-style Matlab OO – Chinasaur May 04 '12 at 16:53
  • 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 sign – Peter Flynn Mar 13 '17 at 10:44
  • In linux systemd services, @ character is often use – Damgot Dec 21 '17 at 15:19
  • @JesperE sometimes you get no choice, developers use @ signs in filenames for things like resolution-dependent variants – Peter Flynn Sep 01 '19 at 21:04

11 Answers11

287

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

Rob Kennedy
  • 161,384
  • 21
  • 275
  • 467
  • 4
    Note that for using "svn diff" you need to add revision parameter. "svn up @file@" works, but "svn diff @file@" doesn't work. You need to use "svn diff -r HEAD @file@" – analytik Oct 18 '11 at 14:38
  • Note for the SVN book: files can exist without extensions, even on Windows, so `news@11` could be a file, as well. – trysis Feb 22 '18 at 14:42
  • 1
    Note that for some commands, like rename, an argument can be either a versioned item or a local file name. In the case of rename, the target also gets scanned for a pinned revision, but it might then afterwards be treated as a plain name. For example, if you want to rename `@foo` to `@bar`, `svn rename @foo@ @bar` will complain about `@bar`; but if you make it `svn rename @foo@ @bar@`, the new name will be literally `@bar@`. To avoid this, add `./` (or `.\ ` on windows) to make it clear it's a local path: `svn rename @foo@ ./@bar`. – Zastai Oct 23 '18 at 07:59
83

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

svn info 'image@2x.png@'

or

svn info "image@2x.png@"

or

svn info image\@2x.png\@

I just tested all three.

Dan J
  • 25,433
  • 17
  • 100
  • 173
David H
  • 40,852
  • 12
  • 92
  • 138
  • 5
    I also tested `svn info icon@2x.png@` and it worked, too. Yes, no quotes or slashes! – Nate Apr 12 '13 at 07:46
  • The necessity for quoting depends on your shell - I use KSH and for sure you need the quotes (as '@' is a sign you want a process run in the background). YMMV depending on shell. – David H Apr 12 '13 at 12:51
  • Yep. My mileage was on the `bash` highway :) – Nate Apr 12 '13 at 20:59
  • 1
    @Nate Now I cannot make it fail - its working fine without the quotes in ksh. I don't know why I thought I needed them - maybe some other issue - it was 2 years ago I posted this... – David H Apr 12 '13 at 21:36
14

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.

Lcsky
  • 825
  • 1
  • 8
  • 17
  • be sure to quote or escape your file names (and do case-insensitive matching). also there's no need to treat files with `@` in their name as a special case, you can safely append the `@` symbol onto all file names: `for file in $(find ./ -type f -iname "*.png"); do svn add "$file@"; done`. also, doesn't this approach leave your svn repo with a file/directory structure inconsistent with the working local copy? – ardnew Jul 11 '13 at 17:54
  • using `exec` of find might be eaiser: `find . -type f -name "*@*.png" -exec svn add {}@ \;` – Walty Yeung Jan 23 '20 at 07:32
12

to add the following file : image@2x.png do the following: svn add image\@2x.png@

Malek Belkahla
  • 121
  • 1
  • 2
12

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

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/locales-usa@2x.png'

But this did:

svn remove 'src/assets/images/hi_res/locales-usa@2x.png@'
NPike
  • 13,136
  • 12
  • 63
  • 80
6

To add multiple files, there is alternative solution:

svn status | grep \.png | awk '{print $2"@"}'| xargs svn add
liruqi
  • 1,524
  • 15
  • 12
1

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"

Srdjan
  • 121
  • 5
0

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

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

Jonyx4
  • 157
  • 1
  • 6
0

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@ ")
Michel Billaud
  • 1,758
  • 11
  • 14
0

@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

Qazzian
  • 684
  • 6
  • 9