[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: Determining which files are treated as binary

From: Dominic Anello <danello_at_danky.com>
Date: 2005-06-02 16:16:05 CEST

On 2005-06-02 09:11:51 +0100, Greg Thomas wrote:
> On Wed, 01 Jun 2005 14:31:08 -0400, Christopher Ness
> <chris@nesser.org> wrote:
>
> >On Wed, 2005-06-01 at 09:25 +0100, Greg Thomas wrote:
> >> I'm trying to create a post-commit hook to set the svn:needs-lock
> >> property on binary files - which should be simple enough.
> >
> >Just to nip this in the bud. You *cannot* modify a commit transaction
> >with a hook script. You can only reject it.
>
> I'm not planning to alter a commit transaction. I'm modifying a
> property (which isn't version controlled anyway) *after* a commit
> transaction. I understand why you can't modify a commit in a
> pre-commit hook, but I don't see any issues in updating the repository
> in a post-commit hook.
----8<----

Properties *are* version-controlled. Revision properties aren't, but
svn:mime-type isn't a rev prop. Furthermore, if you look at the help
for svn propset, you'll see that ps without the --revprop flag only
accepts PATHs as an argument, so you have to check out a working copy.
Not to say it can't be done, but your hook script will both create
additional revisions and need to manage working copies.

> >Depending on your OS, here is a one liner that should get you what you
> >want, then cut the end off and run that through xargs again to set the
> >need-lock property.
> >
> >find . -type f | grep -v .svn | xargs svn propget "svn:mime-type" 2>/dev/null | grep application/octet-stream$
>
> That's fine for application/octet-stream files, but what about other
> mime-types - GIFs, PNGs, Word, Excel, etc. I'd need an exhaustive list
> of all binary types. Given that svn has already identified the file as
> binary when it was added, I was hoping to use that identification.

IIRC, everything without a text/* mime-type will get treated as binary
so just look for non-text mime-types:

find . -! -path '*/.svn/*' -type f | \
  | xargs svn propget "svn:mime-type" 2>/dev/null | grep -v 'text/'

-Dominic

  • application/pgp-signature attachment: stored
Received on Thu Jun 2 16:31:16 2005

This is an archived mail posted to the Subversion Users mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.