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

[PATCH] Add svn_wc_status_obstructed

From: Sander Striker <striker_at_apache.org>
Date: 2002-08-05 19:28:48 CEST

Hi,

This patch adds a new status code to subversion: svn_wc_status_obstructed.
An entry gets this status when:

 a) the entry's kind is different from the filesystem
 b) the entry should be a versioned directory, but the directory
    doesn't appear to be so on the filesystem.

This scratches an itch for me when it comes to writing gui code.
svn_wc_statuses returns an error on case b), instead of continueing
and filling in the status codes for all the entries in the
working copy directory I'm inquiring about.

Thinking about it, the patch is incomplete, I'm not paying attention
the the STRICT argument.

Thoughts?

Sander

Index: ./subversion/include/svn_wc.h
===================================================================
--- ./subversion/include/svn_wc.h
+++ ./subversion/include/svn_wc.h 2002-08-05 09:38:14.000000000 +0200
@@ -545,7 +545,9 @@
     svn_wc_status_replaced, /* was deleted and then re-added */
     svn_wc_status_modified, /* text or props have been modified */
     svn_wc_status_merged, /* local mods received repos mods */
- svn_wc_status_conflicted /* local mods received conflicting repos mods */
+ svn_wc_status_conflicted, /* local mods received conflicting repos mods */
+ svn_wc_status_obstructed /* an unversioned resource is in the way of
+ the versioned resource */
 };
 
 /* Structure for holding the "status" of a working copy item.
Index: ./subversion/libsvn_wc/status.c
===================================================================
--- ./subversion/libsvn_wc/status.c
+++ ./subversion/libsvn_wc/status.c 2002-08-05 19:06:16.000000000 +0200
@@ -141,93 +141,124 @@
 
       *status = stat;
       return SVN_NO_ERROR;
- }
-
- /* Implement predecence rules: */
+ }
+
+ /* Someone either deleted the administrative directory in the versioned
+ subdir, or deleted the directory altogether and created a new one.
+ In any case, what is currently there is in the way.
+ */
+ if (entry->kind == svn_node_dir
+ && path_kind == svn_node_dir)
+ {
+ svn_boolean_t is_wc;
+
+ SVN_ERR (svn_wc_check_wc (path, &is_wc, pool));
+ if (! is_wc)
+ {
+ final_text_status = svn_wc_status_obstructed;
+ }
+ }
+ else
+ {
+ /* Implement predecence rules: */
 
- /* 1. Set the two main variables to "discovered" values first (M, C).
- Together, these two stati are of lowest precedence, and C has
- precedence over M. */
-
- /* Does the entry have props? */
- SVN_ERR (svn_wc__has_props (&has_props, path, pool));
- if (has_props)
- final_prop_status = svn_wc_status_normal;
+ /* 1. Set the two main variables to "discovered" values first (M, C).
+ Together, these two stati are of lowest precedence, and C has
+ precedence over M. */
+
+ /* Does the entry have props? */
+ SVN_ERR (svn_wc__has_props (&has_props, path, pool));
+ if (has_props)
+ final_prop_status = svn_wc_status_normal;
 
- /* If the entry has a property file, see if it has local changes. */
- SVN_ERR (svn_wc_props_modified_p (&prop_modified_p, path, pool));
+ /* If the entry has a property file, see if it has local changes. */
+ SVN_ERR (svn_wc_props_modified_p (&prop_modified_p, path, pool));
   
- /* If the entry is a file, check for textual modifications */
- if (entry->kind == svn_node_file)
- SVN_ERR (svn_wc_text_modified_p (&text_modified_p, path, pool));
+ /* If the entry is a file, check for textual modifications */
+ if (entry->kind == svn_node_file)
+ SVN_ERR (svn_wc_text_modified_p (&text_modified_p, path, pool));
   
- if (text_modified_p)
- final_text_status = svn_wc_status_modified;
+ if (text_modified_p)
+ final_text_status = svn_wc_status_modified;
   
- if (prop_modified_p)
- final_prop_status = svn_wc_status_modified;
+ if (prop_modified_p)
+ final_prop_status = svn_wc_status_modified;
   
- if (entry->prejfile || entry->conflict_old ||
- entry->conflict_new || entry->conflict_wrk)
- {
- svn_boolean_t text_conflict_p, prop_conflict_p;
- const char *parent_dir;
-
- if (entry->kind == svn_node_dir)
- parent_dir = path;
- else /* non-directory, that's all we need to know */
+ if (entry->prejfile || entry->conflict_old ||
+ entry->conflict_new || entry->conflict_wrk)
         {
- parent_dir = svn_path_remove_component_nts (path, pool);
- }
+ svn_boolean_t text_conflict_p, prop_conflict_p;
+ const char *parent_dir;
+
+ if (entry->kind == svn_node_dir)
+ parent_dir = path;
+ else /* non-directory, that's all we need to know */
+ {
+ parent_dir = svn_path_remove_component_nts (path, pool);
+ }
       
- SVN_ERR (svn_wc_conflicted_p (&text_conflict_p, &prop_conflict_p,
- parent_dir, entry, pool));
+ SVN_ERR (svn_wc_conflicted_p (&text_conflict_p, &prop_conflict_p,
+ parent_dir, entry, pool));
       
- if (text_conflict_p)
- final_text_status = svn_wc_status_conflicted;
- if (prop_conflict_p)
- final_prop_status = svn_wc_status_conflicted;
- }
+ if (text_conflict_p)
+ final_text_status = svn_wc_status_conflicted;
+ if (prop_conflict_p)
+ final_prop_status = svn_wc_status_conflicted;
+ }
    
