You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Martin Furter <mf...@rola.ch> on 2003/08/17 16:53:38 UTC

automatic properties

Hello

I made a little patch which adds a new feature: automatic adding of
properties when adding files.
Attached is a patch for subversion/libsvn_client/add.c

After adding the patch you can define a new section in
~/.subversion/config and add entries describing the properties.

There are 3 types of entries: exact matches, suffix matches and the
default. 
Exact matches have the highest priority, the default match the lowest. The
longer a suffix match is the higher it's priority.

Here is an example config:

[auto-props]
* = svn:executable
*.txt = svn:eol-style=native
*.old.txt =
*.sh = svn:eol-style=LF;svn:executable
README.old.txt = svn:eol-style=CRLF
Makefile = svn:eol-style=LF

The format of the properties is name=value;name=value;...
For boolean properties only the name is specified.

I think this simple feature is enough for 99% of the use cases, making it
more complex would also make the config more complex and less human
readable.

Probably some cleanup of the code is needed, and extensive testing, so if
you like the patch just ask me.

Martin

Re: automatic properties

Posted by Philip Martin <ph...@codematters.co.uk>.
Martin Furter <mf...@rola.ch> writes:

> I made a little patch which adds a new feature: automatic adding of
> properties when adding files.

I like this idea in general, but I think it has some problems.

> Attached is a patch for subversion/libsvn_client/add.c

Please include a log message when you send a patch, see the HACKING
file.

> After adding the patch you can define a new section in
> ~/.subversion/config and add entries describing the properties.
>
> There are 3 types of entries: exact matches, suffix matches and the
> default. 
> Exact matches have the highest priority, the default match the lowest. The
> longer a suffix match is the higher it's priority.

I see you are implementing the pattern matching manually.  Did you
choose the above rules because they were simple to implement?  Are you
aware of apr_fnmatch, as used in svn_string.c?  I think I'd prefer an
ordered list, with full apr_fnmatch pattern matching, where the first
list element to match is used.  However, I'm not sure if the current
config file mechanism supports such an ordered list.

> Here is an example config:
>
> [auto-props]
> * = svn:executable
> *.txt = svn:eol-style=native
> *.old.txt =
> *.sh = svn:eol-style=LF;svn:executable
> README.old.txt = svn:eol-style=CRLF
> Makefile = svn:eol-style=LF

Users are going to want to use this feature to set svn:ignore, but it
doesn't look like that will work since svn:ignore generally has a
multi-line value.  I suppose a space separated list could be used
above (like global-ignores), but then the code is going to have to
convert spaces into newlines for this particular "magic" property.

I wonder if separate lists for files and directories are required?
Taking your example above, if you try to set svn:executable on a
directory using the current command line client you will get an
"Illegal target" error.  I suspect users may also want to set
svn:keywords, and again that property doesn't apply to directories, so
putting it in your '*' rule will cause problems.

> The format of the properties is name=value;name=value;...
> For boolean properties only the name is specified.
>
> I think this simple feature is enough for 99% of the use cases, making it
> more complex would also make the config more complex and less human
> readable.

I'd like this feature to provide better support for svn:ignore and
svn:keywords.

-- 
Philip Martin

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

Re: automatic properties

Posted by Lele Gaifax <le...@seldati.it>.
>>>>> Garrett Rooney l'ha dit:

    Garrett> cmpilato@collab.net wrote:
    >> Martin Furter <mf...@rola.ch> writes:
    >>
    >>
    >>> Hello
    >>>
    >>> I made a little patch which adds a new feature: automatic
    >>> adding of properties when adding files.  Attached is a patch
    >>> for subversion/libsvn_client/add.c
    >>
    >>
    >> Is this something you'd want to happen for 'svn import' as
    >> well?  Just a thought...

    Garrett> I'd say no, or at least provide a way to turn it off, as
    Garrett> import commits things directly to the repository, with no
    Garrett> opportunity to tweak the results.  With add, you can
    Garrett> always change the properties before you run the commit in
    Garrett> case your defaults are not appropriate for this
    Garrett> particular file/directory.

Right, but should the function emit some kind of warning about what
happened then?

OTOH, I'd prefer it as a per repository setting, but of course this is
already very nice, for a keyword-addict such as me ;-)

Thanx&bye,
lele.
-- 
nickname: Lele Gaifax	| Quando vivrò di quello che ho pensato ieri
real: Emanuele Gaifas	| comincerò ad aver paura di chi mi copia.
email: lele@seldati.it	|		-- Fortunato Depero, 1929.


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

Re: automatic properties

Posted by Garrett Rooney <ro...@electricjellyfish.net>.
Martin Furter wrote:


> I thought i could add 2 commandline switches, --auto-props and
> --no-auto-props, so enabling and disabling is both possible, and when they
> are found on the cmdline the value of the config is overwritten with
> svn_config_set().
> This way i don't need to change any API or struct. Is that OK ?

That sounds good to me.

