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

[PATCH] Infrastructure changes for incomplete directory support.

From: Karl Fogel <kfogel_at_google.com>
Date: 2006-08-09 01:10:18 CEST

I haven't committed a code change to Subversion in a while, so posting
a patch here first. It's pretty self-explanatory. Remember that I'm
going for infrastructure first, as per this mail:

   http://subversion.tigris.org/servlets/ReadMsg?list=dev&msgNo=118329
   From: Karl Fogel <kfogel@google.com>
   To: "David James" <djames@collab.net>
   Cc: "dev@subversion.tigris.org" <dev@subversion.tigris.org>,
       "Ben Reser" <ben@reser.org>, "Eric Gillespie" <epg@pretzelnet.org>
   Subject: Re: [PROPOSAL] Managing large working copies using viewspecs
   Date: Mon, 31 Jul 2006 15:49:07 -0700
   References: <df2177af0607160110vb242ed5id858bdac3b4fa34@mail.gmail.com>
   Message-ID: <janslkho0f0.fsf@morbius.corp.google.com>

Also, would people prefer that this work happen on a branch?

Note that this change extends .svn/entries format with a new depth
field. As the log message says, you can turn the change on and off
and your working copies should be fine. The only way a problem could
arise is if you were to build with this patch, use the new svn, then
revert, rebuild with some *other* patch that extends .svn/entries with
a semantically different field, and then use that svn on the same
working copies.

-Karl

[[[
Start on incomplete directory support. This is related to issue #695.

Add a new 'svn_depth_t' type, and a corresponding 'depth' field in
.svn/entries. This extends the entry format by one field. Note that
if this change were undone, the field would be ignored on read and
simply omitted the next time .svn/entries is written out.

* subversion/include/svn_types.h
  (svn_depth_t): New enum.
  (svn_wc_status_kind): Move some documentation over to svn_depth_t's
  doc string, and leave a forwarding pointer here.

* subversion/libsvn_wc/README
  (The entries file): Describe the new 'depth' field.

* subversion/include/svn_wc.h
  (svn_wc_entry_t): Add depth field. Update notes to remind extenders
  about alloc_entry() as well as svn_wc_entry_dup().

* subversion/libsvn_wc/entries.c
  (alloc_entry): Initialize depth to infinity.
  (read_entry): Read depth.
  (write_entry): Write depth.
]]]

Index: subversion/include/svn_types.h
===================================================================
--- subversion/include/svn_types.h (revision 21026)
+++ subversion/include/svn_types.h (working copy)
@@ -199,6 +199,18 @@
   svn_recursive
 };
 
+/** The WebDAV concept of "depth".
+ * @since New in 1.5.
+ */
+typedef enum
+{
+ svn_depth_exclude = -1, /* Exclude (remove, whatever) directory D. */
+ svn_depth_zero = 0, /* Just the named directory D, no entries. */
+ svn_depth_one = 1, /* D + immediate children (D and its entries) */
+ svn_depth_infinity = 2, /* D + all descendants (full recursion from D) */
+} svn_depth_t;
+
+
 /**
  * It is sometimes convenient to indicate which parts of an @c svn_dirent_t
  * object you are actually interested in, so that calculating and sending
Index: subversion/include/svn_wc.h
===================================================================
--- subversion/include/svn_wc.h (revision 21026)
+++ subversion/include/svn_wc.h (working copy)
@@ -1187,8 +1187,9 @@
  */
 typedef struct svn_wc_entry_t
 {
- /* IMPORTANT: If you extend this structure, check svn_wc_entry_dup() to see
- if you need to extend that as well. */
+ /* IMPORTANT: If you extend this structure, check svn_wc_entry_dup()
+ and alloc_entry() in libsvn_wc/entries.c, to see if you need to
+ extend one or both of them as well. */
 
   /* General Attributes */
 
@@ -1323,8 +1324,20 @@
    */
   const char *changelist;
 
- /* IMPORTANT: If you extend this structure, check svn_wc_entry_dup() to see
- if you need to extend that as well. */
+ /** The depth of this entry.
+ *
+ * ### It's a bit annoying that we only use this on this_dir
+ * ### entries, yet it will exist (with value svn_depth_infinity) on
+ * ### all entries. Maybe some future extensibility would make this
+ * ### field meaningful on entries besides this_dir.
+ *
+ * @since New in 1.5.
+ */
+ svn_depth_t depth;
+
+ /* IMPORTANT: If you extend this structure, check svn_wc_entry_dup()
+ and alloc_entry() in libsvn_wc/entries.c, to see if you need to
+ extend one or both of them as well. */
 } svn_wc_entry_t;
 
 