- /* 2. Possibly overwrite the text_status variable with "scheduled"
- states from the entry (A, D, R). As a group, these states are
- of medium precedence. They also override any C or M that may
- be in the prop_status field at this point.*/
+ /* 2. Possibly overwrite the text_status variable with "scheduled"
+ states from the entry (A, D, R). As a group, these states are
+ of medium precedence. They also override any C or M that may
+ be in the prop_status field at this point.*/
 
- if (entry->schedule == svn_wc_schedule_add)
- {
- final_text_status = svn_wc_status_added;
- final_prop_status = svn_wc_status_none;
- }
+ if (entry->schedule == svn_wc_schedule_add)
+ {
+ final_text_status = svn_wc_status_added;
+ final_prop_status = svn_wc_status_none;
+ }
       
- else if (entry->schedule == svn_wc_schedule_replace)
- {
- final_text_status = svn_wc_status_replaced;
- final_prop_status = svn_wc_status_none;
- }
+ else if (entry->schedule == svn_wc_schedule_replace)
+ {
+ final_text_status = svn_wc_status_replaced;
+ final_prop_status = svn_wc_status_none;
+ }
     
- else if (entry->schedule == svn_wc_schedule_delete)
- {
- final_text_status = svn_wc_status_deleted;
- final_prop_status = svn_wc_status_none;
- }
-
+ else if (entry->schedule == svn_wc_schedule_delete)
+ {
+ final_text_status = svn_wc_status_deleted;
+ final_prop_status = svn_wc_status_none;
+ }
 
- /* 3. Highest precedence: check to see if file or dir is just
- missing. This overrides every possible state *except*
- deletion. (If something is deleted or scheduled for it, we
- don't care if the working file exists.) */
 
- if ((path_kind == svn_node_none)
- && (final_text_status != svn_wc_status_deleted))
- final_text_status = svn_wc_status_absent;
+ /* 3. Highest precedence:
+
+ a. check to see if file or dir is just missing. This
+ overrides every possible state *except* deletion.
+ (If something is deleted or scheduled for it, we
+ don't care if the working file exists.)
+
+ b. check to see if the file or dir is present in the
+ file system as the same kind it was versioned as.
+ */
 
+ if (path_kind == svn_node_none
+ && final_text_status != svn_wc_status_deleted)
+ {
+ final_text_status = svn_wc_status_absent;
+ }
+
+ if (path_kind != svn_node_none
+ && path_kind != entry->kind)
+ {
+ final_text_status = svn_wc_status_obstructed;
+ }
 
- /* 4. Check for locked directory. */
 
- if (entry->kind == svn_node_dir)
- SVN_ERR (svn_wc_locked (&locked_p, path, pool));
+ /* 4. Check for locked directory. */
 
+ if (entry->kind == svn_node_dir)
+ SVN_ERR (svn_wc_locked (&locked_p, path, pool));
+ }
 
   /* 5. Easy out: unless we're fetching -every- entry, don't bother
      to allocate a struct for an uninteresting entry. */
@@ -508,14 +540,38 @@
                 {
                   /* Directory entries are incomplete. We must get
                      their full entry from their own THIS_DIR entry.
- svn_wc_entry does this for us if it can. */
- svn_wc_entry_t *subdir;
+ svn_wc_entry does this for us if it can.
+
+ Don't error out if svn_wc_entry can't get the
+ entry for us because the path is not a (working
+ copy) directory. Instead pass the incomplete
+ entry to add_status_structure, since that contains
+ enough information to determine the actual state
+ of this entry. */
+
+ svn_wc_entry_t *subdir = NULL;
+ svn_error_t *svn_err;
+
+ svn_err = svn_wc_entry (&subdir, fullpath, FALSE, pool);
+ if (svn_err != NULL
+ && svn_err->apr_err == SVN_ERR_WC_NOT_DIRECTORY)
+ {
+ svn_error_clear_all(svn_err);
+ subdir = entry;
+ }
+ else
+ {
+ return svn_err;
+ }
 
- SVN_ERR (svn_wc_entry (&subdir, fullpath, FALSE, pool));
                   SVN_ERR (add_status_structure (statushash, fullpath,
                                                  subdir, get_all,
- strict, pool));
- if (descend)
+ strict, pool));
+
+ /* Descend only on request and if the subdirectory is
+ actually a versioned resource.
+ */
+ if (descend && subdir != entry)
                     {
                       SVN_ERR (svn_wc_statuses (statushash, fullpath, descend,
                                                 get_all, strict, no_ignore,
Index: ./subversion/clients/cmdline/status.c
===================================================================
--- ./subversion/clients/cmdline/status.c
+++ ./subversion/clients/cmdline/status.c 2002-08-05 19:05:49.000000000 +0200
@@ -55,7 +55,8 @@
     case svn_wc_status_added:
       text_statuschar = 'A';
       break;
     case svn_wc_status_absent:
+ case svn_wc_status_obstructed:
       text_statuschar = '!';
       break;
     case svn_wc_status_deleted:

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Mon Aug 5 19:19:35 2002

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.