You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Vyacheslav Iutin <iu...@whirix.com> on 2007/02/07 13:54:11 UTC

svn-changes-dump

Hello,

I would like to put a script into contrib/ folder. The script is for 
dumping of changed files between revisions. Maybe it'll useful for 
people. The script is attached.

Please let me know.

Thank you for advance.

-- 
Regards,
Slava

Re: svn-changes-dump

Posted by Karl Fogel <kf...@red-bean.com>.
Peter Samuelson <pe...@p12n.org> writes:
> [Vyacheslav Iutin]
>> # Copyright (c) 2007, Whirix Ltd.
>> # All rights reserved.
>> # Author: Vyacheslav Iutin <iu...@yahoo.com>
>> #
>> # Licenced under the same terms as Subversion.
>
> Hmmm, isn't "All rights reserved" the opposite of "Licensed under..."?

"All rights reserved" is a special legal formula, and it is
appropriate even for very liberal open source licenses.  It doesn't
mean what one would intuitively think it means.

Best,
-Karl

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: svn-changes-dump

Posted by Vyacheslav Iutin <iu...@whirix.com>.
Peter,

thank you very much for suggestions. Especially for HEAD revision issue.

Now it dumps dirs recursively without svn meta-data.

I'll add necessary changes and make new attempt. :)

Thanks again.

