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

Re: [PATCH] automatic properties

From: Martin Furter <mf_at_rola.ch>
Date: 2003-09-30 03:30:21 CEST

On Tue, 30 Sep 2003, Julian Foad wrote:

> Martin Furter wrote:
> >
> > On Mon, 29 Sep 2003, Julian Foad wrote:
> >>I am wondering about the relationship between these new configurable
> >>auto-properties and the existing non-configurable automatic properties
> >>"svn:executable" and "svn:mimetype". The exising non-configurable
> >>auto-props seem to be applied only on commit, and not on add. It would
> >>be silly for the two types of auto-props not to work in the same
> >>situations. Is there a good reason why they don't?
> >
> > If i understood it correctly the current behaviour is the following when
> > importing:
> > 1. check if the file contains a '\0', if yes set the property
> > svn:mime-type to application/octet-stream
> > 2. check if the file has the executable bit set, if yes add the
> > property svn:executable
> >
> > These properties are applied in subversion/libsvn_wc/adm_ops.c in
> > import_file() and subversion/libsvn_client/commit.c in svn_wc_add().
>
> (The other way round - in adm_ops.c n svn_wc_add and commit.c in import_file.)
>
> > When adding a file svn_wc_add() sets these properties and
> > svn_client__add_auto_props() overwrites them.
> > When importing svn_client__add_auto_props() adds the properties and
> > import_file() adds the dfault if they aren't allready set.
> > So both commands have the same result.
>
> Ah, yes. I missed that. I am glad that I was wrong. I was misled
> because there is no call to "svn_io_detect_mimetype" in
> subversion/libsvn_client/add.c. The call is at a lower level, in
> svn_wc_add.
>
> The implementations of "svn_io_detect_mimetype" and
> "svn_io_is_file_executable" are in libsvn_wc because they ar WC-only
> operations. It seems to me that your new property-configuration
> function is very similar: it is also a WC-only operation, and so belongs
> with its two friends in libsvn_wc. I would make it like this:
>
> /* Return a hash of configured AND detected properties together */
> svn_wc_get_auto_props(...)
> {
> /* Look up auto-props in the config file (the first half of
> your svn_client__add_auto_props). */
>
> /* Detect mime-type and executable if they were not configured. */
>
> /* Return all of these properties in a hash table. */
> }
>
> and then the two existing callers of
> "svn_io_is_file_executable"/"svn_io_detect_mime_type" would call the
> single new function instead of those two old functions:
>
> import_file(...)
> {
> ...
> properties = svn_wc_get_auto_props(...);
> for (hi in properties)
> SVN_ERR (editor->change_file_prop (file_baton, hi->name, hi->value, pool));
> ...
> }
>
> svn_wc_add(...)
> {
> ...
> if (! copyfrom_url)
> {
> properties = svn_wc_get_auto_props(...);
> for (hi in properties)
> SVN_ERR (svn_wc_prop_set (hi->name, hi->value, path, parent_access, pool));
> }
> ...
> }
>
> This way, the logic of reading the configured properties and detecting
> two properties and having the former override the latter is all in one
> place, and there is only one call to each of editor->change_file_prop
> and svn_wc_prop_set rather than three of each.

Yeah, sounds really great but...
I don't have the config in svn_wc_add().
Now i remember why i added it to libsvn_client/add.c ;-)

To get it working this way i'd have to add ctx->config to the parameters
of svn_wc_add().
svn_wc_add is called from libsvn_client/add.c, libsvn_client/copy.c,
libsvn_client/diff.c (merge) and subversion/libsvn_wc/copy.c, totally 8
places in the source.
I think i have to check first that all these calls either have access to
ctx or always have copyfrom_url not null.

Here are the statements that need config:

  cfg = apr_hash_get (ctx->config, SVN_CONFIG_CATEGORY_CONFIG,
                        APR_HASH_KEY_STRING);
  svn_config_get (cfg, &cfgvalue, SVN_CONFIG_SECTION_MISCELLANY,
                  SVN_CONFIG_OPTION_ENABLE_AUTO_PROPS_ADD, "false");
  svn_config_enumerate (cfg, SVN_CONFIG_SECTION_AUTO_PROPS,
                        auto_props_enumerator, &autoprops);

The only function in libsvn_wc using svn_config_get is
svn_wc_get_default_ignores() at the moment, but this means that there is
no problem with linking of the libs.

This change sounds really heavy. Are there other options or shall i just
do that ?

Martin

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Tue Sep 30 03:32:16 2003

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

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