You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Brian Denny <br...@briandenny.net> on 2003/06/09 02:25:41 UTC

[PATCH] Followup to Issue #1075 / r5814

This patch tries to address some of the concerns expressed by Philip and 
Mike about r5814.  (It does *not* address all of Philip's concerns,
because Mike shot down my last try at a server-side solution and I just
don't want to go there again, at least not without some consensus.)

So at this point I'm basically looking for: Am i doing anything stupid, or 
is this patch a reasonable improvement on r5814?

(I personally feel concerned about the number of different places in
libsvn_wc that I had to write very similar code to acheive what I
needed, both here and in r5814.  Is this a reflection on my solution, or
a reflection on the state of libsvn_wc?)

-brian


Log:
Followup to r5814 (Issue #1075 - update receiving delete for missing
directory).  Make sure to clean up missing directories any time we bump
a revision number (really, when we remove the 'incomplete' flag).  
Also, don't delete schedule-add entries.

* libsvn_wc/log.c
  (log_do_delete_entry): Don't delete schedule-add entries.

* libsvn_wc/adm_ops.c
  (recursively_tweak_entries): Don't delete schedule-add entries.

* libsvn_wc/update_editor.c
  (maybe_bump_dir_info): For each directory that we actually bump,
    remove any entries for missing or 'deleted' children.  (But don't 
    delete schedule-add entries).



Index: subversion/libsvn_wc/log.c
===================================================================
--- subversion/libsvn_wc/log.c	(revision 6165)
+++ subversion/libsvn_wc/log.c	(working copy)
@@ -536,14 +536,18 @@
     {
       if (svn_wc__adm_missing (adm_access, full_path))
         {
-          /* The directory is already missing, so don't try to recurse --
-             just delete the entry in the parent directory. */
-          apr_hash_t *entries;
-          SVN_ERR (svn_wc_entries_read (&entries, loggy->adm_access, TRUE,
-                                        loggy->pool));
-          svn_wc__entry_remove (entries, name);
-          SVN_ERR (svn_wc__entries_write (entries, loggy->adm_access, 
-                                          loggy->pool));
+          /* The directory is already missing, so don't try to recurse. */
+          if (entry->schedule != svn_wc_schedule_add)
+            {
+              /* Delete the parent directory's entry. */
+              apr_hash_t *entries;
+              SVN_ERR (svn_wc_entries_read (&entries, loggy->adm_access, TRUE,
+                                            loggy->pool));
+              svn_wc__entry_remove (entries, name);
+              SVN_ERR (svn_wc__entries_write (entries, loggy->adm_access, 
+                                              loggy->pool));
+            }
+          /* Else, leave schedule-add entry untouched. */
         }
       else 
         {
Index: subversion/libsvn_wc/adm_ops.c
===================================================================
--- subversion/libsvn_wc/adm_ops.c	(revision 6165)
+++ subversion/libsvn_wc/adm_ops.c	(working copy)
@@ -117,14 +117,18 @@
           if (remove_missing_dirs 
               && svn_wc__adm_missing (dirpath, child_path))
             {
-              svn_wc__entry_remove (entries, name);
-              if (notify_func)
-                (* notify_func) (notify_baton, child_path, 
-                                 svn_wc_notify_delete,
-                                 current_entry->kind, NULL, 
-                                 svn_wc_notify_state_unknown,
-                                 svn_wc_notify_state_unknown,
-                                 SVN_INVALID_REVNUM);
+              if (current_entry->schedule != svn_wc_schedule_add)
+                {
+                  svn_wc__entry_remove (entries, name);
+                  if (notify_func)
+                    (* notify_func) (notify_baton, child_path, 
+                                     svn_wc_notify_delete,
+                                     current_entry->kind, NULL, 
+                                     svn_wc_notify_state_unknown,
+                                     svn_wc_notify_state_unknown,
+                                     SVN_INVALID_REVNUM);
+                }
+              /* Else if missing item is schedule-add, do nothing. */
             }
 
           /* Not missing or deleted, so recurse. */
Index: subversion/libsvn_wc/update_editor.c
===================================================================
--- subversion/libsvn_wc/update_editor.c	(revision 6165)
+++ subversion/libsvn_wc/update_editor.c	(working copy)
@@ -297,6 +297,9 @@
     {
       svn_wc_entry_t tmp_entry;
       svn_wc_adm_access_t *adm_access;
+      apr_hash_t *entries, *dirents;
+      apr_hash_index_t *hi;
+      apr_pool_t *subpool = svn_pool_create (pool);
 
       if (--bdi->ref_count > 0)
         return SVN_NO_ERROR;    /* directory isn't done yet */
@@ -309,6 +312,53 @@
                                      &tmp_entry,
                                      SVN_WC__ENTRY_MODIFY_INCOMPLETE,
                                      TRUE /* immediate write */,  pool));
+
+      /* Clean up deleted/missing directories. */
+      SVN_ERR (svn_wc_adm_retrieve (&adm_access, eb->adm_access, bdi->path,
+                                    pool));
+      SVN_ERR (svn_wc_entries_read (&entries, adm_access, TRUE, pool));
+      SVN_ERR (svn_io_get_dirents (&dirents, bdi->path, pool));
+      for (hi = apr_hash_first (pool, entries); hi; hi = apr_hash_next (hi))
+        {
+          svn_pool_clear (subpool);
+          const void *key;
+          apr_ssize_t klen;
+          void *val;
+          const svn_wc_entry_t *current_entry;
+
+          /* Get the next entry */
+          apr_hash_this (hi, &key, &klen, &val);
+          current_entry = val;
+
+          /* Skip THIS_DIR. */
+          if (! strcmp (key, SVN_WC_ENTRY_THIS_DIR))
+            continue;
+
+          /* If the item is a 'deleted' or missing dir, remove it
+           * (unless it is schedule-add). */
+          if (current_entry->kind == svn_node_dir
+              && (current_entry->deleted
+                  || (! apr_hash_get (dirents, key, klen)))
+              && (current_entry->schedule != svn_wc_schedule_add))
+            {
+              svn_wc__entry_remove (entries, current_entry->name);
+              if (eb->notify_func)
+                (*eb->notify_func) (eb->notify_baton,
+                                    svn_path_join (bdi->path,
+                                                   current_entry->name,
+                                                   subpool),
+                                    svn_wc_notify_update_delete,
+                                    svn_node_dir, NULL,
+                                    svn_wc_notify_state_unknown,
+                                    svn_wc_notify_state_unknown,
+                                    SVN_INVALID_REVNUM);
+           }
+
+        } /* end entries loop */
+
+      svn_pool_destroy (subpool);
+
+      SVN_ERR (svn_wc__entries_write (entries, adm_access, pool));
     }
   /* we exited the for loop because there are no more parents */
 

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: [PATCH] Followup to Issue #1075 / r5814

Posted by cm...@collab.net.
Brian Denny <br...@briandenny.net> writes:

> (I personally feel concerned about the number of different places in
> libsvn_wc that I had to write very similar code to acheive what I
> needed, both here and in r5814.  Is this a reflection on my solution, or
> a reflection on the state of libsvn_wc?)

Without examining your patch, let me assure you that it is quite
likely that the state of libsvn_wc is such that it would cause you
this kind of repetitive pain.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org