Author: rhuijben
Date: Fri May 13 09:09:20 2011
New Revision: 1102618

URL: http://svn.apache.org/viewvc?rev=1102618&view=rev
Log:
Update the status handling of externals to be a bit more like after we move
file externals to their own storage.

I think svn needs further tweaks on how it should report file externals, but
this makes their status reports with the experimental format 29 and the
current output equivalent.

* subversion/include/private/svn_client_private.h
  (svn_client__create_status): New function.

* subversion/include/private/svn_wc_private.h
  (svn_wc__external_status): New function.

* subversion/libsvn_client/delete.c
  (find_undeletables): Handle all externals as unversioned as seen from their
    parent working copy.

* subversion/libsvn_client/status.c
  (includes): Add svn_client_private.h
  (create_client_status): Remove prototype.
  (tweak_status): Update caller.
  (create_client_status): Rename to ...
  (svn_client__create_status): ... this. And tweak file externals to be like
    the new situation.

* subversion/libsvn_wc/externals.c
  (svn_wc__external_status): New function.

* subversion/svn/status-cmd.c
  (includes): Add svn_client_private.h
  (print_status): Tweak the status for externals.

* subversion/svn/status.c
  (combined_status): Don't show file externals as externals.

* subversion/tests/cmdline/externals_tests.py
  (cannot_move_or_remove_file_externals): Expect an unversioned file error
    on deleting directories containing file externals.

Modified:
    subversion/trunk/subversion/include/private/svn_client_private.h
    subversion/trunk/subversion/include/private/svn_wc_private.h
    subversion/trunk/subversion/libsvn_client/delete.c
    subversion/trunk/subversion/libsvn_client/status.c
    subversion/trunk/subversion/libsvn_wc/externals.c
    subversion/trunk/subversion/svn/status-cmd.c
    subversion/trunk/subversion/svn/status.c
    subversion/trunk/subversion/tests/cmdline/externals_tests.py

Modified: subversion/trunk/subversion/include/private/svn_client_private.h
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/include/private/svn_client_private.h?rev=1102618&r1=1102617&r2=1102618&view=diff
==============================================================================
--- subversion/trunk/subversion/include/private/svn_client_private.h (original)
+++ subversion/trunk/subversion/include/private/svn_client_private.h Fri May 13 
09:09:20 2011
@@ -45,6 +45,20 @@ extern "C" {
 svn_error_t *
 svn_client__assert_homogeneous_target_type(const apr_array_header_t *targets);
 
+
+/* Create a svn_client_status_t structure *CST for LOCAL_ABSPATH, shallow
+ * copying data from *STATUS wherever possible and retrieving the other values
+ * where needed. Peform temporary allocations in SCRATCH_POOL and allocate the
+ * result in RESULT_POOL
+ */
+svn_error_t *
+svn_client__create_status(svn_client_status_t **cst,
+                          svn_wc_context_t *wc_ctx,
+                          const char *local_abspath,
+                          const svn_wc_status3_t *status,
+                          apr_pool_t *result_pool,
+                          apr_pool_t *scratch_pool);
+
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */

Modified: subversion/trunk/subversion/include/private/svn_wc_private.h
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/include/private/svn_wc_private.h?rev=1102618&r1=1102617&r2=1102618&view=diff
==============================================================================
--- subversion/trunk/subversion/include/private/svn_wc_private.h (original)
+++ subversion/trunk/subversion/include/private/svn_wc_private.h Fri May 13 
09:09:20 2011
@@ -123,6 +123,18 @@ svn_wc__read_external_info(svn_node_kind
                            apr_pool_t *result_pool,
                            apr_pool_t *scratch_pool);
 
+/* Fill a svn_wc_status3_t * structure with information about the external,
+   like how it would be shown if file externals were still part of the parent
+   working copy. */
+svn_error_t *
+svn_wc__external_status(const svn_wc_status3_t **status,
+                        svn_node_kind_t *external_kind,
+                        svn_wc_context_t *wc_ctx,
+                        const char *wri_abspath,
+                        const char *local_abspath,
+                        apr_pool_t *result_pool,
+                        apr_pool_t *scratch_pool);
+
 
 /** Set @a *tree_conflict to a newly allocated @c
  * svn_wc_conflict_description_t structure describing the tree

Modified: subversion/trunk/subversion/libsvn_client/delete.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/delete.c?rev=1102618&r1=1102617&r2=1102618&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/delete.c (original)
+++ subversion/trunk/subversion/libsvn_client/delete.c Fri May 13 09:09:20 2011
@@ -60,7 +60,8 @@ find_undeletables(void *baton,
                              _("'%s' is in the way of the resource "
                                "actually under version control"),
                              svn_dirent_local_style(path, pool));
-  else if (! status->versioned)
+  else if (! status->versioned 
+           || status->node_status == svn_wc_status_external)
     return svn_error_createf(SVN_ERR_UNVERSIONED_RESOURCE, NULL,
                              _("'%s' is not under version control"),
                              svn_dirent_local_style(path, pool));

Modified: subversion/trunk/subversion/libsvn_client/status.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/status.c?rev=1102618&r1=1102617&r2=1102618&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/status.c (original)
+++ subversion/trunk/subversion/libsvn_client/status.c Fri May 13 09:09:20 2011
@@ -41,6 +41,7 @@
 
 #include "svn_private_config.h"
 #include "private/svn_wc_private.h"
+#include "private/svn_client_private.h"
 
 
 /*** Getting update information ***/
@@ -60,15 +61,6 @@ struct status_baton
   svn_wc_context_t *wc_ctx;                   /* A working copy context. */
 };
 