> +/* Method which automatically adds properties.
> +   
> +   @param path        a filename
> +   @param ctx         the client context
> +   @param pool        apr memory pool
> +   @param adm_access  whatever ???, used when adding
> +   @param editor      editor, used when importing
> +   @param file_baton  file baton for editor, used when importing
> +   @param mimetype    pointer for returning mimetype, used when importing
> +   @param executable  pointer for returning executable, used when importing
> +   @return            an svn_error_t or SVN_NO_ERROR when everything went OK
> +*/
> +svn_error_t *
> +svn_client__add_auto_props (const char *path,
> +                            svn_client_ctx_t *ctx,
> +                            apr_pool_t *pool,
> +                            svn_wc_adm_access_t *adm_access,
> +                            const svn_delta_editor_t *editor,
> +                            void *file_baton,
> +                            const char **mimetype,
> +                            int *executable);
> +

I haven't had a chance to look closely at the patch, but in order to get 
doxygen to pick up your @param tags you'll have to start the comment 
with /** like the rest of the doxygen comments in svn_client.h.  Also, 
our documentation comments tend to be a bit more conversational than 
that, see the rest of the file for examples.

-garrett


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

Re: automatic properties

Posted by Martin Furter <mf...@rola.ch>.

On 17 Aug 2003 cmpilato@collab.net wrote:

> Ben Collins-Sussman <su...@collab.net> writes:
> 
> > Garrett Rooney <ro...@electricjellyfish.net> writes:
> > 
> > > Ben Collins-Sussman wrote:
> > > 
> > > > Garrett, keep in mind that 'svn import' *already* detects binary files
> > > > and sets svn:mime-type to application/x-octet-stream while
> > > > committing.  That's why it sometimes prints "A  (bin)  foo.doc".
> > > 
> > > Yes, but setting svn:mime-type for binary files serves a more
> > > fundamental purpose (avoiding merges and eol translation on
> > > non-textual files), so it seems like a reasonable special case to me.
> > 
> > I guess my take is -- hey, if we add Martin's auto-propset feature,
> > it would definitely be "turned off" by default.
> > 
> > I'm thinking about all the users who have repeatedly complained that
> > they don't like having to remember to set svn:eol-style=native every
> > time they add a new source-code file.  Some people have suggested
> > "recursive" directory props as a solution (really hard to implement),
> > other have suggested a server-side configuration solution (also
> > possible, but it's a very large change).  Martin's patch seems pretty
> > simple, effective, and low-impact.
> 
> I hear it.  I totally dig the idea of the patch, and actually *want
> this* for myself in 'add' and 'import'.  Yes, definitely, the default
> is off (meaning, what, that there's nothing but commented-out stuffs
> written to new .subversion areas?), but I soooooo want to import a
> website have my JPEGs be image/jpeg, my PNGs image/png, my HTML
> text/html, and so on, without having to write a custom script or do
> the work by hand.
> 

Thank you all for your nice comments, and thank you Ben for the compliment :)

So here comes version 2 of my patch, but still not finished.
I've done some cleanup, added auto-props to import and added 2 enable
flags, one for svn add and one for svn import.
These flags are in ~/.subversion/config in the section miscellany, their
name is 'enable-auto-props-add' and 'enable-auto-props-imp', their value
can be 'true' or everything else.

Still missing is the testing of this feature and commandline switches for
the flags.

I thought i could add 2 commandline switches, --auto-props and
--no-auto-props, so enabling and disabling is both possible, and when they
are found on the cmdline the value of the config is overwritten with
svn_config_set().
This way i don't need to change any API or struct. Is that OK ?

Re: automatic properties

Posted by cm...@collab.net.
Ben Collins-Sussman <su...@collab.net> writes:

> Garrett Rooney <ro...@electricjellyfish.net> writes:
> 
> > Ben Collins-Sussman wrote:
> > 
> > > Garrett, keep in mind that 'svn import' *already* detects binary files
> > > and sets svn:mime-type to application/x-octet-stream while
> > > committing.  That's why it sometimes prints "A  (bin)  foo.doc".
> > 
> > Yes, but setting svn:mime-type for binary files serves a more
> > fundamental purpose (avoiding merges and eol translation on
> > non-textual files), so it seems like a reasonable special case to me.
> 
> I guess my take is -- hey, if we add Martin's auto-propset feature,
> it would definitely be "turned off" by default.
> 
> I'm thinking about all the users who have repeatedly complained that
> they don't like having to remember to set svn:eol-style=native every
> time they add a new source-code file.  Some people have suggested
> "recursive" directory props as a solution (really hard to implement),
> other have suggested a server-side configuration solution (also
> possible, but it's a very large change).  Martin's patch seems pretty
> simple, effective, and low-impact.

I hear it.  I totally dig the idea of the patch, and actually *want
this* for myself in 'add' and 'import'.  Yes, definitely, the default
is off (meaning, what, that there's nothing but commented-out stuffs
written to new .subversion areas?), but I soooooo want to import a
website have my JPEGs be image/jpeg, my PNGs image/png, my HTML
text/html, and so on, without having to write a custom script or do
the work by hand.


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

Re: automatic properties

Posted by Ben Collins-Sussman <su...@collab.net>.
Garrett Rooney <ro...@electricjellyfish.net> writes:

> Ben Collins-Sussman wrote:
> 
> > Garrett, keep in mind that 'svn import' *already* detects binary files
> > and sets svn:mime-type to application/x-octet-stream while
> > committing.  That's why it sometimes prints "A  (bin)  foo.doc".
> 
> Yes, but setting svn:mime-type for binary files serves a more
> fundamental purpose (avoiding merges and eol translation on
> non-textual files), so it seems like a reasonable special case to me.

I guess my take is -- hey, if we add Martin's auto-propset feature,
it would definitely be "turned off" by default.

I'm thinking about all the users who have repeatedly complained that
they don't like having to remember to set svn:eol-style=native every
time they add a new source-code file.  Some people have suggested
"recursive" directory props as a solution (really hard to implement),
other have suggested a server-side configuration solution (also
possible, but it's a very large change).  Martin's patch seems pretty
simple, effective, and low-impact.



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

Re: automatic properties

Posted by Garrett Rooney <ro...@electricjellyfish.net>.
Ben Collins-Sussman wrote:

> Garrett, keep in mind that 'svn import' *already* detects binary files
> and sets svn:mime-type to application/x-octet-stream while
> committing.  That's why it sometimes prints "A  (bin)  foo.doc".

Yes, but setting svn:mime-type for binary files serves a more 
fundamental purpose (avoiding merges and eol translation on non-textual 
files), so it seems like a reasonable special case to me.

-garrett


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

Re: automatic properties

Posted by Ben Collins-Sussman <su...@collab.net>.
Garrett Rooney <ro...@electricjellyfish.net> writes:

> cmpilato@collab.net wrote:
> 
> > Martin Furter <mf...@rola.ch> writes:
> >
> >>Hello
> >>
> >>I made a little patch which adds a new feature: automatic adding of
> >>properties when adding files.
> >>Attached is a patch for subversion/libsvn_client/add.c
> > Is this something you'd want to happen for 'svn import' as well?
> > Just
> > a thought...
> 
> I'd say no, or at least provide a way to turn it off, as import
> commits things directly to the repository, with no opportunity to
> tweak the results.  With add, you can always change the properties
> before you run the commit in case your defaults are not appropriate
> for this particular file/directory.

Garrett, keep in mind that 'svn import' *already* detects binary files
and sets svn:mime-type to application/x-octet-stream while
committing.  That's why it sometimes prints "A  (bin)  foo.doc".

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

Re: automatic properties

Posted by Garrett Rooney <ro...@electricjellyfish.net>.
cmpilato@collab.net wrote:

> Martin Furter <mf...@rola.ch> writes:
> 
> 
>>Hello
>>
>>I made a little patch which adds a new feature: automatic adding of
>>properties when adding files.
>>Attached is a patch for subversion/libsvn_client/add.c
> 
> 
> Is this something you'd want to happen for 'svn import' as well?  Just
> a thought...

I'd say no, or at least provide a way to turn it off, as import commits 
things directly to the repository, with no opportunity to tweak the 
results.  With add, you can always change the properties before you run 
the commit in case your defaults are not appropriate for this particular 
file/directory.

-garrett


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

Re: automatic properties

Posted by cm...@collab.net.
Martin Furter <mf...@rola.ch> writes:

> Hello
> 
> I made a little patch which adds a new feature: automatic adding of
> properties when adding files.
> Attached is a patch for subversion/libsvn_client/add.c

Is this something you'd want to happen for 'svn import' as well?  Just
a thought...

Also, have you learned about using 'svn diff' yet? :-)

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

Re: automatic properties

Posted by Blair Zajac <bl...@orcaware.com>.
Martin Furter wrote:
> 
> Hello
> 
> I made a little patch which adds a new feature: automatic adding of
> properties when adding files.
> Attached is a patch for subversion/libsvn_client/add.c
> 
> After adding the patch you can define a new section in
> ~/.subversion/config and add entries describing the properties.
> 
> There are 3 types of entries: exact matches, suffix matches and the
> default.
> Exact matches have the highest priority, the default match the lowest. The
> longer a suffix match is the higher it's priority.
> 
> Here is an example config:
> 
> [auto-props]
> * = svn:executable
> *.txt = svn:eol-style=native
> *.old.txt =
> *.sh = svn:eol-style=LF;svn:executable
> README.old.txt = svn:eol-style=CRLF
> Makefile = svn:eol-style=LF
> 
> The format of the properties is name=value;name=value;...
> For boolean properties only the name is specified.
> 
> I think this simple feature is enough for 99% of the use cases, making it
> more complex would also make the config more complex and less human
> readable.
> 
> Probably some cleanup of the code is needed, and extensive testing, so if
> you like the patch just ask me.

The svn_load_dirs.pl script already does something like this with it's
-p command line option.  It would be good if the method in add and possibly
import were consistent with svn_load_dirs.pl or both were changed.

See tools/client-side/svn_load_dirs.README and
svn_load_dirs_property_table.example.

Best,
Blair

-- 
Blair Zajac <bl...@orcaware.com>
Plots of your system's performance - http://www.orcaware.com/orca/

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