You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by hw...@apache.org on 2010/05/19 21:09:22 UTC

svn commit: r946343 - in /subversion/trunk/subversion/libsvn_wc: wc_db.c wc_db_util.c wc_db_util.h

Author: hwright
Date: Wed May 19 19:09:21 2010
New Revision: 946343

URL: http://svn.apache.org/viewvc?rev=946343&view=rev
Log:
Introduce another file for breaking stuff out of wc_db.c.

* subversion/libsvn_wc/wc_db_util.c,
  subversion/libsvn_wc/wc_db_util.h:
  New.

* subversion/libsvn_wc/wc_db.c
  (fetch_wc_id): Remove.
  (parse_local_abspath, svn_wc__db_upgrade_apply_dav_cache): Update callers.

Added:
    subversion/trunk/subversion/libsvn_wc/wc_db_util.c   (with props)
    subversion/trunk/subversion/libsvn_wc/wc_db_util.h   (with props)
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=946343&r1=946342&r2=946343&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db.c (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db.c Wed May 19 19:09:21 2010
@@ -43,6 +43,7 @@
 #include "lock.h"
 #include "tree_conflicts.h"
 #include "wc_db_pdh.h"
+#include "wc_db_util.h"
 #include "workqueue.h"
 
 #include "svn_private_config.h"
@@ -592,30 +593,6 @@ determine_obstructed_file(svn_boolean_t 
 
 /* */
 static svn_error_t *
-fetch_wc_id(apr_int64_t *wc_id,
-            svn_sqlite__db_t *sdb,
-            apr_pool_t *scratch_pool)
-{
-  svn_sqlite__stmt_t *stmt;
-  svn_boolean_t have_row;
-
-  /* ### cheat. we know there is just one WORKING_COPY row, and it has a
-     ### NULL value for local_abspath. */
-  SVN_ERR(svn_sqlite__get_statement(&stmt, sdb, STMT_SELECT_WCROOT_NULL));
-  SVN_ERR(svn_sqlite__step(&have_row, stmt));
-  if (!have_row)
-    return svn_error_createf(SVN_ERR_WC_CORRUPT, svn_sqlite__reset(stmt),
-                             _("Missing a row in WCROOT."));
-
-  SVN_ERR_ASSERT(!svn_sqlite__column_is_null(stmt, 0));
-  *wc_id = svn_sqlite__column_int64(stmt, 0);
-
-  return svn_error_return(svn_sqlite__reset(stmt));
-}
-
-
-/* */
-static svn_error_t *
 open_db(svn_sqlite__db_t **sdb,
         const char *dir_abspath,
         const char *sdb_fname,
@@ -851,7 +828,7 @@ parse_local_abspath(svn_wc__db_pdh_t **p
       apr_int64_t wc_id;
       svn_error_t *err;
 
-      err = fetch_wc_id(&wc_id, sdb, scratch_pool);
+      err = svn_wc__db_util_fetch_wc_id(&wc_id, sdb, scratch_pool);
       if (err)
         {
           if (err->apr_err == SVN_ERR_WC_CORRUPT)
@@ -5973,7 +5950,7 @@ svn_wc__db_upgrade_apply_dav_cache(svn_s
   apr_hash_index_t *hi;
   svn_sqlite__stmt_t *stmt;
 
-  SVN_ERR(fetch_wc_id(&wc_id, sdb, iterpool));
+  SVN_ERR(svn_wc__db_util_fetch_wc_id(&wc_id, sdb, iterpool));
 
   SVN_ERR(svn_sqlite__get_statement(&stmt, sdb, STMT_UPDATE_BASE_DAV_CACHE));
 

Added: subversion/trunk/subversion/libsvn_wc/wc_db_util.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc_db_util.c?rev=946343&view=auto
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db_util.c (added)
+++ subversion/trunk/subversion/libsvn_wc/wc_db_util.c Wed May 19 19:09:21 2010
@@ -0,0 +1,73 @@
+/*
+ * wc_db_util.c :  Various util functions for wc_db(_pdh)
+ *
+ * ====================================================================
+ *    Licensed to the Apache Software Foundation (ASF) under one
+ *    or more contributor license agreements.  See the NOTICE file
+ *    distributed with this work for additional information
+ *    regarding copyright ownership.  The ASF licenses this file
+ *    to you under the Apache License, Version 2.0 (the
+ *    "License"); you may not use this file except in compliance
+ *    with the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing,
+ *    software distributed under the License is distributed on an
+ *    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *    KIND, either express or implied.  See the License for the
+ *    specific language governing permissions and limitations
+ *    under the License.
+ * ====================================================================
+ */
+
+/* About this file:
+   This file is meant to be a stash of fairly low-level functions used by both
+   wc_db.c and wc_db_pdh.c.  In breaking stuff out of the monolithic wc_db.c,
+   I have discovered that some utility functions are used by bits in both
+   files.  Rather than shoehorn those functions into one file or the other, or
+   create circular dependencies between the files, I felt a third file, with
+   a well-defined scope, would be sensible.  History will judge its effect.
+
+   The goal of it file is simple: just execute SQLite statements.  That is,
+   functions in this file should have no knowledge of pdh's or db's, and
+   should just operate on the raw sdb object.  If a function requires more
+   information than that, it shouldn't be in here.  -hkw
+ */
+
+#define SVN_WC__I_AM_WC_DB
+
+#include "svn_dirent_uri.h"
+
+#include "wc.h"
+#include "wc_db_util.h"
+#include "wc-queries.h"
+
+#include "svn_private_config.h"
+
+WC_QUERIES_SQL_DECLARE_STATEMENTS(statements);
+
+
+
+/* */
+svn_error_t *
+svn_wc__db_util_fetch_wc_id(apr_int64_t *wc_id,
+                            svn_sqlite__db_t *sdb,
+                            apr_pool_t *scratch_pool)
+{
+  svn_sqlite__stmt_t *stmt;
+  svn_boolean_t have_row;
+
+  /* ### cheat. we know there is just one WORKING_COPY row, and it has a
+     ### NULL value for local_abspath. */
+  SVN_ERR(svn_sqlite__get_statement(&stmt, sdb, STMT_SELECT_WCROOT_NULL));
+  SVN_ERR(svn_sqlite__step(&have_row, stmt));
+  if (!have_row)
+    return svn_error_createf(SVN_ERR_WC_CORRUPT, svn_sqlite__reset(stmt),
+                             _("Missing a row in WCROOT."));
+
+  SVN_ERR_ASSERT(!svn_sqlite__column_is_null(stmt, 0));
+  *wc_id = svn_sqlite__column_int64(stmt, 0);
+
+  return svn_error_return(svn_sqlite__reset(stmt));
+}

Propchange: subversion/trunk/subversion/libsvn_wc/wc_db_util.c
------------------------------------------------------------------------------
    svn:eol-style = native

Added: subversion/trunk/subversion/libsvn_wc/wc_db_util.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc_db_util.h?rev=946343&view=auto
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db_util.h (added)
+++ subversion/trunk/subversion/libsvn_wc/wc_db_util.h Wed May 19 19:09:21 2010
@@ -0,0 +1,42 @@
+/**
+ * @copyright
+ * ====================================================================
+ *    Licensed to the Apache Software Foundation (ASF) under one
+ *    or more contributor license agreements.  See the NOTICE file
+ *    distributed with this work for additional information
+ *    regarding copyright ownership.  The ASF licenses this file
+ *    to you under the Apache License, Version 2.0 (the
+ *    "License"); you may not use this file except in compliance
+ *    with the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing,
+ *    software distributed under the License is distributed on an
+ *    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *    KIND, either express or implied.  See the License for the
+ *    specific language governing permissions and limitations
+ *    under the License.
+ * ====================================================================
+ * @endcopyright
+ */
+
+/* This file is not for general consumption; it should only be used by
+   wc_db.c. */
+#ifndef SVN_WC__I_AM_WC_DB
+#error "You should not be using these functions directly"
+#endif /* SVN_WC__I_AM_WC_DB */
+
+#ifndef WC_DB_UTIL_H
+#define WC_DB_UTIL_H
+
+#include "wc_db.h"
+
+
+/* */
+svn_error_t *
+svn_wc__db_util_fetch_wc_id(apr_int64_t *wc_id,
+                            svn_sqlite__db_t *sdb,
+                            apr_pool_t *scratch_pool);
+
+#endif /* WC_DB_UTIL_H */

Propchange: subversion/trunk/subversion/libsvn_wc/wc_db_util.h
------------------------------------------------------------------------------
    svn:eol-style = native



Re: svn commit: r946343 - in /subversion/trunk/subversion/libsvn_wc: wc_db.c wc_db_util.c wc_db_util.h

Posted by "Hyrum K. Wright" <hy...@mail.utexas.edu>.
On Wed, May 19, 2010 at 3:43 PM, Greg Stein <gs...@gmail.com> wrote:

> On Wed, May 19, 2010 at 15:09,  <hw...@apache.org> wrote:
> > Author: hwright
> > Date: Wed May 19 19:09:21 2010
> > New Revision: 946343
> >
> > URL: http://svn.apache.org/viewvc?rev=946343&view=rev
> > Log:
> > Introduce another file for breaking stuff out of wc_db.c.
> >
> > * subversion/libsvn_wc/wc_db_util.c,
> >  subversion/libsvn_wc/wc_db_util.h:
> >  New.
>
> Per IRC, I would suggest a single wc_db_private.h. Many little headers
> just gets to be annoying, and I don't think this header will get
> out-of-control-sized.
>

Makes sense.  I'll combine wc_db_util.h and wc_db_pdh.h into
wc_db_private.h.

-Hyrum

Re: svn commit: r946343 - in /subversion/trunk/subversion/libsvn_wc: wc_db.c wc_db_util.c wc_db_util.h

Posted by Greg Stein <gs...@gmail.com>.
On Wed, May 19, 2010 at 15:09,  <hw...@apache.org> wrote:
> Author: hwright
> Date: Wed May 19 19:09:21 2010
> New Revision: 946343
>
> URL: http://svn.apache.org/viewvc?rev=946343&view=rev
> Log:
> Introduce another file for breaking stuff out of wc_db.c.
>
> * subversion/libsvn_wc/wc_db_util.c,
>  subversion/libsvn_wc/wc_db_util.h:
>  New.

Per IRC, I would suggest a single wc_db_private.h. Many little headers
just gets to be annoying, and I don't think this header will get
out-of-control-sized.

>...

Cheers,
-g