Index: subversion/include/svn_config.h
===================================================================
--- subversion/include/svn_config.h	(revision 6732)
+++ subversion/include/svn_config.h	(working copy)
@@ -82,7 +82,10 @@
 #define SVN_CONFIG_OPTION_GLOBAL_IGNORES            "global-ignores"
 #define SVN_CONFIG_OPTION_LOG_ENCODING              "log-encoding"
 #define SVN_CONFIG_OPTION_TEMPLATE_ROOT             "template-root"
+#define SVN_CONFIG_OPTION_ENABLE_AUTO_PROPS_ADD     "enable-auto-props-add"
+#define SVN_CONFIG_OPTION_ENABLE_AUTO_PROPS_IMP     "enable-auto-props-imp"
 #define SVN_CONFIG_SECTION_TUNNELS              "tunnels"
+#define SVN_CONFIG_SECTION_AUTO_PROPS           "auto-props"
 
 
 /*** Configuration Default Values ***/
Index: subversion/libsvn_client/client.h
===================================================================
--- subversion/libsvn_client/client.h	(revision 6732)
+++ subversion/libsvn_client/client.h	(working copy)
@@ -233,6 +233,28 @@
 
 /*** Add/delete ***/
 
+/* 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);
+
 /* The main logic of the public svn_client_add;  the only difference
    is that this function uses an existing access baton.
    (svn_client_add just generates an access baton and calls this func.) */
