You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by ph...@apache.org on 2010/10/19 11:33:06 UTC

svn commit: r1024187 - /subversion/trunk/subversion/libsvn_wc/wc_db.c

Author: philip
Date: Tue Oct 19 09:33:06 2010
New Revision: 1024187

URL: http://svn.apache.org/viewvc?rev=1024187&view=rev
Log:
* subversion/libsvn_wc/wc_db.c
  (svn_wc__db_op_read_tree_conflict): Get a pdh and use it to avoid 
   ascending outside the working copy root.

Modified:
    subversion/trunk/subversion/libsvn_wc/wc_db.c

Modified: subversion/trunk/subversion/libsvn_wc/wc_db.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc_db.c?rev=1024187&r1=1024186&r2=1024187&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db.c (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db.c Tue Oct 19 09:33:06 2010
@@ -3920,31 +3920,34 @@ svn_wc__db_op_read_tree_conflict(
                      apr_pool_t *result_pool,
                      apr_pool_t *scratch_pool)
 {
-  const char *parent_abspath;
-  apr_hash_t *tree_conflicts;
-  svn_error_t *err;
+  svn_wc__db_pdh_t *pdh;
+  const char *local_relpath, *child_path;
 
   SVN_ERR_ASSERT(svn_dirent_is_absolute(local_abspath));
-  parent_abspath = svn_dirent_dirname(local_abspath, scratch_pool);
 
-  err = svn_wc__db_op_read_all_tree_conflicts(&tree_conflicts, db,
-                                              parent_abspath,
-                                              result_pool, scratch_pool);
-  if (err && SVN_WC__ERR_IS_NOT_CURRENT_WC(err))
+  SVN_ERR(svn_wc__db_pdh_parse_local_abspath(&pdh, &local_relpath, db,
+                              local_abspath, svn_sqlite__mode_readonly,
+                              scratch_pool, scratch_pool));
+
+  child_path = svn_dirent_skip_ancestor(pdh->wcroot->abspath, local_abspath);
+  if (child_path != local_abspath && child_path[0])
     {
-       /* We walked off the top of a working copy.  */
-       svn_error_clear(err);
-       *tree_conflict = NULL;
-       return SVN_NO_ERROR;
-    }
-  else if (err)
-    return svn_error_return(err);
+      const char * parent_abspath;
+      apr_hash_t *tree_conflicts;
 
-  if (tree_conflicts)
-    *tree_conflict = apr_hash_get(tree_conflicts,
-                                  svn_dirent_basename(local_abspath,
-                                                      scratch_pool),
-                                  APR_HASH_KEY_STRING);
+      parent_abspath = svn_dirent_dirname(local_abspath, scratch_pool);
+
+      SVN_ERR(svn_wc__db_op_read_all_tree_conflicts(&tree_conflicts, db,
+                                                    parent_abspath,
+                                                    result_pool, scratch_pool));
+      if (tree_conflicts)
+        *tree_conflict = apr_hash_get(tree_conflicts,
+                                      svn_dirent_basename(local_abspath,
+                                                          scratch_pool),
+                                      APR_HASH_KEY_STRING);
+      else
+        *tree_conflict = NULL;
+    }
   else
     *tree_conflict = NULL;
 



Re: svn commit: r1024187 - /subversion/trunk/subversion/libsvn_wc/wc_db.c

Posted by Philip Martin <ph...@wandisco.com>.
"Bert Huijben" <be...@qqmail.nl> writes:

>> -  if (err && SVN_WC__ERR_IS_NOT_CURRENT_WC(err))
>> +  SVN_ERR(svn_wc__db_pdh_parse_local_abspath(&pdh, &local_relpath, db,
>> +                              local_abspath,
>> svn_sqlite__mode_readonly,
>> +                              scratch_pool, scratch_pool));
>> +
>> +  child_path = svn_dirent_skip_ancestor(pdh->wcroot->abspath,
>> local_abspath);
>> +  if (child_path != local_abspath && child_path[0])
>
> if (*local_relpath != '\0') gives you the same result.

Ah, yes.

>
>>      {
>> -       /* We walked off the top of a working copy.  */
>> -       svn_error_clear(err);
>> -       *tree_conflict = NULL;
>> -       return SVN_NO_ERROR;
>> -    }
>> -  else if (err)
>> -    return svn_error_return(err);
>> +      const char * parent_abspath;
>> +      apr_hash_t *tree_conflicts;
>> 
>> -  if (tree_conflicts)
>> -    *tree_conflict = apr_hash_get(tree_conflicts,
>> -                                  svn_dirent_basename(local_abspath,
>> -                                                      scratch_pool),
>> -                                  APR_HASH_KEY_STRING);
>> +      parent_abspath = svn_dirent_dirname(local_abspath,
>> scratch_pool);
>> +
>> +      SVN_ERR(svn_wc__db_op_read_all_tree_conflicts(&tree_conflicts,
>> db,
>> +                                                    parent_abspath,
>> +                                                    result_pool,
>> scratch_pool));
>> +      if (tree_conflicts)
>> +        *tree_conflict = apr_hash_get(tree_conflicts,
>> +
>> svn_dirent_basename(local_abspath,
>> +
>> scratch_pool),
>> +                                      APR_HASH_KEY_STRING);
>
> You can pass NULL to svn_dirent_basename() here, which will just return a pointer into local_abspath.

That's not my code, but yes.  A quick grep suggests there are several
places this could be done.

-- 
Philip

Re: svn commit: r1024187 - /subversion/trunk/subversion/libsvn_wc/wc_db.c

Posted by Philip Martin <ph...@wandisco.com>.
"Bert Huijben" <be...@qqmail.nl> writes:

>> -  if (err && SVN_WC__ERR_IS_NOT_CURRENT_WC(err))
>> +  SVN_ERR(svn_wc__db_pdh_parse_local_abspath(&pdh, &local_relpath, db,
>> +                              local_abspath,
>> svn_sqlite__mode_readonly,
>> +                              scratch_pool, scratch_pool));
>> +
>> +  child_path = svn_dirent_skip_ancestor(pdh->wcroot->abspath,
>> local_abspath);
>> +  if (child_path != local_abspath && child_path[0])
>
> if (*local_relpath != '\0') gives you the same result.

Ah, yes.

>
>>      {
>> -       /* We walked off the top of a working copy.  */
>> -       svn_error_clear(err);
>> -       *tree_conflict = NULL;
>> -       return SVN_NO_ERROR;
>> -    }
>> -  else if (err)
>> -    return svn_error_return(err);
>> +      const char * parent_abspath;
>> +      apr_hash_t *tree_conflicts;
>> 
>> -  if (tree_conflicts)
>> -    *tree_conflict = apr_hash_get(tree_conflicts,
>> -                                  svn_dirent_basename(local_abspath,
>> -                                                      scratch_pool),
>> -                                  APR_HASH_KEY_STRING);
>> +      parent_abspath = svn_dirent_dirname(local_abspath,
>> scratch_pool);
>> +
>> +      SVN_ERR(svn_wc__db_op_read_all_tree_conflicts(&tree_conflicts,
>> db,
>> +                                                    parent_abspath,
>> +                                                    result_pool,
>> scratch_pool));
>> +      if (tree_conflicts)
>> +        *tree_conflict = apr_hash_get(tree_conflicts,
>> +
>> svn_dirent_basename(local_abspath,
>> +
>> scratch_pool),
>> +                                      APR_HASH_KEY_STRING);
>
> You can pass NULL to svn_dirent_basename() here, which will just return a pointer into local_abspath.

That's not my code, but yes.  A quick grep suggests there are several
places this could be done.

-- 
Philip

RE: svn commit: r1024187 - /subversion/trunk/subversion/libsvn_wc/wc_db.c

Posted by Bert Huijben <be...@qqmail.nl>.

> -----Original Message-----
> From: philip@apache.org [mailto:philip@apache.org]
> Sent: dinsdag 19 oktober 2010 11:33
> To: commits@subversion.apache.org
> Subject: svn commit: r1024187 -
> /subversion/trunk/subversion/libsvn_wc/wc_db.c
> 
> Author: philip
> Date: Tue Oct 19 09:33:06 2010
> New Revision: 1024187
> 
> URL: http://svn.apache.org/viewvc?rev=1024187&view=rev
> Log:
> * subversion/libsvn_wc/wc_db.c
>   (svn_wc__db_op_read_tree_conflict): Get a pdh and use it to avoid
>    ascending outside the working copy root.
> 
> Modified:
>     subversion/trunk/subversion/libsvn_wc/wc_db.c
> 
> Modified: subversion/trunk/subversion/libsvn_wc/wc_db.c
> URL:
> http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc_d
> b.c?rev=1024187&r1=1024186&r2=1024187&view=diff
> =======================================================================
> =======
> --- subversion/trunk/subversion/libsvn_wc/wc_db.c (original)
> +++ subversion/trunk/subversion/libsvn_wc/wc_db.c Tue Oct 19 09:33:06
> 2010
> @@ -3920,31 +3920,34 @@ svn_wc__db_op_read_tree_conflict(
>                       apr_pool_t *result_pool,
>                       apr_pool_t *scratch_pool)
>  {
> -  const char *parent_abspath;
> -  apr_hash_t *tree_conflicts;
> -  svn_error_t *err;
> +  svn_wc__db_pdh_t *pdh;
> +  const char *local_relpath, *child_path;
> 
>    SVN_ERR_ASSERT(svn_dirent_is_absolute(local_abspath));
> -  parent_abspath = svn_dirent_dirname(local_abspath, scratch_pool);
> 
> -  err = svn_wc__db_op_read_all_tree_conflicts(&tree_conflicts, db,
> -                                              parent_abspath,
> -                                              result_pool,
> scratch_pool);
> -  if (err && SVN_WC__ERR_IS_NOT_CURRENT_WC(err))
> +  SVN_ERR(svn_wc__db_pdh_parse_local_abspath(&pdh, &local_relpath, db,
> +                              local_abspath,
> svn_sqlite__mode_readonly,
> +                              scratch_pool, scratch_pool));
> +
> +  child_path = svn_dirent_skip_ancestor(pdh->wcroot->abspath,
> local_abspath);
> +  if (child_path != local_abspath && child_path[0])

if (*local_relpath != '\0') gives you the same result.

>      {
> -       /* We walked off the top of a working copy.  */
> -       svn_error_clear(err);
> -       *tree_conflict = NULL;
> -       return SVN_NO_ERROR;
> -    }
> -  else if (err)
> -    return svn_error_return(err);
> +      const char * parent_abspath;
> +      apr_hash_t *tree_conflicts;
> 
> -  if (tree_conflicts)
> -    *tree_conflict = apr_hash_get(tree_conflicts,
> -                                  svn_dirent_basename(local_abspath,
> -                                                      scratch_pool),
> -                                  APR_HASH_KEY_STRING);
> +      parent_abspath = svn_dirent_dirname(local_abspath,
> scratch_pool);
> +
> +      SVN_ERR(svn_wc__db_op_read_all_tree_conflicts(&tree_conflicts,
> db,
> +                                                    parent_abspath,
> +                                                    result_pool,
> scratch_pool));
> +      if (tree_conflicts)
> +        *tree_conflict = apr_hash_get(tree_conflicts,
> +
> svn_dirent_basename(local_abspath,
> +
> scratch_pool),
> +                                      APR_HASH_KEY_STRING);

You can pass NULL to svn_dirent_basename() here, which will just return a pointer into local_abspath.

	Bert 


RE: svn commit: r1024187 - /subversion/trunk/subversion/libsvn_wc/wc_db.c

Posted by Bert Huijben <be...@qqmail.nl>.

> -----Original Message-----
> From: philip@apache.org [mailto:philip@apache.org]
> Sent: dinsdag 19 oktober 2010 11:33
> To: commits@subversion.apache.org
> Subject: svn commit: r1024187 -
> /subversion/trunk/subversion/libsvn_wc/wc_db.c
> 
> Author: philip
> Date: Tue Oct 19 09:33:06 2010
> New Revision: 1024187
> 
> URL: http://svn.apache.org/viewvc?rev=1024187&view=rev
> Log:
> * subversion/libsvn_wc/wc_db.c
>   (svn_wc__db_op_read_tree_conflict): Get a pdh and use it to avoid
>    ascending outside the working copy root.
> 
> Modified:
>     subversion/trunk/subversion/libsvn_wc/wc_db.c
> 
> Modified: subversion/trunk/subversion/libsvn_wc/wc_db.c
> URL:
> http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc_d
> b.c?rev=1024187&r1=1024186&r2=1024187&view=diff
> =======================================================================
> =======
> --- subversion/trunk/subversion/libsvn_wc/wc_db.c (original)
> +++ subversion/trunk/subversion/libsvn_wc/wc_db.c Tue Oct 19 09:33:06
> 2010
> @@ -3920,31 +3920,34 @@ svn_wc__db_op_read_tree_conflict(
>                       apr_pool_t *result_pool,
>                       apr_pool_t *scratch_pool)
>  {
> -  const char *parent_abspath;
> -  apr_hash_t *tree_conflicts;
> -  svn_error_t *err;
> +  svn_wc__db_pdh_t *pdh;
> +  const char *local_relpath, *child_path;
> 
>    SVN_ERR_ASSERT(svn_dirent_is_absolute(local_abspath));
> -  parent_abspath = svn_dirent_dirname(local_abspath, scratch_pool);
> 
> -  err = svn_wc__db_op_read_all_tree_conflicts(&tree_conflicts, db,
> -                                              parent_abspath,
> -                                              result_pool,
> scratch_pool);
> -  if (err && SVN_WC__ERR_IS_NOT_CURRENT_WC(err))
> +  SVN_ERR(svn_wc__db_pdh_parse_local_abspath(&pdh, &local_relpath, db,
> +                              local_abspath,
> svn_sqlite__mode_readonly,
> +                              scratch_pool, scratch_pool));
> +
> +  child_path = svn_dirent_skip_ancestor(pdh->wcroot->abspath,
> local_abspath);
> +  if (child_path != local_abspath && child_path[0])

if (*local_relpath != '\0') gives you the same result.

>      {
> -       /* We walked off the top of a working copy.  */
> -       svn_error_clear(err);
> -       *tree_conflict = NULL;
> -       return SVN_NO_ERROR;
> -    }
> -  else if (err)
> -    return svn_error_return(err);
> +      const char * parent_abspath;
> +      apr_hash_t *tree_conflicts;
> 
> -  if (tree_conflicts)
> -    *tree_conflict = apr_hash_get(tree_conflicts,
> -                                  svn_dirent_basename(local_abspath,
> -                                                      scratch_pool),
> -                                  APR_HASH_KEY_STRING);
> +      parent_abspath = svn_dirent_dirname(local_abspath,
> scratch_pool);
> +
> +      SVN_ERR(svn_wc__db_op_read_all_tree_conflicts(&tree_conflicts,
> db,
> +                                                    parent_abspath,
> +                                                    result_pool,
> scratch_pool));
> +      if (tree_conflicts)
> +        *tree_conflict = apr_hash_get(tree_conflicts,
> +
> svn_dirent_basename(local_abspath,
> +
> scratch_pool),
> +                                      APR_HASH_KEY_STRING);

You can pass NULL to svn_dirent_basename() here, which will just return a pointer into local_abspath.

	Bert