How to checkout only the changes

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

How to checkout only the changes

horst.schlonz

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.
Reply | Threaded
Open this post in threaded view
|

Re: How to checkout only the changes

Ryan Schmidt-8

On Mar 24, 2017, at 15:04, [hidden email] wrote:

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

There's no built-in command to do that.

Reply | Threaded
Open this post in threaded view
|

Re: How to checkout only the changes

horst.schlonz
On 3/24/2017 7:56 PM, Ryan Schmidt wrote:
>
> On Mar 24, 2017, at 15:04, [hidden email] wrote:
>
>> 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.
>
> There's no built-in command to do that.
>
Maybe somebody wrote a script for this?

I'd like to index these files, but I don't want to index the same files
again and again.
Reply | Threaded
Open this post in threaded view
|

Re: How to checkout only the changes

Mark Phippard-3
On Sat, Mar 25, 2017 at 10:59 AM, <[hidden email]> wrote:
On 3/24/2017 7:56 PM, Ryan Schmidt wrote:

On Mar 24, 2017, at 15:04, [hidden email] wrote:

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.

There's no built-in command to do that.

Maybe somebody wrote a script for this?

I'd like to index these files, but I don't want to index the same files again and again.

You could maintain a working copy and just run svn update and scrape the output to identify changes.  Otherwise you need to run svn log -v with a script and then use svn cat to get the individual files.

--
Reply | Threaded
Open this post in threaded view
|

RE: How to checkout only the changes

Andrew Reedick-2
In reply to this post by horst.schlonz
> From: [hidden email] [mailto:[hidden email]]
> Sent: Friday, March 24, 2017 4:04 PM
> To: [hidden email]
> 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



Reply | Threaded
Open this post in threaded view
|

Re: How to checkout only the changes

horst.schlonz
On 03/27/2017 10:08 AM, Andrew Reedick wrote:

>> From: [hidden email] [mailto:[hidden email]]
>> Sent: Friday, March 24, 2017 4:04 PM
>> To: [hidden email]
>> 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.

Reply | Threaded
Open this post in threaded view
|

RE: How to checkout only the changes

Andrew Reedick-2
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: [hidden email] [mailto:[hidden email]]
Sent: Wednesday, March 29, 2017 9:28 PM
To: [hidden email]
Subject: Re: How to checkout only the changes

On 03/27/2017 10:08 AM, Andrew Reedick wrote:

>> From: [hidden email] [mailto:[hidden email]]
>> Sent: Friday, March 24, 2017 4:04 PM
>> To: [hidden email]
>> 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.

Reply | Threaded
Open this post in threaded view
|

Re: How to checkout only the changes

Daniel Shahaf-2
Andrew Reedick wrote on Thu, Mar 30, 2017 at 13:09:26 +0000:
> svn log --diff -r $REV "$SVNREPO"  | grep '^+++' | perl -pe 's/^\+\+\+ //; s/\t.*$//' | while read i

'svn diff --summarize' or 'svn log -qv' would be better.  (They're O(1)
as opposed to O(revision size).)
Reply | Threaded
Open this post in threaded view
|

RE: How to checkout only the changes

Andrew Reedick-2

> -----Original Message-----
> From: Daniel Shahaf [mailto:[hidden email]]
> Sent: Thursday, March 30, 2017 3:41 PM
> To: Andrew Reedick
> Cc: [hidden email]; [hidden email]
> Subject: Re: How to checkout only the changes
>
> 'vsvn diff --summarize' or 'svn log -qv' would be better.  (They're O(1) as opposed to O(revision size).)


Unfortunately, neither one differentiates between directories and filenames (unless you go with --xml.)  And exporting a dir will grab a bit more than what we wanted.  Unless of course the contents of new directories count as changes.  Which would be a requirements question for the OP.
Reply | Threaded
Open this post in threaded view
|

Re: How to checkout only the changes

horst.schlonz
On 03/31/2017 12:22 PM, Andrew Reedick wrote:

>
>> -----Original Message-----
>> From: Daniel Shahaf [mailto:[hidden email]]
>> Sent: Thursday, March 30, 2017 3:41 PM
>> To: Andrew Reedick
>> Cc: [hidden email]; [hidden email]
>> Subject: Re: How to checkout only the changes
>>
>> 'vsvn diff --summarize' or 'svn log -qv' would be better.  (They're O(1) as opposed to O(revision size).)
>
> Unfortunately, neither one differentiates between directories and filenames (unless you go with --xml.)  And exporting a dir will grab a bit more than what we wanted.  Unless of course the contents of new directories count as changes.  Which would be a requirements question for the OP.
>

I'm not sure if I understand what you guys are talking about.

Done some testing and it seems to do well, thanks. It exports a file
with its path when the file has been added or modified (compared to the
previous revision). I think I can easily wrap this in a loop to go
through all revisions of a repository.

However, it would be even better if it would ignore cheap copies as
these do not not contain that much new information. Maybe I can catch
most of these if I ignore pathnames that contain "tags" or "branches".