问题
In Subversion, is it possible to check out only those files affected during a specific commit, provided you know the specific revision number?
回答1:
I think that a Subversion check out can only check out a specific folder and not individual files. That said, the command:
svn log -r *revision* -q -v
will list the changes associated with the specified revision so you could process the output of this command to help copy the desired files to somewhere after checking out a working folder for the full directory.
回答2:
you can get a list of files modified since a specific revision like this:
svn diff -r [REVNUM]:HEAD --summarize > fileschanged.txt
then create a script to checkout each file in the fileschanged.txt
回答3:
I think it's possible that you're using the term "check out" here in its CVS sense, that is, an "svn update". Is that right?
If so, then you can update to the particular revision that you want:
svn update -r12345
or even just those files to that revision:
svn update -r12345 file1 file2 file3
though you'll have to get the list of files from svn using some of the other suggestions.
回答4:
I know it's a bit offtopic but I use TRAC to do this and it exports only the files modified between 2 revisions as a zip archive with the files in their original directory structure.
回答5:
svn checkout
only works at the directory level, not the file level. Of course, if all the changes in a specific changeset were from the same directory, then you can perform the svn checkout <url> <path> -r<revid>
.
回答6:
You can check the list of affected files using svn log -q -v -r123 url
.
If you really only want to get the affected files you can use svn cat urlToFile -r123 > myfile
for each file.
回答7:
If you're using a recent version of svn you can checkout an empty folder, then update the specific files.
after getting your list of files to select,
svn co --depth=empty url dest
cd dest
svn up file1 file2 file3
Edit: pretty much the same solution as accepted answer here: Checkout one file from Subversion
回答8:
Here is one way to do it.
svn co --depth empty svn://myrepository/mytrunk
cd mytrunk
svn diff -c[REVNUM] svn://myrepository/mytrunk | grep "Index:" | awk '{print $2}' | xargs -n 1 svn update --parents
The output from the awk one-liner is a list of files changed with relative paths. As previously mentioned, update works on individual files while checkout works on modules. The '--parents' option forces the creation of directories in your working copy as necessary.
Note that update also has a '--changelist' option (at least in v.1.7.1+), but it didn't seem to be doing what I wanted.
回答9:
I needed a dump of all the files that had changed within a range of a dozen revisions. I did it like so (these commands may not be perfect, this is just a general explanation):
Create a diff that will show the files you need and write the list to a text file
svn diff --summarize -r219:232 > r219-232_Summary.txt
This will give you a text file with lines like
M path/to/file.php
Massage the file format to replace the beginning of each line with an 'svn up' command, instead of 'A ' or 'M ' or whatever.
sed -i 's/A /svn up /g' ./r219-232_Summary.txt
... which will give you lines like
svn up path/to/file.php
Create a new directory and check out your project to it
svn co http://www.repo.net/whatever
Remove everything in the directory except the .svn file (I'm using a relatively recent svn client so if you're on an old svn client that has a .svn in every directory, not sure how that will work)
rm -rf ./*
Copy in your text file, make it executable, and run it as a script.
cp /path/to/wherever/r219-232_Summary.txt ./r219-232_Summary.sh
chmod 777 ./r219-232_Summary.sh
./r219-232_Summary.sh
If all goes as planned, then shell should parse each 'svn up' command in your text file and populate the directory with only the files that you're interested in.
回答10:
Here is a simple bash script version. I used a "search pattern" to remove unnecessary lines. Revision, repository address and destination path are given as arguments but it could be hardcoded.
#!/bin/bash
REVISION=${1}
REPOSITORY="${2}"
DEST_PATH="${3}"
SEARCH_PATTERN="trunk"
FILES=$(svn log -q -v $REPOSITORY -r $REVISION | grep $SEARCH_PATTERN)
mkdir -p $DEST_PATH
for FILE in $FILES ; do
if [[ $FILE == *"$SEARCH_PATTERN"* ]]
then
FOLDER=$(dirname $FILE)
mkdir -p $DEST_PATH/$FOLDER
svn export -r $REVISION $REPOSITORY/$FILE $DEST_PATH/$FOLDER
fi
done
#EOF
回答11:
You can get just the list of files in a particular change using
svn log -v -q -r rev
You can then clean up the markers on the front of the line with a pipe like
sed -e "s/^ . / /" | egrep -v "Changed paths:|-----"
. In order to get just the files, you would probably use svn cat
as suggested by Nikolai.
[edited to cleanup and simplify the sed pipeline.]
回答12:
Sorry to resurrect a long-dead question, but it was never answered to my satisfaction.
You can build a simple tool to do this for you using SVNKit. I found this blog about it, and slightly modified the code for my needs. I'm using it to this day in my deployment process.
It does an export not a checkout, but I'm sure that would be a simple change.
回答13:
svn mergeinfo --show-revs eligible http://base.com.rev1 http://base.com.rev2
This will give a lot of revisions
Now you would like to see the list of files in each revision. So take the list of revision and copy into note pad or editplus and modify so that they fit into one line
svn log -r r33521 -r33762 -3456 -r5623 -q -v >> missedFiles.txt
Note : I had 118 revisions and I was not able to get the list of files correctly. So i ran the above command by breaking into subsets of revision
来源:https://stackoverflow.com/questions/971188/subversion-check-out-only-those-files-affected-during-a-specific-commit