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

Factor out tests for WC entry present locally.

From: Julian Foad <julianfoad_at_btopenworld.com>
Date: 2005-11-27 01:59:56 CET

How's this patch? Are the name and description of the function good?

Should any of the other dozen or so tests of "->absent" and/or "->deleted" in
the WC library be using this function? There are a few that look suspicious,
but I'm not sure what they are trying to do exactly.

In subversion/libsvn_wc/adm_crawler.c (report_revisions):237:

       /* If the entry is 'deleted' or 'absent', make sure the server
          knows it's gone... */
       if (current_entry->deleted || current_entry->absent)
         {
           /* ...unless we're reporting everything, in which case it's already
              missing on the server. */
           if (! report_everything)
             SVN_ERR (reporter->delete_path (report_baton, this_path, iterpool));
           continue;
         }

In subversion/libsvn_wc/adm_ops.c (tweak_entries):113:

       /* If a file, or deleted or absent dir in recursive mode, then tweak the
          entry but don't recurse. */
       if ((current_entry->kind == svn_node_file)
           || (recurse && (current_entry->deleted || current_entry->absent)))
         {
           SVN_ERR (svn_wc__tweak_entry (entries, name, ...
         }

In subversion/libsvn_wc/adm_ops.c (svn_wc__do_update_cleanup):228:

   if (entry->kind == svn_node_file
       || (entry->kind == svn_node_dir && (entry->deleted || entry->absent)))
     {
       ...do stuff...
     }

- Julian

Factor out tests for whether a WC entry is present locally.

The main reason for doing this is because the exact test to use is rather
obscure, as the redundant condition in some of the tests being replaced
shows. (A "deleted" or "absent" item can never have schedule "replace".)

* subversion/libsvn_wc/entries.h
* subversion/libsvn_wc/entries.c
  (svn_wc__entry_present_locally): New function.

* subversion/libsvn_wc/entries.c (handle_start_tag):
* subversion/libsvn_wc/lock.c (prune_deleted):
* subversion/libsvn_wc/relocate.c (svn_wc_relocate2):
  Use it.

Index: subversion/libsvn_wc/relocate.c
===================================================================
--- subversion/libsvn_wc/relocate.c (revision 17457)
+++ subversion/libsvn_wc/relocate.c (working copy)
@@ -159,8 +159,7 @@
         continue;
 
       if (recurse && (entry->kind == svn_node_dir)
- && (! entry->deleted || (entry->schedule == svn_wc_schedule_add))
- && ! entry->absent)
+ && svn_wc__entry_present_locally (entry))
         {
           svn_wc_adm_access_t *subdir_access;
           const char *subdir = svn_path_join (path, key, pool);
Index: subversion/libsvn_wc/entries.c
===================================================================
--- subversion/libsvn_wc/entries.c (revision 17457)
+++ subversion/libsvn_wc/entries.c (working copy)
@@ -533,15 +533,8 @@
         
   /* Find the name and set up the entry under that name. This
      should *NOT* be NULL, since svn_wc__atts_to_entry() should
- have made it into SVN_WC_ENTRY_THIS_DIR. (Note that technically,
- an entry can't be both absent and scheduled for addition, but we
- don't need a sanity check for that here.) */
- if ((entry->deleted || entry->absent)
- && (entry->schedule != svn_wc_schedule_add)
- && (entry->schedule != svn_wc_schedule_replace)
- && (! accum->show_hidden))
- ;
- else
+ have made it into SVN_WC_ENTRY_THIS_DIR. */
+ if (svn_wc__entry_present_locally (entry) || accum->show_hidden)
     apr_hash_set (accum->entries, entry->name, APR_HASH_KEY_STRING, entry);
 }
 
@@ -2029,3 +2022,11 @@
                                 "path is marked 'missing'"),
                               svn_path_local_style (path, pool));
 }
+
+
+svn_boolean_t
+svn_wc__entry_present_locally (const svn_wc_entry_t *entry)
+{
+ return (! entry->deleted && ! entry->absent)
+ || (entry->schedule == svn_wc_schedule_add);
+}
Index: subversion/libsvn_wc/entries.h
===================================================================
--- subversion/libsvn_wc/entries.h (revision 17457)
+++ subversion/libsvn_wc/entries.h (working copy)
@@ -211,6 +211,12 @@
                      apr_pool_t *pool);
 
 
+/* Return true iff @a entry indicates an item that is present in the WC
+ * (as opposed to being "absent" or "deleted" and not recreated). */
+svn_boolean_t
+svn_wc__entry_present_locally (const svn_wc_entry_t *entry);
+
+
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */
Index: subversion/libsvn_wc/lock.c
===================================================================
--- subversion/libsvn_wc/lock.c (revision 17457)
+++ subversion/libsvn_wc/lock.c (working copy)
@@ -28,6 +28,7 @@
 #include "adm_files.h"
 #include "lock.h"
 #include "questions.h"
+#include "entries.h"
 
 #include "svn_private_config.h"
 
@@ -1250,10 +1251,7 @@
           const svn_wc_entry_t *entry;
           apr_hash_this (hi, NULL, NULL, &val);
           entry = val;
- if ((entry->deleted
- && (entry->schedule != svn_wc_schedule_add)
- && (entry->schedule != svn_wc_schedule_replace))
- || entry->absent)
+ if (! svn_wc__entry_present_locally (entry))
             break;
         }
 
@@ -1276,9 +1274,7 @@
 
           apr_hash_this (hi, &key, NULL, &val);
           entry = val;
- if (((entry->deleted == FALSE) && (entry->absent == FALSE))
- || (entry->schedule == svn_wc_schedule_add)
- || (entry->schedule == svn_wc_schedule_replace))
+ if (svn_wc__entry_present_locally (entry))
             {
               apr_hash_set (adm_access->entries, key,
                             APR_HASH_KEY_STRING, entry);

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Sun Nov 27 02:00:45 2005

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.