New and improved and simplified version. Uses 'svn log --diff' to get the files that changed.
Again, only lightly tested. (The previous script assumed that the order of the xml attributes didn't change and it did. Ooops.)
I used perl instead of sed due to sed version silliness in regards to tabs; so feel free to the perl equivalent sed commands to remove the trailing "\t (revision 12345)" from the "svn log --diff ... | grep '^+++' " output.
Remove the two echo commands to actually run the mkdir/export commands.
Edge case: I didn't test how 'svn log --diff' handles deleted files.
#!/bin/bash
REV=$1
SVNREPO=$2
svn log --diff -r $REV "$SVNREPO" | grep '^+++' | perl -pe 's/^\+\+\+ //; s/\t.*$//' | while read i
do
D=./`dirname "$i"`
echo mkdir -p "$D"
echo svn export --force "$SVNREPO/$i@$REV" "$D/"
done
-----Original Message-----
From: horst.schlonz_at_gmx.de [mailto:horst.schlonz_at_gmx.de]
Sent: Wednesday, March 29, 2017 9:28 PM
To: users_at_subversion.apache.org
Subject: Re: How to checkout only the changes
On 03/27/2017 10:08 AM, Andrew Reedick wrote:
>> From: horst.schlonz_at_gmx.de [mailto:horst.schlonz_at_gmx.de]
>> Sent: Friday, March 24, 2017 4:04 PM
>> To: users_at_subversion.apache.org
>> Subject: How to checkout only the changes
>>
>>
>> Is there a way to export only the changes, that occured in a specific revision? Like export or checkout only the added or modified files in their respective paths? Deletions and cheap copies cannot be treated that way, obviously. Please CC as I am not subscribed.
>
> FYI, 'svn copy' counts as an Add. That may or may not be a concern?
>
> Mostly Untested But Seems to Work in the Average Case(tm), so user beware:
>
> #!/bin/bash
>
> # usage: foo.sh 1234 http://svn_server/repo_name
> REV=$1
> SVNREPO=$2
>
> svn log -qv -r $REV $SVNREPO
>
> # Yes we're grepping on XML because :laziness:
> # And we're using perl because I can't be bothered with sed/awk subtleties
> svn log -qv --xml -r $REV "$SVNREPO" | perl -ne 'chomp; $a=1 if /^ action="[AD]"/; print "$1\n" if ( $a && /^ kind="file">(.*)<\/path>/ ); $a=0 if /<\/path>/;' | while read i
> do
> D=./`dirname "$i"`
> mkdir -p "$D"
> svn export --force "$SVNREPO/$i@$REV" "$D/"
> done
>
The script just drops to the shell with exit code 0. My perl knowledge is very limited, but to debug I executed this
$ echo "action=\"A\">/trunk/text.txt</path>" | perl -ne 'chomp; $a=1 if /^ action="[AD]"/; print "$1\n" if ( $a && /^ kind="file">(.*)<\/path>/ ); $a=0 if /<\/path>/;'
I assume that is supposed to do something but for me it just drops to the shell with exit code 0.
Received on 2017-03-30 15:09:45 CEST