[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: Reverting to an older revision for a single file

From: B. Smith-Mannschott <benpsm_at_gmail.com>
Date: 2007-04-06 10:38:29 CEST

On Apr 5, 2007, at 22:33, Larry Martell wrote:

> If I have a project and I want to revert back to an older version
> of one file,
> what is the best way to do that?
>
> Here's a specific example:
>
> Let's say the head revision of my project is at 100, and I want to
> get revision
> 90 of file.c and check that in at the head and have version 101. I
> tried this:
>
> svn up
> svn -r90 up file.c
> svn ci
>
> The ci silently did nothing at all.
>
> What I had to do to get this to work was:
>
> svn up
> svn -r90 up file.c
> mv file.c file.c.90
> svn up
> mv file.c.90 file.c
> svn ci
>
> Is that the proper way to do this, or is there a better way?
>

Merge, specifically with a reversed revision range. See example that
follows. Also read the chapter on merging in the Subversion Book.

[bsmith@ws235:/repos]

$ svnadmin create example
$ svn co file:///repos/example example.wc
Checked out revision 0.
$ cd example.wc

[bsmith@ws235:/repos/example.wc]

$ echo "This will be in file.txt at revision 1" > file.txt
$ svn add file.txt
A file.txt

$ svn ci -m 'new: file.txt'
   Adding file.txt
   Transmitting file data .
   Committed revision 1.

$ echo "This will be file.txt at revision 2" > file.txt
$ svn ci -m 'changed: file.txt'
Sending file.txt
Transmitting file data .
Committed revision 2.

# merge the changes from necessary to get from HEAD to revision 1 of
# file.txt into file.txt. Since file.txt is at HEAD, this effectively
# reverts it to what it was in revision 1 of the repository.

$ svn merge -rHEAD:1 file.txt
U file.txt

$ cat file.txt
This will be in file.txt at revision 1

$ svn ci -m 'file.txt, reverted to what it was in revision 1'
Sending file.txt
Transmitting file data .
Committed revision 3.

$ svn cat -r1 file.txt
This will be in file.txt at revision 1

$ svn cat -r2 file.txt
This will be file.txt at revision 2

$ svn cat -r3 file.txt
This will be in file.txt at revision 1

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org
Received on Fri Apr 6 10:38:58 2007

This is an archived mail posted to the Subversion Users mailing list.