Index: subversion/libsvn_client/commit.c
===================================================================
--- subversion/libsvn_client/commit.c	(revision 6732)
+++ subversion/libsvn_client/commit.c	(working copy)
@@ -105,8 +105,8 @@
              apr_pool_t *pool)
 {
   void *file_baton;
-  const char *mimetype;
-  svn_boolean_t executable;
+  const char *mimetype = NULL;
+  svn_boolean_t executable = FALSE;
   unsigned char digest[MD5_DIGESTSIZE];
   const char *text_checksum;
 
@@ -114,8 +114,29 @@
   SVN_ERR (editor->add_file (edit_path, dir_baton, NULL, SVN_INVALID_REVNUM, 
                              pool, &file_baton));
 
+  /* add automatic properties */
+  SVN_ERR (svn_client__add_auto_props (path, ctx, pool, NULL, editor,
+                                       file_baton, &mimetype, &executable));
+
   /* If the file has a discernable mimetype, add that as a property to
      the file. */
+  if (!mimetype)
+    SVN_ERR (svn_io_detect_mimetype (&mimetype, path, pool));
+  if (mimetype)
+    SVN_ERR (editor->change_file_prop (file_baton, SVN_PROP_MIME_TYPE,
+                                       svn_string_create (mimetype, pool), 
+                                       pool));
+
+  /* If the file is executable, add that as a property to the file. */
+  if (!executable)
+    SVN_ERR (svn_io_is_file_executable (&executable, path, pool));
+  if (executable)
+    SVN_ERR (editor->change_file_prop (file_baton, SVN_PROP_EXECUTABLE,
+                                       svn_string_create ("", pool), 
+                                       pool));
+#if 0
+  /* If the file has a discernable mimetype, add that as a property to
+     the file. */
   SVN_ERR (svn_io_detect_mimetype (&mimetype, path, pool));
   if (mimetype)
     SVN_ERR (editor->change_file_prop (file_baton, SVN_PROP_MIME_TYPE,
@@ -128,7 +149,8 @@
     SVN_ERR (editor->change_file_prop (file_baton, SVN_PROP_EXECUTABLE,
                                        svn_string_create ("", pool), 
                                        pool));
-  
+#endif
+
   if (ctx->notify_func)
     (*ctx->notify_func) (ctx->notify_baton,
                          path,
Index: subversion/libsvn_client/add.c
===================================================================
--- subversion/libsvn_client/add.c	(revision 6732)
+++ subversion/libsvn_client/add.c	(working copy)
@@ -30,12 +30,162 @@
 #include "svn_error.h"
 #include "svn_path.h"
 #include "svn_io.h"
+#include "svn_config.h"
 #include "client.h"
 
 
 
 /*** Code. ***/
 
+typedef struct {
+  char *filename;
+  int name_len;
+  char *props;
+  int match_len;
+  apr_pool_t *pool;
+} auto_props_baton_t;
+
+static svn_boolean_t
+auto_props_enumerator (const char *name,
+                       const char *value,
+                       void *baton)
+{
+  auto_props_baton_t *autoprops = (auto_props_baton_t*)baton;
+  int len;
+
+  if (!name)
+    return TRUE;
+  if (!baton)
+    return FALSE;
+  if (!value)
+    value = "";
+  if (!strcmp (name, "*") )
+    {
+      /* default properties */
+      if (autoprops->match_len == -1)
+        {
+          autoprops->props = apr_pstrdup(autoprops->pool, value);
+          autoprops->match_len = 0;
+        }
+      return TRUE;
+    }
+  if (name[0] == '*')
+    {
+      /* properties for a suffix */
+      len = strlen (name+1);
+      if (autoprops->match_len >= len)
+        return TRUE;
+      if (len > autoprops->name_len)
+        return TRUE;
+      if (!strcmp (name+1, autoprops->filename+autoprops->name_len-len))
+        {
+          autoprops->props = apr_pstrdup(autoprops->pool, value);
+          autoprops->match_len = len;
+        }
+      return TRUE;
+    }
+  if (!strcmp(name, autoprops->filename))
+    {
+      /* properties for an exact match */
+      autoprops->props = apr_pstrdup(autoprops->pool, value);
+      return FALSE;
+    }
+  return TRUE;
+}
+
+/* for a description look into client.h */
+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)
+{
+  svn_config_t *cfg = NULL;
+  auto_props_baton_t autoprops;
+  char *property;
+  char *last_token;
+  char *value;
+  const char *cfgvalue = 0;
+  svn_error_t *err;
+
+  /* check that we have config */
+  if (!ctx->config)
+    return SVN_NO_ERROR;
+  cfg = apr_hash_get (ctx->config, SVN_CONFIG_CATEGORY_CONFIG,
+                        APR_HASH_KEY_STRING);
+  if (!cfg)
+    return SVN_NO_ERROR;
+
+  /* check that auto props is enabled */
+  if (editor)
+    svn_config_get (cfg, &cfgvalue, SVN_CONFIG_SECTION_MISCELLANY,
+                    SVN_CONFIG_OPTION_ENABLE_AUTO_PROPS_IMP, "false");
+  else
+    svn_config_get (cfg, &cfgvalue, SVN_CONFIG_SECTION_MISCELLANY,
+                    SVN_CONFIG_OPTION_ENABLE_AUTO_PROPS_ADD, "false");
+  if (!cfgvalue || strcmp(cfgvalue, "true"))
+    return SVN_NO_ERROR;
+
+  /* search for auto props */
+  autoprops.filename = svn_path_basename (path, pool);
+  autoprops.name_len = strlen (autoprops.filename);
+  autoprops.props = NULL;
+  autoprops.match_len = -1;
+  autoprops.pool = pool;
+  svn_config_enumerate (cfg, SVN_CONFIG_SECTION_AUTO_PROPS,
+                        auto_props_enumerator, &autoprops);
+
+  /* did we find auto props ? */
+  if (!autoprops.props)
+    return SVN_NO_ERROR;
+  if (strlen (autoprops.props) == 0)
+    return SVN_NO_ERROR;
+
+  /* add properties */
+  last_token = NULL;
+  property = apr_strtok (autoprops.props, ";", &last_token);
+  while (property)
+    {
+      svn_string_t valstr;
+      value = strchr (property, '=');
+      if (value)
+        {
+          *value = 0;
+          value++;
+          apr_collapse_spaces (value, value);
+        }
+      else
+        value = "";
+      apr_collapse_spaces (property, property);
+      valstr.data = value;
+      valstr.len = strlen (value);
+      if (strlen (property))
+        {
+          if (editor)
+            {
+              /* SVN_PROP_MIME_TYPE and SVN_PROP_EXECUTABLE
+               * are returned to the caller */
+              if (!strcmp(property, SVN_PROP_MIME_TYPE))
+                *mimetype = apr_pstrdup (pool, value);
+              else if (!strcmp (property, SVN_PROP_EXECUTABLE))
+                *executable = TRUE;
+              else
+                err = editor->change_file_prop (file_baton, property,
+                                       &valstr, pool);
+            }
+          else
+            err = svn_wc_prop_set (property, &valstr, path, adm_access, pool);
+        }
+      if (err)
+        return err;
+      property = apr_strtok (NULL, ";", &last_token);
+    }
+}
+
 static svn_error_t *
 add_dir_recursive (const char *dirname,
                    svn_wc_adm_access_t *adm_access,
@@ -97,9 +247,13 @@
         SVN_ERR (add_dir_recursive (fullpath, dir_access, ctx, subpool));
 
       else if (this_entry.filetype == APR_REG)
-        SVN_ERR (svn_wc_add (fullpath, dir_access, NULL, SVN_INVALID_REVNUM,
-                             ctx->cancel_func, ctx->cancel_baton,
-                             ctx->notify_func, ctx->notify_baton, subpool));
+        {
+          SVN_ERR (svn_wc_add (fullpath, dir_access, NULL, SVN_INVALID_REVNUM,
+                               ctx->cancel_func, ctx->cancel_baton,
+                               ctx->notify_func, ctx->notify_baton, subpool));
+          SVN_ERR (svn_client__add_auto_props (fullpath, ctx, subpool,
+                                      adm_access, NULL, NULL, NULL, NULL));
+        }
 
       /* Clean out the per-iteration pool. */
       svn_pool_clear (subpool);
@@ -145,9 +299,14 @@
   if ((kind == svn_node_dir) && recursive)
     err = add_dir_recursive (path, adm_access, ctx, pool);
   else
-    err = svn_wc_add (path, adm_access, NULL, SVN_INVALID_REVNUM,
-                      ctx->cancel_func, ctx->cancel_baton,
-                      ctx->notify_func, ctx->notify_baton, pool);
+    {
+      err = svn_wc_add (path, adm_access, NULL, SVN_INVALID_REVNUM,
+                        ctx->cancel_func, ctx->cancel_baton,
+                        ctx->notify_func, ctx->notify_baton, pool);
+      if (!err)
+        err = svn_client__add_auto_props (path, ctx, pool, adm_access,
+                                          NULL, NULL, NULL, NULL);
+    }
 
   return err;
 }
