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

Re: [PATCH] Re: .svnignore functionality

From: Mark Benedetto King <bking_at_answerfriend.com>
Date: 2001-10-18 23:01:42 CEST

On Thu, Oct 18, 2001 at 03:24:22PM -0500, Ben Collins-Sussman wrote:
> Mark Benedetto King <bking@answerfriend.com> writes:
>
> > Okay, here's a second try.
>
> This looks great. Smaller too. :-)

Amazing what using the correct level of abstraction will do.

>
>
> > + if (list != NULL)
> > + {
> > + char *walk = list->data;
> > + do {
> > + char *p = strchr (walk, '\n');
>
> Maybe we should be more flexible here. Can we allow the patterns to
> be separated by any amount of whitespace?
>
> Personally, I'd like to see this someday:
>
> % svn proplist dir/
> svn:ignore : *.so *.o *~
>
> ...rather than see a bunch of newline-separated patterns.

Oh, sure. Of course, that will make patterns-with-spaces tricky,
but people who put spaces in file names deserve what they get.

Index: ./subversion/include/svn_types.h
===================================================================
--- ./subversion/include/.svn/text-base/svn_types.h Wed Oct 17 11:34:49 2001
+++ ./subversion/include/svn_types.h Thu Oct 18 16:03:41 2001
@@ -86,6 +86,8 @@
 /* All Subversion property names start with this. */
 #define SVN_PROP_PREFIX "svn:"
 
+/* This directory property stores a list of filename patterns to ignore */
+#define SVN_PROP_IGNORE SVN_PROP_PREFIX "ignore"
 
 /* The fs revision property that stores a commit's author. */
 #define SVN_PROP_REVISION_AUTHOR SVN_PROP_PREFIX "author"
Index: ./subversion/libsvn_wc/wc.h
===================================================================
--- ./subversion/libsvn_wc/.svn/text-base/wc.h Thu Oct 18 16:59:40 2001
+++ ./subversion/libsvn_wc/wc.h Thu Oct 18 16:59:40 2001
@@ -53,9 +53,6 @@
 #define SVN_WC_TIMESTAMP_WC "working"
 
 
-/* The name of the '.svnignore' file */
-#define SVN_WC_SVNIGNORE ".svnignore"
-
 
 
 /*** Locking. ***/
Index: ./subversion/libsvn_wc/adm_crawler.c
===================================================================
--- ./subversion/libsvn_wc/.svn/text-base/adm_crawler.c Thu Oct 18 16:59:41 2001
+++ ./subversion/libsvn_wc/adm_crawler.c Thu Oct 18 16:59:41 2001
@@ -54,47 +54,31 @@
 
 }
 
-/* Helper routine: try to read the contents of DIRPATH/.svnignore. If
- no such file exists, then set *PATTERNS to NULL. Otherwise, set
- *PATTERNS to a list of patterns to match; *PATTERNS will contain
- an array of (const char *) objects. */
+/* Helper routine: read the newline separated records
+ in the dir-props hash-entry for "svn:ignore" into *PATTERNS
+ as (const char *) objects. */
+
 static svn_error_t *
-load_ignore_file (const char *dirpath,
+load_ignore_property (const char *dirpath,
                   apr_array_header_t *patterns,
                   apr_pool_t *pool)
 {
- apr_file_t *fp;
- apr_status_t status;
- char buf[100];
- apr_size_t sz = 100;
-
- /* Try to load the .svnignore file. */
+ static const char * const whitespace = " \t\r\n";
+ svn_stringbuf_t *prop = svn_stringbuf_create (SVN_PROP_IGNORE, pool);
   svn_stringbuf_t *path = svn_stringbuf_create (dirpath, pool);
- svn_path_add_component_nts (path, SVN_WC_SVNIGNORE, svn_path_local_style);
- if (apr_file_open (&fp, path->data, APR_READ | APR_BUFFERED,
- APR_OS_DEFAULT, pool))
- {
- return SVN_NO_ERROR;
- }
-
- /* Now that it's open, read one line at a time into the array. */
- while (1)
- {
- status = svn_io_read_length_line (fp, buf, &sz);
- if (status == APR_EOF)
- break;
- else if (status)
- return svn_error_createf(status, 0, NULL, pool,
- "error reading %s", path->data);
-
- (*((const char **) apr_array_push (patterns))) =
- apr_pstrndup (pool, buf, sz);
-
- sz = 100;
- }
-
+ svn_stringbuf_t *list;
+ SVN_ERR(svn_wc_prop_get (&list, prop, path, pool));
+ if (list != NULL)
+ {
+ char *state;
+ char *token = apr_strtok (list->data, whitespace, &state);
+ do {
+ *(const char **)apr_array_push(patterns) = apr_pstrdup (pool, token);
+ token = apr_strtok(NULL, whitespace, &state);
+ } while (token);
+ }
   return SVN_NO_ERROR;
-}
+}
 
 
 
@@ -1508,9 +1492,9 @@
   SVN_ERR (svn_wc_entries_read (&entries, full_path, subpool));
   SVN_ERR (svn_io_get_dirents (&dirents, full_path, subpool));
 
- /* Try to load any '.svnignore' file that may be present. */
+ /* Try to load any 'svn:ignore' property that may be present. */
   patterns = apr_array_make (pool, 1, sizeof(const char *));
- SVN_ERR (load_ignore_file (full_path->data, patterns, subpool));
+ SVN_ERR (load_ignore_property (full_path->data, patterns, subpool));
   add_default_ignores (patterns);
 
   /* Phase 1: Print out every unrecognized (unversioned) object. */

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Sat Oct 21 14:36:45 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.