You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by pb...@apache.org on 2012/08/31 21:17:48 UTC

svn commit: r1379553 - in /subversion/branches/inheritable-props/subversion: include/private/ libsvn_client/ libsvn_wc/ tests/cmdline/ tests/libsvn_wc/

Author: pburba
Date: Fri Aug 31 19:17:47 2012
New Revision: 1379553

URL: http://svn.apache.org/viewvc?rev=1379553&view=rev
Log:
On the inheritable-props branch: Implement iprop caching for file externals.c

* subversion/include/private/svn_wc_private.h

  (svn_wc__get_file_external_editor): Add a new argument for the file's
   iprops.

* subversion/libsvn_client/externals.c

  (switch_file_external): Get the switched files iprops and pass them
   to svn_wc__get_file_external_editor, which stashes them in the new
   baton member.

* subversion/libsvn_wc/externals.c

  (edit_baton): New member tracking iprops.

  (close_file): Pass the new baton member to svn_wc__db_external_add_file
   so it can cache the iprops.

  (close_edit): If close_file hasn't beat us to it, pass the new baton
   member to (converted to a hash) to
   svn_wc__db_op_bump_revisions_post_update so it can cache the iprops.

  (svn_wc__get_file_external_editor): Populate the new baton member.

* subversion/libsvn_wc/wc_db.c

  (insert_external_baton_t): New member tracking iprops.

  (insert_external_node): Populate new baton member.

  (svn_wc__db_external_add_file): New argument tracking iprops.

* subversion/libsvn_wc/wc_db.h

  (svn_wc__db_external_add_file): New argument tracking iprops.

* subversion/tests/cmdline/iprop_tests.py

  (iprops_with_file_externals): Remove XFail decorator and expand test
   coverage.

* subversion/tests/libsvn_wc/db-test.c

  (test_externals_store): Upate call to svn_wc__db_external_add_file.

Modified:
    subversion/branches/inheritable-props/subversion/include/private/svn_wc_private.h
    subversion/branches/inheritable-props/subversion/libsvn_client/externals.c
    subversion/branches/inheritable-props/subversion/libsvn_wc/externals.c
    subversion/branches/inheritable-props/subversion/libsvn_wc/wc-queries.sql
    subversion/branches/inheritable-props/subversion/libsvn_wc/wc_db.c
    subversion/branches/inheritable-props/subversion/libsvn_wc/wc_db.h
    subversion/branches/inheritable-props/subversion/tests/cmdline/iprop_tests.py
    subversion/branches/inheritable-props/subversion/tests/libsvn_wc/db-test.c

