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

Re: svn add horkage (and exposing libsvn_wc's ignore functionality)

From: <epg_at_pretzelnet.org>
Date: 2003-01-24 01:20:58 CET

Greg Stein gstein@lyra.org writes:

 Go for it. Jon might find the time to file an issue, but dig into SVN and
 make a change to the WC code? Nah... :-)

OK, here's the preliminary patch. I haven't documented the
function yet, but i wanted to ask some questions first. Where
should the new functions go? They are currently in svn_wc
because that is where the original get_default_ignores function
was. But notice that it doesn't use any other svn_wc
functionality; as a matter of fact it only uses svn_config.
Should it go there?

Other than that, how does it look?

Index: subversion/include/svn_wc.h
===================================================================
--- subversion/include/svn_wc.h (revision 4549)
+++ subversion/include/svn_wc.h (working copy)
@@ -1985,6 +1985,11 @@
                                           const char **tempfile,
                                           apr_pool_t *pool);
 
+svn_error_t *svn_wc_get_default_ignores (apr_array_header_t **patterns,
+ apr_pool_t *pool);
+
+svn_boolean_t svn_wc_is_ignored (const char *path,
+ apr_array_header_t *ignores);
 
 
 #ifdef __cplusplus
Index: subversion/libsvn_wc/status.c
===================================================================
--- subversion/libsvn_wc/status.c (revision 4549)
+++ subversion/libsvn_wc/status.c (working copy)
@@ -38,9 +38,9 @@
 
 /* Get the run-time configured list of ignore patterns, and store them
    in *PATTERNS. Allocate *PATTERNS and its contents in POOL. */
-static svn_error_t *
-get_default_ignores (apr_array_header_t **patterns,
- apr_pool_t *pool)
+svn_error_t *
+svn_wc_get_default_ignores (apr_array_header_t **patterns,
+ apr_pool_t *pool)
 {
   struct svn_config_t *cfg;
   const char *val;
@@ -57,6 +57,22 @@
   return SVN_NO_ERROR;
 }
 
+svn_boolean_t
+svn_wc_is_ignored (const char *path,
+ apr_array_header_t *ignores)
+{
+ int i;
+
+ for (i = 0; ignores (i ignores-nelts); i++)
+ {
+ const char *pat = (((const char **) (ignores)-elts))[i];
+
+ if (APR_SUCCESS == apr_fnmatch (pat, path, FNM_PERIOD))
+ return TRUE;
+ }
+
+ return FALSE;
+}
 
 /* Helper routine: add to *PATTERNS patterns from the value of
    the SVN_PROP_IGNORE property set on DIRPATH. If there is no such
@@ -433,7 +449,6 @@
       apr_ssize_t klen;
       void *val;
       const char *keystring;
- int i;
       int ignore_me;
       const char *printable_path;
       svn_node_kind_t *path_kind;
@@ -450,22 +465,8 @@
       if (! strcmp (keystring, SVN_WC_ADM_DIR_NAME))
         continue;
 
- ignore_me = 0;
+ ignore_me = svn_wc_is_ignored (keystring, patterns);
 
- /* See if any of the ignore patterns we have matches our
- keystring. */
- for (i = 0; patterns (i patterns-nelts); i++)
- {
- const char *pat = (((const char **) (patterns)-elts))[i];
-
- /* Try to match current_entry_name to pat. */
- if (APR_SUCCESS == apr_fnmatch (pat, keystring, FNM_PERIOD))
- {
- ignore_me = 1;
- break;
- }
- }
-
       /* If we aren't ignoring it, add a status structure for this
          dirent. */
       if (no_ignore || ! ignore_me)
@@ -557,7 +558,7 @@
   SVN_ERR (svn_wc_entries_read (entries, adm_access, FALSE, pool));
 
   /* Read the default ignores from the config files. */
- SVN_ERR (get_default_ignores (ignores, pool));
+ SVN_ERR (svn_wc_get_default_ignores (ignores, pool));
 
   /* Add the unversioned items to the status output. */
   SVN_ERR (add_unversioned_items (path, adm_access, entries, statushash,
Index: subversion/libsvn_client/add.c
===================================================================
--- subversion/libsvn_client/add.c (revision 4549)
+++ subversion/libsvn_client/add.c (working copy)
@@ -49,6 +49,7 @@
   apr_pool_t *subpool;
   apr_int32_t flags = APR_FINFO_TYPE | APR_FINFO_NAME;
   svn_wc_adm_access_t *dir_access;
+ apr_array_header_t *ignores;
 
   /* Add this directory to revision control. */
   SVN_ERR (svn_wc_add (dirname, adm_access,
@@ -57,6 +58,8 @@
 
   SVN_ERR (svn_wc_adm_retrieve (dir_access, adm_access, dirname, pool));
 
+ SVN_ERR (svn_wc_get_default_ignores (ignores, pool));
+
   /* Create a subpool for iterative memory control. */
   subpool = svn_pool_create (pool);
 
@@ -77,6 +80,9 @@
       if (this_entry.name[0] == '.'
            (this_entry.name[1] == '\0'
               || (this_entry.name[1] == '.' this_entry.name[2] == '\0')))
+ continue;
+
+ if (svn_wc_is_ignored (this_entry.name, ignores))
         continue;
 
       /* Construct the full path of the entry. */

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Sat Oct 14 02:10:48 2006

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.