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

Re: svn_wc_statuses

From: Karl Fogel <kfogel_at_galois.collab.net>
Date: 2001-01-08 16:38:34 CET

Bill Tutt <billtut@microsoft.com> writes:
> While writing the necessary code to do some per file state reporting in the
> UI, svn_wc_statuses looked like the perfect function, except just for one
> tiny little problem: It recurses into nested directories. Now since normally
> the UI only handles one directory at a time, this seems like a tiny bit of
> overkill. I suppose I could just a tiny little flag bit argument, but I've
> never been particular happy with arbitrary bitflags like that.
> Thoughts?

Actually, I think adding a recurse flag is probably best. Here's why:

Ben pointed out that WebDAV has a useful "levels" concept. Say we're
taking status of a directory:

   Level 0 means the thing itself, just the named directory
   Level 1 means the thing and its immediate children (this dir + its entries)
   Level 2 means the thing and all its descendants (full recursion)

One defensible solution would be to have one unified function, taking
a `level' parameter. Unfortunately, because this function would have
to handle multiple return values as well as a single return value,
getting the status of just one entity would become cumbersome: you'd
have to roll through a hash to find the lone returned status.

So we have one function for level 0:

   /* Fill *STATUS for PATH, allocating in POOL, with the exception of
      the repos_rev field, which is normally filled in by the caller. */
   svn_error_t *svn_wc_status (svn_wc_status_t **status,
                               svn_string_t *path,
                               apr_pool_t *pool);
And another function for levels 1 and 2, since those levels both
involve multiple return values:

   /* Under PATH, fill STATUSHASH to map paths to svn_wc_status_t
      structures. For each struct, all fields will be filled in except
      for repos_rev; this would presumably be filled in by the caller. */
   svn_error_t *svn_wc_statuses (apr_hash_t *statushash,
                                 svn_string_t *path,
                                 apr_pool_t *pool);

However, svn_wc_statuses() only does level 2 right now -- I forgot to
offer any way to just get level 1. "Due to bad planning, the hundred
twenty-two thousand miles of string are in three inch lengths." :-)

Since there are only 2 levels to distinguish between here, a boolean
flag seems fine. I'll change it to this:

   /* Under DIR, fill STATUSHASH mapping paths to svn_wc_status_t
    * structures. DIR must be a directory, otherwise you want to use
    * svn_wc_status().
    * If DESCEND is zero, statushash will contain paths for DIR and
    * its non-directory entries (subdirectories should be subjects of
    * separate status calls).
    * If DESCEND is non-zero, statushash will contain statuses for DIR
    * and everything below it, including subdirectories. In other
    * words, a full recursion.
    * For each struct, all fields will be filled in except for
    * repos_rev, which would presumably be filled in by the caller.
   svn_error_t *svn_wc_statuses (apr_hash_t *statushash,
                                 svn_string_t *dir,
                                 svn_boolean_t descend,
                                 apr_pool_t *pool);

Received on Sat Oct 21 14:36:19 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.