Lets say that I have a file that starts in directory1
and I move the file to directory2
in revision 2
. The Node-copyfrom-rev
in the dump file is 1
. How do I extract the contents of the file based on only knowing where it might have previously been without a certainty of where it will end up in the most up to date working copy?
For instance, if I run
svn cat -r 1 directory1/file.txt
,
you won't be able to find the file. You need to perform
svn cat -r 1 directory2/file.txt
which requires knowledge that the file in the working copy exists in directory2 at the end.
There are two separate ways of specifying a revision:
svn -r$rev $URL
svn $URL@$rev
.Think of the first way (plain revision number) as giving you a revision of a file, and the second way (the pinned revision number) as giving you the revision number of the directory.
For example, in revision 10, I did this:
$ svn co $REPO/trunk/foo
A foo/foo.txt
A foo/bar.txt
$ cd foo
$ svn delete bar.txt
$ svn commit -m"Removed bar.txt in revision 10"
committed revision 11
Now, it's revision 20 and I realize I need to see what bar.txt
looked like. If I do this:
$ svn cat -r10 $REPO/trunk/foo/bar.txt
I'll get an error because there is no longer an element in my repository /trunk/foo/bar.txt
. What I need to do is to also go back to the repository structure back in revision 10. I can do that by pinning revision 10 onto the URL:
$ svn cat -r10 $REPO/trunk/foo/bar.txt@10
That will give me the contents of bar.txt
at revision 10 as it existed in the repository at revision 10.
Let's look at my log:
$ svn log -v -r161077 $REPO/trunk/Tools/server_tools/
------------------------------------------------------------------------
r161077 | dweintraub | 2013-05-23 17:02:03 -0400 (Thu, 23 May 2013) | 1 line
Changed paths:
D /trunk/Tools/server_tools/jdescribe.pl
Deleting -- in wrong repository
------------------------------------------------------------------------
$
You can see that jdescribe.pl
was deleted in revision 161077 of my repository. Thus, if I want it, I need to look at revision 161076:
If I do this:
$ svn ls -r161076 $REPO/trunk/Tools/server_tools
find-required-jars.pl
jdescribe.pl
jenkins-bin/
There it is, in revision 161076 of the directory:
Let's concatenate out jdescribe.pl
:
$ svn cat -r161076 $REPO/trunk/Tools/server_tools/jdescribe.pl
svn: warning: W160013: '/svn/TravelClickPD/!svn/rvr/161264/trunk/Tools/server_tools/jdescribe.pl' path not found
svn: E200009: Could not cat all targets because some targets don't exist
svn: E200009: Illegal target for the requested operation
$
Didn't work. There's no jdescribe.pl
in the current revision of the directory.
Let's add the pinned revision:
$ svn cat -r161076 $REPO/trunk/Tools/server_tools/jdescribe.pl@161076 | head
#! /usr/bin/env perl
# description.pl
use 5.12.0;
use warnings;
use LWP::UserAgent;
use HTTP::Request::Common qw(POST);
use Pod::Usage;
use Getopt::Long;
There it is!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With