Modified: subversion/branches/inheritable-props/subversion/include/private/svn_wc_private.h
URL: http://svn.apache.org/viewvc/subversion/branches/inheritable-props/subversion/include/private/svn_wc_private.h?rev=1379553&r1=1379552&r2=1379553&view=diff
==============================================================================
--- subversion/branches/inheritable-props/subversion/include/private/svn_wc_private.h (original)
+++ subversion/branches/inheritable-props/subversion/include/private/svn_wc_private.h Fri Aug 31 19:17:47 2012
@@ -55,7 +55,14 @@ svn_wc__changelist_match(svn_wc_context_
                          apr_pool_t *scratch_pool);
 
 /* Like svn_wc_get_update_editorX and svn_wc_get_status_editorX, but only
-   allows updating a file external LOCAL_ABSPATH */
+   allows updating a file external LOCAL_ABSPATH.
+
+   Since this only deals with files, the WCROOT_IPROPS argument in
+   svn_wc_get_update_editorX and svn_wc_get_status_editorX (hashes mapping
+   const char * absolute working copy paths, which are working copy roots, to
+   depth-first ordered arrays of svn_prop_inherited_item_t * structures) is
+   simply IPROPS here, a depth-first ordered arrays of
+   svn_prop_inherited_item_t * structs. */
 svn_error_t *
 svn_wc__get_file_external_editor(const svn_delta_editor_t **editor,
                                  void **edit_baton,
@@ -66,6 +73,7 @@ svn_wc__get_file_external_editor(const s
                                  const char *url,
                                  const char *repos_root_url,
                                  const char *repos_uuid,
+                                 apr_array_header_t *iprops,
                                  svn_boolean_t use_commit_times,
                                  const char *diff3_cmd,
                                  const apr_array_header_t *preserved_exts,

Modified: subversion/branches/inheritable-props/subversion/libsvn_client/externals.c
URL: http://svn.apache.org/viewvc/subversion/branches/inheritable-props/subversion/libsvn_client/externals.c?rev=1379553&r1=1379552&r2=1379553&view=diff
==============================================================================
--- subversion/branches/inheritable-props/subversion/libsvn_client/externals.c (original)
+++ subversion/branches/inheritable-props/subversion/libsvn_client/externals.c Fri Aug 31 19:17:47 2012
@@ -475,12 +475,16 @@ switch_file_external(const char *local_a
        ### We can't enable this now, because that would move the external
        ### information into the wrong working copy */
     const char *definition_abspath = svn_dirent_dirname(local_abspath,subpool);
+    apr_array_header_t *inherited_props;
 
     /* Open an RA session to 'source' URL */
     SVN_ERR(svn_client__ra_session_from_path2(&ra_session, &switch_loc,
                                               url, dir_abspath,
                                               peg_revision, revision,
                                               ctx, subpool));
+    /* Get the external file's iprops. */
+    SVN_ERR(svn_ra_get_inherited_props(ra_session, &inherited_props, "",
+                                       switch_loc->rev, subpool, subpool));
 
     SVN_ERR(svn_ra_reparent(ra_session, svn_uri_dirname(url, subpool),
                             subpool));
@@ -492,6 +496,7 @@ switch_file_external(const char *local_a
                                              switch_loc->url,
                                              switch_loc->repos_root_url,
                                              switch_loc->repos_uuid,
+                                             inherited_props,
                                              use_commit_times,
                                              diff3_cmd, preserved_exts,
                                              definition_abspath /* def */,

Modified: subversion/branches/inheritable-props/subversion/libsvn_wc/externals.c
URL: http://svn.apache.org/viewvc/subversion/branches/inheritable-props/subversion/libsvn_wc/externals.c?rev=1379553&r1=1379552&r2=1379553&view=diff
==============================================================================
--- subversion/branches/inheritable-props/subversion/libsvn_wc/externals.c (original)
+++ subversion/branches/inheritable-props/subversion/libsvn_wc/externals.c Fri Aug 31 19:17:47 2012
@@ -381,6 +381,10 @@ struct edit_baton
   /* List of incoming propchanges */
   apr_array_header_t *propchanges;
 
+  /* Array of svn_prop_inherited_item_t * structures representing the
+     properties inherited by the base node at LOCAL_ABSPATH. */
+  apr_array_header_t *iprops;
+
   /* The last change information */
   svn_revnum_t changed_rev;
   apr_time_t changed_date;
@@ -810,6 +814,7 @@ close_file(void *file_baton,
                         eb->repos_uuid,
                         *eb->target_revision,
                         new_pristine_props,
+                        eb->iprops,
                         eb->changed_rev,
                         eb->changed_date,
                         eb->changed_author,
@@ -825,6 +830,12 @@ close_file(void *file_baton,
                         all_work_items,
                         pool));
 
+    /* close_edit may also update iprops for switched files, catching
+       those for which close_file is never called (e.g. an update of a
+       file external with no changes).  So as a minor optimization we
+       clear the iprops so as not to set them again in close_edit. */
+    eb->iprops = NULL;
+
     SVN_ERR(svn_wc__wq_run(eb->db, eb->wri_abspath,
                            eb->cancel_func, eb->cancel_baton, pool));
   }
@@ -864,8 +875,18 @@ close_edit(void *edit_baton,
 {
   struct edit_baton *eb = edit_baton;
 
-  if (!eb->file_closed)
+  if (!eb->file_closed
+      || eb->iprops)
     {
+      apr_hash_t *wcroot_iprops = NULL;
+
+      if (eb->iprops)
+        {
+          wcroot_iprops = apr_hash_make(pool);
+          apr_hash_set(wcroot_iprops, eb->local_abspath, APR_HASH_KEY_STRING,
+                       eb->iprops);
+        }
+
       /* The node wasn't updated, so we just have to bump its revision */
       SVN_ERR(svn_wc__db_op_bump_revisions_post_update(eb->db,
                                                        eb->local_abspath,
@@ -873,7 +894,7 @@ close_edit(void *edit_baton,
                                                        NULL, NULL, NULL,
                                                        *eb->target_revision,
                                                        apr_hash_make(pool),
-                                                       NULL,
+                                                       wcroot_iprops,
                                                        pool));
     }
 
@@ -890,6 +911,7 @@ svn_wc__get_file_external_editor(const s
                                  const char *url,
                                  const char *repos_root_url,
                                  const char *repos_uuid,
+                                 apr_array_header_t *iprops,
                                  svn_boolean_t use_commit_times,
                                  const char *diff3_cmd,
                                  const apr_array_header_t *preserved_exts,
@@ -925,6 +947,8 @@ svn_wc__get_file_external_editor(const s
   eb->repos_root_url = apr_pstrdup(edit_pool, repos_root_url);
   eb->repos_uuid = apr_pstrdup(edit_pool, repos_uuid);
 
+  eb->iprops = iprops;
+
   eb->use_commit_times = use_commit_times;
   eb->ext_patterns = preserved_exts;
   eb->diff3cmd = diff3_cmd;

Modified: subversion/branches/inheritable-props/subversion/libsvn_wc/wc-queries.sql
URL: http://svn.apache.org/viewvc/subversion/branches/inheritable-props/subversion/libsvn_wc/wc-queries.sql?rev=1379553&r1=1379552&r2=1379553&view=diff
==============================================================================
--- subversion/branches/inheritable-props/subversion/libsvn_wc/wc-queries.sql (original)
+++ subversion/branches/inheritable-props/subversion/libsvn_wc/wc-queries.sql Fri Aug 31 19:17:47 2012
@@ -1532,14 +1532,14 @@ SELECT local_relpath FROM nodes
 WHERE wc_id = ?1
   AND local_relpath = ?2
   AND op_depth = 0
-  AND inherited_props not null
+  AND (inherited_props not null)
 
 -- STMT_SELECT_INODES_RECURSIVE
 SELECT local_relpath FROM nodes
 WHERE wc_id = ?1
   AND IS_STRICT_DESCENDANT_OF(local_relpath, ?2)
   AND op_depth = 0
-  AND inherited_props not null
+  AND (inherited_props not null)
 
 /* ------------------------------------------------------------------------- */
 

Modified: subversion/branches/inheritable-props/subversion/libsvn_wc/wc_db.c
URL: http://svn.apache.org/viewvc/subversion/branches/inheritable-props/subversion/libsvn_wc/wc_db.c?rev=1379553&r1=1379552&r2=1379553&view=diff
==============================================================================
--- subversion/branches/inheritable-props/subversion/libsvn_wc/wc_db.c (original)
+++ subversion/branches/inheritable-props/subversion/libsvn_wc/wc_db.c Fri Aug 31 19:17:47 2012
@@ -254,6 +254,7 @@ typedef struct insert_external_baton_t {
 
   /* for file and symlink externals */
   const apr_hash_t *props;
+  apr_array_header_t *iprops;
   svn_revnum_t changed_rev;
   apr_time_t changed_date;
   const char *changed_author;
@@ -2986,6 +2987,7 @@ insert_external_node(void *baton,
       ibb.revision        = ieb->revision;
 
       ibb.props           = ieb->props;
+      ibb.iprops          = ieb->iprops;
       ibb.changed_rev     = ieb->changed_rev;
       ibb.changed_date    = ieb->changed_date;
       ibb.changed_author  = ieb->changed_author;
@@ -3050,6 +3052,7 @@ svn_wc__db_external_add_file(svn_wc__db_
                              svn_revnum_t revision,
 
                              const apr_hash_t *props,
+                             apr_array_header_t *iprops,
 
                              svn_revnum_t changed_rev,
                              apr_time_t changed_date,
@@ -3104,6 +3107,7 @@ svn_wc__db_external_add_file(svn_wc__db_
   ieb.revision = revision;
 
   ieb.props = props;
+  ieb.iprops = iprops;
 
   ieb.changed_rev = changed_rev;
   ieb.changed_date = changed_date;

Modified: subversion/branches/inheritable-props/subversion/libsvn_wc/wc_db.h
URL: http://svn.apache.org/viewvc/subversion/branches/inheritable-props/subversion/libsvn_wc/wc_db.h?rev=1379553&r1=1379552&r2=1379553&view=diff
==============================================================================
--- subversion/branches/inheritable-props/subversion/libsvn_wc/wc_db.h (original)
+++ subversion/branches/inheritable-props/subversion/libsvn_wc/wc_db.h Fri Aug 31 19:17:47 2012
@@ -1041,6 +1041,7 @@ svn_wc__db_external_add_file(svn_wc__db_
                              svn_revnum_t revision,
 
                              const apr_hash_t *props,
+                             apr_array_header_t *iprops,
 
                              svn_revnum_t changed_rev,
                              apr_time_t changed_date,

Modified: subversion/branches/inheritable-props/subversion/tests/cmdline/iprop_tests.py
URL: http://svn.apache.org/viewvc/subversion/branches/inheritable-props/subversion/tests/cmdline/iprop_tests.py?rev=1379553&r1=1379552&r2=1379553&view=diff
==============================================================================
--- subversion/branches/inheritable-props/subversion/tests/cmdline/iprop_tests.py (original)
+++ subversion/branches/inheritable-props/subversion/tests/cmdline/iprop_tests.py Fri Aug 31 19:17:47 2012
@@ -1574,7 +1574,6 @@ def iprops_with_directory_externals(sbox
 
 #----------------------------------------------------------------------
 # Inherited property caching by file externals.
-@XFail()
 def iprops_with_file_externals(sbox):
   "iprop caching works with file externals"
 
@@ -1591,19 +1590,19 @@ def iprops_with_file_externals(sbox):
   svntest.main.run_svn(None, 'commit', '-m', 'Add a branch property',
                        wc_dir)
 
-  # Create a file external in the first WC that points to a location in the
-  # same WC.
+  # Create two file externals, one pegged to a fixed revision.
   sbox.simple_propset('svn:externals',
                       sbox.repo_url + '/A/D/H/psi file-external',
                       'A/B/E')
+  sbox.simple_propset('svn:externals',
+                      sbox.repo_url + '/A/D/H/psi@4 file-external-pegged',
+                      'A/B/F')
   svntest.actions.run_and_verify_svn(None, None, [], 'ci', '-m',
                                      'Add a file external', wc_dir)
   svntest.actions.run_and_verify_svn(None, None, [], 'up', wc_dir)
 
-  # Check the properties inherited by the external file.  It should
-  # inherit the property from ^/ and ^/A/D.
-  #
-  # Currently this fails because the file external inherits *nothing*.
+  # Check the properties inherited by the external files.  Both should
+  # inherit the properties from ^/ and ^/A/D.
   expected_iprops = {
     sbox.repo_url          : {'Prime-Root-Prop'   : 'Root-Prop-Val1'},
     sbox.repo_url + '/A/D' : {'Prime-Branch-Prop' : 'Branch-Prop-Val1'}}
@@ -1611,6 +1610,37 @@ def iprops_with_file_externals(sbox):
   svntest.actions.run_and_verify_inherited_prop_xml(
     sbox.ospath('A/B/E/file-external'), expected_iprops,
     expected_explicit_props)
+  svntest.actions.run_and_verify_inherited_prop_xml(
+    sbox.ospath('A/B/F/file-external-pegged'), expected_iprops,
+    expected_explicit_props)
+
+  # Modify the "branch" property on 'A/D'.
+  sbox.simple_propset('Prime-Branch-Prop', 'Branch-Prop-Val2', 'A/D')
+  svntest.main.run_svn(None, 'commit', '-m', 'Add a branch property',
+                       wc_dir)
+
+  # There should be no change in the external file's
+  # inherited properties until...
+  svntest.actions.run_and_verify_inherited_prop_xml(
+    sbox.ospath('A/B/E/file-external'), expected_iprops,
+    expected_explicit_props)
+  svntest.actions.run_and_verify_inherited_prop_xml(
+    sbox.ospath('A/B/F/file-external-pegged'), expected_iprops,
+    expected_explicit_props)
+
+  # ...We update the external:
+  svntest.actions.run_and_verify_svn(None, None, [], 'up', wc_dir)
+  # The pegged file external's iprops should remain unchanged.
+  svntest.actions.run_and_verify_inherited_prop_xml(
+    sbox.ospath('A/B/F/file-external-pegged'), expected_iprops,
+    expected_explicit_props)
+  # But the other's should be updated.
+  expected_iprops = {
+    sbox.repo_url          : {'Prime-Root-Prop'   : 'Root-Prop-Val1'},
+    sbox.repo_url + '/A/D' : {'Prime-Branch-Prop' : 'Branch-Prop-Val2'}}
+  svntest.actions.run_and_verify_inherited_prop_xml(
+    sbox.ospath('A/B/E/file-external'), expected_iprops,
+    expected_explicit_props)
 
 ########################################################################
 # Run the tests

Modified: subversion/branches/inheritable-props/subversion/tests/libsvn_wc/db-test.c
URL: http://svn.apache.org/viewvc/subversion/branches/inheritable-props/subversion/tests/libsvn_wc/db-test.c?rev=1379553&r1=1379552&r2=1379553&view=diff
==============================================================================
--- subversion/branches/inheritable-props/subversion/tests/libsvn_wc/db-test.c (original)
+++ subversion/branches/inheritable-props/subversion/tests/libsvn_wc/db-test.c Fri Aug 31 19:17:47 2012
@@ -1406,6 +1406,7 @@ test_externals_store(apr_pool_t *pool)
                                        "not-a-uuid",
                                        12,
                                        props,
+                                       NULL,
                                        10,
                                        987654,
                                        "somebody",