-/* Create svn_client_status_t from svn_wc_satus3_t */
-static svn_error_t *
-create_client_status(svn_client_status_t **cst,
-                     svn_wc_context_t *wc_ctx,
-                     const char *local_abspath,
-                     const svn_wc_status3_t *status,
-                     apr_pool_t *result_pool,
-                     apr_pool_t *scratch_pool);
-
 /* A status callback function which wraps the *real* status
    function/baton.   This sucker takes care of any status tweaks we
    need to make (such as noting that the target of the status is
@@ -101,8 +93,8 @@ tweak_status(void *baton,
       return SVN_NO_ERROR;
     }
 
-  SVN_ERR(create_client_status(&cst, sb->wc_ctx, local_abspath, status,
-                               scratch_pool, scratch_pool));
+  SVN_ERR(svn_client__create_status(&cst, sb->wc_ctx, local_abspath, status,
+                                    scratch_pool, scratch_pool));
 
   /* If we know that the target was deleted in HEAD of the repository,
      we need to note that fact in all the status structures that come
@@ -586,18 +578,13 @@ svn_client_status_dup(const svn_client_s
   return st;
 }
 
-/* Create a svn_client_status_t structure *CST for LOCAL_ABSPATH, shallow
- * copying data from *STATUS wherever possible and retrieving the other values
- * where needed. Peform temporary allocations in SCRATCH_POOL and allocate the
- * result in RESULT_POOL
- */
-static svn_error_t *
-create_client_status(svn_client_status_t **cst,
-                     svn_wc_context_t *wc_ctx,
-                     const char *local_abspath,
-                     const svn_wc_status3_t *status,
-                     apr_pool_t *result_pool,
-                     apr_pool_t *scratch_pool)
+svn_error_t *
+svn_client__create_status(svn_client_status_t **cst,
+                          svn_wc_context_t *wc_ctx,
+                          const char *local_abspath,
+                          const svn_wc_status3_t *status,
+                          apr_pool_t *result_pool,
+                          apr_pool_t *scratch_pool)
 {
   *cst = apr_pcalloc(result_pool, sizeof(**cst));
 
@@ -630,11 +617,10 @@ create_client_status(svn_client_status_t
   (*cst)->switched = status->switched;
   (*cst)->file_external = FALSE;
 
-  if (((*cst)->node_status == svn_wc_status_external)
-      /* Old style file-externals */
-      || (status->versioned
-          && status->switched
-          && status->kind == svn_node_file))
+  if (/* Old style file-externals */
+      (status->versioned
+       && status->switched
+       && status->kind == svn_node_file))
     {
       svn_node_kind_t external_kind;
 
@@ -646,9 +632,14 @@ create_client_status(svn_client_status_t
 
       if (external_kind == svn_node_file)
         {
+          /* Make it similar to the new status */
           (*cst)->file_external = TRUE;
           (*cst)->switched = FALSE;
-          (*cst)->node_status = (*cst)->text_status;
+          (*cst)->node_status = svn_wc_status_external;
+          (*cst)->versioned = FALSE;
+          (*cst)->kind = svn_node_unknown;
+          (*cst)->text_status = svn_wc_status_none;
+          (*cst)->prop_status = svn_wc_status_none;
         }
     }
 

Modified: subversion/trunk/subversion/libsvn_wc/externals.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/externals.c?rev=1102618&r1=1102617&r2=1102618&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/externals.c (original)
+++ subversion/trunk/subversion/libsvn_wc/externals.c Fri May 13 09:09:20 2011
@@ -1166,4 +1166,72 @@ svn_wc__read_external_info(svn_node_kind
                                                 result_pool);
 
   return SVN_NO_ERROR;
+}
+
+svn_error_t *
+svn_wc__external_status(const svn_wc_status3_t **stat,
+                        svn_node_kind_t *external_kind,
+                        svn_wc_context_t *wc_ctx,
+                        const char *wri_abspath,
+                        const char *local_abspath,
+                        apr_pool_t *result_pool,
+                        apr_pool_t *scratch_pool)
+{
+  svn_wc_status3_t *st = apr_pcalloc(result_pool, sizeof(*st));
+  svn_wc__db_status_t status;
+  svn_wc__db_kind_t kind;
+  svn_wc__db_lock_t *lock;
+  svn_filesize_t recorded_size;
+  apr_time_t recorded_mod_time;
+  svn_boolean_t had_props, props_mod;
+  svn_boolean_t conflicted;
+
+  SVN_ERR(svn_wc__db_external_read(&status, &kind, &st->revision,
+                                   &st->repos_relpath, &st->repos_root_url,
+                                   NULL, &st->changed_rev, &st->changed_date,
+                                   &st->changed_author, NULL, NULL, &lock,
+                                   &recorded_size, &recorded_mod_time,
+                                   NULL, NULL, NULL, NULL, &conflicted,
+                                   &had_props, &props_mod,
+                                   wc_ctx->db, local_abspath, wri_abspath,
+                                   result_pool, scratch_pool));
+
+  if (status == svn_wc__db_status_excluded)
+    {
+      SVN_ERR_MALFUNCTION(); /* Not supported yet */
+    }
+  else if (kind == svn_wc__db_kind_file
+      || kind == svn_wc__db_kind_symlink)
+    {
+      SVN_DBG(("Revision of %s is %d\n", local_abspath, st->revision));
+      st->versioned = TRUE;
+      st->kind = svn_node_file;
+      st->node_status = svn_wc_status_external;
+      st->text_status = svn_wc_status_normal;
+    
+      if (props_mod)
+        st->prop_status = svn_wc_status_modified;
+      else if (had_props)
+        st->prop_status = svn_wc_status_normal;
+      else
+        st->prop_status = svn_wc_status_none;
+
+      if (external_kind)
+        *external_kind = svn_node_file;
+    }
+  else
+    {
+      SVN_ERR_ASSERT(kind == svn_wc__db_kind_dir);
+      st->kind = svn_node_dir;
+      st->node_status = svn_wc_status_external;
+
+      st->text_status = svn_wc_status_none;
+      st->prop_status = svn_wc_status_none;
+
+      if (external_kind)
+        *external_kind = svn_node_dir;
+    }
+
+  *stat = st;
+  return SVN_NO_ERROR;
 }
\ No newline at end of file

Modified: subversion/trunk/subversion/svn/status-cmd.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/svn/status-cmd.c?rev=1102618&r1=1102617&r2=1102618&view=diff
==============================================================================
--- subversion/trunk/subversion/svn/status-cmd.c (original)
+++ subversion/trunk/subversion/svn/status-cmd.c Fri May 13 09:09:20 2011
@@ -41,7 +41,7 @@
 
 #include "svn_private_config.h"
 #include "private/svn_wc_private.h"
-
+#include "private/svn_client_private.h"
 
 
 /*** Code. ***/
@@ -222,6 +222,34 @@ print_status(void *baton,
 
       status = twks;
     }
+  else if (status->node_status == svn_wc_status_external)
+    {
+      const svn_wc_status3_t *wc_status;
+      svn_client_status_t *twks;
+      svn_node_kind_t kind;
+      svn_error_t *err;
+
+      err = svn_wc__external_status(&wc_status, &kind, sb->ctx->wc_ctx,
+                                    local_abspath, local_abspath,
+                                    sb->cl_pool, pool);
+
+      if (err)
+        {
+          if (err->apr_err != SVN_ERR_WC_PATH_NOT_FOUND)
+            return svn_error_return(err);
+          svn_error_clear(err);
+        }
+      else
+        {
+          SVN_ERR(svn_client__create_status(&twks, sb->ctx->wc_ctx,
+                                            local_abspath, wc_status,
+                                            sb->cl_pool, pool));
+
+          twks->file_external = (kind == svn_node_file);
+
+          status = twks;
+        }
+    }
 
   /* If the path is part of a changelist, then we don't print
      the item, but instead dup & cache the status structure for later. */

Modified: subversion/trunk/subversion/svn/status.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/svn/status.c?rev=1102618&r1=1102617&r2=1102618&view=diff
==============================================================================
--- subversion/trunk/subversion/svn/status.c (original)
+++ subversion/trunk/subversion/svn/status.c Fri May 13 09:09:20 2011
@@ -73,6 +73,10 @@ combined_status(const svn_client_status_
         /* This value might be the property status */
         new_status = status->text_status;
         break;
+      case svn_wc_status_external:
+        if (status->file_external)
+          new_status = status->text_status;
+        break;
       default:
         break;
     }

Modified: subversion/trunk/subversion/tests/cmdline/externals_tests.py
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/externals_tests.py?rev=1102618&r1=1102617&r2=1102618&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/externals_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/externals_tests.py Fri May 13 
09:09:20 2011
@@ -992,10 +992,16 @@ def cannot_move_or_remove_file_externals
   # But the directory that contains it can be deleted.
   expected_status = svntest.actions.get_virginal_state(wc_dir, 6)
 
-  svntest.actions.run_and_verify_svn(None, None, [],
+  svntest.actions.run_and_verify_svn(None, None,
+                                     ".*gamma' is not under version.*",
                                      'rm',
                                      os.path.join(wc_dir, "A", "B"))
 
+  # When you apply a bit of force
+  svntest.actions.run_and_verify_svn(None, None, [],
+                                     'rm', '--force',
+                                     os.path.join(wc_dir, "A", "B"))
+
   expected_status.tweak('A/B', status='D ')
   expected_output = svntest.wc.State(wc_dir, {
       'A/B' : Item(verb='Deleting'),


Reply via email to