@@ -1573,14 +1586,10 @@
  * for getting the status of exactly one thing, and another for
  * getting the statuses of (potentially) multiple things.
  *
- * The WebDAV concept of "depth" may be useful in understanding the
- * motivation behind this. Suppose we're getting the status of
- * directory D. The three depth levels would mean
- *
- * depth 0: D itself (just the named directory)
- * depth 1: D and its immediate children (D + its entries)
- * depth Infinity: D and all its descendants (full recursion)
- *
+ * The WebDAV concept of depth, as explained in the documentation for
+ * svn_depth_t, may be useful in understanding this. Suppose we're
+ * getting the status of directory D:
+ *
  * To offer all three levels, we could have one unified function,
  * taking a `depth' parameter. Unfortunately, because this function
  * would have to handle multiple return values as well as the single
Index: subversion/libsvn_wc/entries.c
===================================================================
--- subversion/libsvn_wc/entries.c (revision 21026)
+++ subversion/libsvn_wc/entries.c (working copy)
@@ -63,6 +63,7 @@
   entry->copyfrom_rev = SVN_INVALID_REVNUM;
   entry->cmt_rev = SVN_INVALID_REVNUM;
   entry->kind = svn_node_none;
+ entry->depth = svn_depth_infinity;
   return entry;
 }
 
@@ -449,7 +450,21 @@
 
   /* Changelist. */
   SVN_ERR(read_str(&entry->changelist, buf, end, pool));
+ MAYBE_DONE;
 
+ /* Depth. */
+ {
+ const char *result;
+ SVN_ERR(read_val(&result, buf, end));
+ if (result[0] == '0' && result[1] == '\0')
+ entry->depth = svn_depth_zero;
+ if (result[0] == '1' && result[1] == '\0')
+ entry->depth = svn_depth_one;
+ else
+ /* svn_depth_exclude "can't happen" here, so assume infinity. */
+ entry->depth = svn_depth_infinity;
+ }
+
  done:
   *new_entry = entry;
   return SVN_NO_ERROR;
@@ -1548,6 +1563,24 @@
   /* Changelist. */
   write_str(buf, entry->changelist, pool);
 
+ /* Depth. */
+ {
+ const char *val;
+ switch (entry->depth)
+ {
+ case svn_depth_zero:
+ val = "0";
+ break;
+ case svn_depth_one:
+ val = "1";
+ default:
+ /* Else assume 2 (svn_depth_infinity), which we represent as "",
+ which write_val() will emit if handed NULL. */
+ val = NULL;
+ }
+ write_val(buf, val, 1);
+ }
+
   /* Remove redundant separators at the end of the entry. */
   while (buf->len > 1 && buf->data[buf->len - 2] == '\n')
     buf->len--;
Index: subversion/libsvn_wc/README
===================================================================
--- subversion/libsvn_wc/README (revision 21026)
+++ subversion/libsvn_wc/README (working copy)
@@ -478,6 +478,15 @@
 changelist:
    Which changelist this entry is part of, or empty if none.
 
+depth:
+ The entry depth of this directory. `0' means updates will not pull
+ in any files or subdirectories not already present. `1' means
+ updates will pull in any files or subdirectories not already
+ present, and those subdirectories' this_dir entries will have depth
+ `0'. `' means infinite (normal) depth -- the directory has all its
+ entries and pulls new entries with depth infinity as well.
+ Default is infinite (`').
+
 The only fields allowed in an entry for a directory (other than the
 this_dir entry) are name, absent, deleted, schedule, copied,
 copyfrom-url, copyfrom-rev and kind. The other fields are only stored

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Wed Aug 9 01:11:02 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.