Peter Samuelson wrote:
> [Vyacheslav Iutin]
>> # Copyright (c) 2007, Whirix Ltd.
>> # All rights reserved.
>> # Author: Vyacheslav Iutin <iu...@yahoo.com>
>> #
>> # Licenced under the same terms as Subversion.
> 
> Hmmm, isn't "All rights reserved" the opposite of "Licensed under..."?
> 
> 
>> if [ -d $dir ] ; then
>> 	tempdir=`mktemp -d $dir.XXXXXX`
> 
> You should mention somewhere that this script requires the mktemp
> program, which is not standard on Unix.
> 
>> 	mv -v $dir/* $tempdir
>> 	rm -r -v $dir
> 
> You should mention somewhere that this script requires GNU coreutils;
> otherwise, I don't believe mv, rm, cp and mkdir can be assumed to
> support the -v option, nor will cp support -a.
> 
>> 	if [ ! -d $listItem ] ; then
>> 		mkdir -v -p $dir/`dirname $listItem`
>> 		cp -a -v $listItem $dir/$listItem
>> 	fi
> 
> This appears to copy the HEAD revision of each file or directory.  Are
> you sure this is what you intended?  I would have expected to get the
> file as of r345, or whatever revision I passed in to the script.
> 
> Also, did you mean to recursively copy added or modified directories?
> Including the .svn/ metadata subdirectory?  That is not what I would
> expect when running a script like this.
> 
> Finally, I suggest quoting your filenames; some people use subversion
> to store filenames with spaces and other interesting characters.

-- 
Regards,
Slava

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: svn-changes-dump

Posted by Vyacheslav Iutin <iu...@whirix.com>.
Peter,

Peter Samuelson wrote:
> [Vyacheslav Iutin]
>>> Ahh, much better syntax - I thought about suggesting this before,
>>> but I wasn't sure if it was common to all POSIX shells.  But it is,
>>> I just checked.
>> Peter, how did you check it for POSIX compatibility?
> 
> I have several POSIX shells installed on my local system so that I can
> check things like this.  Specifically I ran it in 'posh', a minimal
> POSIX shell, and 'dash', a variant of the NetBSD system shell which is
> also fairly minimalist.  Sometimes I test more complicated constructs
> on a wider variety of shells: dash, posh, bash, zsh, sash, pdksh (which
> is similar to ksh88), ksh93, and the busybox shell.  All of these are
> provided by Debian so they're easy to install.  Actually I rarely
> bother to test busybox.
> 

thank you for clarification.

> Concerning `` and $(): that was just a matter of personal preference,
> there is nothing wrong with using ``, I just wanted to mention that I
> think $() is easier to read and use.

However you found a number of real defects in the script. It is good 
reason to make something due to your preferences. :)

Do you think the util could be useful for people?

-- 
Regards,
Slava

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: svn-changes-dump

Posted by Peter Samuelson <pe...@p12n.org>.
[Vyacheslav Iutin]
> >Ahh, much better syntax - I thought about suggesting this before,
> >but I wasn't sure if it was common to all POSIX shells.  But it is,
> >I just checked.
> 
> Peter, how did you check it for POSIX compatibility?

I have several POSIX shells installed on my local system so that I can
check things like this.  Specifically I ran it in 'posh', a minimal
POSIX shell, and 'dash', a variant of the NetBSD system shell which is
also fairly minimalist.  Sometimes I test more complicated constructs
on a wider variety of shells: dash, posh, bash, zsh, sash, pdksh (which
is similar to ksh88), ksh93, and the busybox shell.  All of these are
provided by Debian so they're easy to install.  Actually I rarely
bother to test busybox.

Concerning `` and $(): that was just a matter of personal preference,
there is nothing wrong with using ``, I just wanted to mention that I
think $() is easier to read and use.

Re: svn-changes-dump

Posted by Vyacheslav Iutin <iu...@whirix.com>.
Peter,

Peter Samuelson wrote:
> -rWORKING even when a peg rev is specified.  That surprised me.  'svn
> export URL@REV' is different, -r defaults to the peg rev.

I was surprised too. Though, I think, it is correct.

> Ahh, much better syntax - I thought about suggesting this before, but I
> wasn't sure if it was common to all POSIX shells.  But it is, I just
> checked.

Peter, how did you check it for POSIX compatibility?

> speaking of minor matters - also speaking about POSIX shell features -
> I like $() better than ``.  I find it more readable, and you can nest
> $().

I just used `` all my life, since the day of my born. :)

> Insufficient quoting - if `dirname "$listItem"` has spaces in it, mkdir
> gets multiple arguments.  "`dirname "$listItem"`" works, though as I
> said earlier I prefer "$(dirname "$listItem")".

You are right, I never think about people who like spaces... The working 
  around the programmers spoil my vigilance...

-- 
Regards,
Slava

Re: svn-changes-dump

Posted by Vyacheslav Iutin <iu...@whirix.com>.
Who could answer exactly? Actually I guess it is rather easy to fix if 
it is a bug.

Malcolm Rowe wrote:
> On Fri, Feb 09, 2007 at 12:14:29AM -0600, Peter Samuelson wrote:
>> [Vyacheslav Iutin]
>>> #svn export somefile.txt@5
>>>
>>> will get HEAD revision of somefile.txt. Or not?
>> Easy enough to test.  Sure enough, 'svn export PATH@REV' defaults to
>> -rWORKING even when a peg rev is specified.  That surprised me.  'svn
>> export URL@REV' is different, -r defaults to the peg rev.
>>
> 
> Unless I'm missing something, that's a bug.  If unspecified, the operative
> revision is supposed to default to the peg revision, and then default
> to either HEAD or BASE depending upon whether we're talking about a URL
> or WC item.
> 
> Regards,
> Malcolm

-- 
Regards,
Slava

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: svn-changes-dump

Posted by Malcolm Rowe <ma...@farside.org.uk>.
On Fri, Feb 09, 2007 at 12:14:29AM -0600, Peter Samuelson wrote:
> 
> [Vyacheslav Iutin]
> > #svn export somefile.txt@5
> > 
> > will get HEAD revision of somefile.txt. Or not?
> 
> Easy enough to test.  Sure enough, 'svn export PATH@REV' defaults to
> -rWORKING even when a peg rev is specified.  That surprised me.  'svn
> export URL@REV' is different, -r defaults to the peg rev.
> 

Unless I'm missing something, that's a bug.  If unspecified, the operative
revision is supposed to default to the peg revision, and then default
to either HEAD or BASE depending upon whether we're talking about a URL
or WC item.

Regards,
Malcolm

Re: svn-changes-dump

Posted by Peter Samuelson <pe...@p12n.org>.
[Vyacheslav Iutin]
> #svn export somefile.txt@5
> 
> will get HEAD revision of somefile.txt. Or not?

Easy enough to test.  Sure enough, 'svn export PATH@REV' defaults to
-rWORKING even when a peg rev is specified.  That surprised me.  'svn
export URL@REV' is different, -r defaults to the peg rev.

> # get last revision from range
> MAXREV=${1#*:}

Ahh, much better syntax - I thought about suggesting this before, but I
wasn't sure if it was common to all POSIX shells.  But it is, I just
checked.

> # get file list
> diffList=`svn log -v -r$1 | grep -E '[[:space:]]{3}(M|A)' | \
> cut -d'/' -f 4-`

No need for a \ continuation character, both because of the `` and
because of the trailing |.  But that's a minor matter.  (:  And
speaking of minor matters - also speaking about POSIX shell features -
I like $() better than ``.  I find it more readable, and you can nest
$().

> # create folders and copy files, we copy files of latest revision from range
> for listItem in $diffList ; do
> 	if [ ! -d "$listItem" ] ; then
> 		mkdir -p "$DIR"/`dirname "$listItem"`

Insufficient quoting - if `dirname "$listItem"` has spaces in it, mkdir
gets multiple arguments.  "`dirname "$listItem"`" works, though as I
said earlier I prefer "$(dirname "$listItem")".

Re: svn-changes-dump

Posted by Vyacheslav Iutin <iu...@whirix.com>.
Peter,

about peg revision.

I think command like

#svn export somefile.txt@5

will get HEAD revision of somefile.txt. Or not? But I actually want 
revision 5 of file which is in working directory now. I didn't suppose 
to run into the problems with previously renamed/removed files. Because 
the script is for incremental updates first of all. However I've set 
both peg revision and operative revision to be more careful.

Export is much better indeed. Thank you.

Peter Samuelson wrote:
> Slava, this version looks much better.
> 
>> # get max number of revision from range
>> REV1=`echo "$1" | sed 's/^\([0-9]\+\):\([0-9]\+\)$/\1/g'`
>> REV2=`echo "$1" | sed 's/^\([0-9]\+\):\([0-9]\+\)$/\2/g'`
>> if [ $REV1 -gt $REV2 ] ; then
>> 	MAXREV=$REV1
>> else
>> 	MAXREV=$REV2
>> fi
> 
> This will fail if you use a range with non-numeric revisions - say,
> HEAD or BASE or {2007-01-25}.
> 
> I suggest just splitting on ":" and using REV2 unconditionally.  Don't
> worry about the case of "520:514" - if people want the newer rev, they
> can specify it in the right order.
> 
> 
>> 		mkdir -p "$DIR"/`dirname "$listItem"`
>> 		$SVN cat -r$MAXREV "$listItem" > "$DIR/$listItem"
> 
> I suggest 'svn export' instead of 'svn cat'.  You don't need the shell
> redirection, and more importantly, 'svn export' preserves the execute
> permission bits (from the svn:executable property).
> 
> Finally, I think you want to use peg-rev syntax - ${listItem}@$MAXREV -
> rather than -r syntax.  That way you get the same files that the log
> messages refer to.

-- 
Regards,
Slava

Re: svn-changes-dump

Posted by Peter Samuelson <pe...@p12n.org>.
Slava, this version looks much better.

> # get max number of revision from range
> REV1=`echo "$1" | sed 's/^\([0-9]\+\):\([0-9]\+\)$/\1/g'`
> REV2=`echo "$1" | sed 's/^\([0-9]\+\):\([0-9]\+\)$/\2/g'`
> if [ $REV1 -gt $REV2 ] ; then
> 	MAXREV=$REV1
> else
> 	MAXREV=$REV2
> fi

This will fail if you use a range with non-numeric revisions - say,
HEAD or BASE or {2007-01-25}.

I suggest just splitting on ":" and using REV2 unconditionally.  Don't
worry about the case of "520:514" - if people want the newer rev, they
can specify it in the right order.


> 		mkdir -p "$DIR"/`dirname "$listItem"`
> 		$SVN cat -r$MAXREV "$listItem" > "$DIR/$listItem"

I suggest 'svn export' instead of 'svn cat'.  You don't need the shell
redirection, and more importantly, 'svn export' preserves the execute
permission bits (from the svn:executable property).

Finally, I think you want to use peg-rev syntax - ${listItem}@$MAXREV -
rather than -r syntax.  That way you get the same files that the log
messages refer to.

Re: svn-changes-dump

Posted by Vyacheslav Iutin <iu...@whirix.com>.
Hi Peter,

the new version is attached. Thank you very much for legal stuff issues
pointing. Please let me know if you have any more notes.

Peter Samuelson wrote:
> [Vyacheslav Iutin]
>> # Copyright (c) 2007, Whirix Ltd.
>> # All rights reserved.
>> # Author: Vyacheslav Iutin <iu...@yahoo.com>
>> #
>> # Licenced under the same terms as Subversion.
> 
> Hmmm, isn't "All rights reserved" the opposite of "Licensed under..."?
> 
> 
>> if [ -d $dir ] ; then
>> 	tempdir=`mktemp -d $dir.XXXXXX`
> 
> You should mention somewhere that this script requires the mktemp
> program, which is not standard on Unix.
> 
>> 	mv -v $dir/* $tempdir
>> 	rm -r -v $dir
> 
> You should mention somewhere that this script requires GNU coreutils;
> otherwise, I don't believe mv, rm, cp and mkdir can be assumed to
> support the -v option, nor will cp support -a.
> 
>> 	if [ ! -d $listItem ] ; then
>> 		mkdir -v -p $dir/`dirname $listItem`
>> 		cp -a -v $listItem $dir/$listItem
>> 	fi
> 
> This appears to copy the HEAD revision of each file or directory.  Are
> you sure this is what you intended?  I would have expected to get the
> file as of r345, or whatever revision I passed in to the script.
> 
> Also, did you mean to recursively copy added or modified directories?
> Including the .svn/ metadata subdirectory?  That is not what I would
> expect when running a script like this.
> 
> Finally, I suggest quoting your filenames; some people use subversion
> to store filenames with spaces and other interesting characters.

-- 
Regards,
Slava


Re: svn-changes-dump

Posted by Peter Samuelson <pe...@p12n.org>.
[Vyacheslav Iutin]
> # Copyright (c) 2007, Whirix Ltd.
> # All rights reserved.
> # Author: Vyacheslav Iutin <iu...@yahoo.com>
> #
> # Licenced under the same terms as Subversion.

Hmmm, isn't "All rights reserved" the opposite of "Licensed under..."?


> if [ -d $dir ] ; then
> 	tempdir=`mktemp -d $dir.XXXXXX`

You should mention somewhere that this script requires the mktemp
program, which is not standard on Unix.

> 	mv -v $dir/* $tempdir
> 	rm -r -v $dir

You should mention somewhere that this script requires GNU coreutils;
otherwise, I don't believe mv, rm, cp and mkdir can be assumed to
support the -v option, nor will cp support -a.

> 	if [ ! -d $listItem ] ; then
> 		mkdir -v -p $dir/`dirname $listItem`
> 		cp -a -v $listItem $dir/$listItem
> 	fi

This appears to copy the HEAD revision of each file or directory.  Are
you sure this is what you intended?  I would have expected to get the
file as of r345, or whatever revision I passed in to the script.

Also, did you mean to recursively copy added or modified directories?
Including the .svn/ metadata subdirectory?  That is not what I would
expect when running a script like this.

Finally, I suggest quoting your filenames; some people use subversion
to store filenames with spaces and other interesting characters.