Re: svn commit: r36758 - trunk/subversion/libsvn_wc
From: Kouhei Sutou <kou_at_cozmixng.org>
Date: Sat, 9 May 2009 09:18:25 +0900
Hi,
This change requires that repos_root should not be NULL.
svn_wc_ensure_adm3()'s documents says
Thanks,
-- kou 2009/3/25 Hyrum K. Wright <hyrum_at_hyrumwright.org>: > Author: hwright > Date: Tue Mar 24 14:09:14 2009 > New Revision: 36758 > > Log: > Move the directory initialization code into wc_db. > > * subversion/libsvn_wc/entries.c >  (statements, statement_keys): Remove a statement. >  (svn_wc__entries_init): Largely gut, calling the wc_db API instead. > > * subversion/libsvn_wc/wc_db.c >  (statement_keys, statements): New statement.  Also, when inserting the >   base_node, also insert the incomplete children flag. >  (insert_base_baton): Add incomplete_children flag. >  (insert_base_node): Insert the incomplete children flag. >  (svn_wc__db_init): New. > > * subversion/libsvn_wc/wc_db.h >  (svn_wc__db_init): New. > > Modified: >  trunk/subversion/libsvn_wc/entries.c >  trunk/subversion/libsvn_wc/wc_db.c >  trunk/subversion/libsvn_wc/wc_db.h > > Modified: trunk/subversion/libsvn_wc/entries.c > URL: http://svn.collab.net/viewvc/svn/trunk/subversion/libsvn_wc/entries.c?pathrev=36758&r1=36757&r2=36758 > ============================================================================== > --- trunk/subversion/libsvn_wc/entries.c     Tue Mar 24 09:59:55 2009     (r36757) > +++ trunk/subversion/libsvn_wc/entries.c     Tue Mar 24 14:09:14 2009     (r36758) > @@ -59,7 +59,6 @@ static const char * const upgrade_sql[] >   and removed at the same time. */ >  enum statement_keys { >  STMT_INSERT_REPOSITORY, > -  STMT_INSERT_WCROOT, >  STMT_INSERT_BASE_NODE, >  STMT_INSERT_WORKING_NODE, >  STMT_INSERT_ACTUAL_NODE, > @@ -81,9 +80,6 @@ static const char * const statements[] = >  "insert into repository (root, uuid) " >  "values (?1, ?2);", > > -  "insert into wcroot (local_abspath) " > -  "values (?1);", > - >  "insert or replace into base_node " >   "(wc_id, local_relpath, repos_id, repos_relpath, parent_relpath, " >    "presence, " > @@ -2935,77 +2931,31 @@ svn_error_t * >  svn_wc__entries_init(const char *path, >            const char *uuid, >            const char *url, > -           const char *repos, > +           const char *repos_root, >            svn_revnum_t initial_rev, >            svn_depth_t depth, >            apr_pool_t *pool) >  { > -  svn_sqlite__db_t *wc_db; > -  svn_wc__db_t *db; > -  svn_sqlite__stmt_t *stmt; >  apr_pool_t *scratch_pool = svn_pool_create(pool); > -  const char *wc_db_path = db_path(path, scratch_pool); > -  apr_int64_t wc_id; > -  apr_int64_t repos_id; > -  svn_wc_entry_t *entry = alloc_entry(scratch_pool); > +  const char *abspath; > +  const char *repos_relpath; > >  if (!should_create_next_gen()) > -   return svn_wc__entries_init_old(path, uuid, url, repos, initial_rev, > +   return svn_wc__entries_init_old(path, uuid, url, repos_root, initial_rev, >                   depth, pool); > > -  SVN_ERR_ASSERT(! repos || svn_path_is_ancestor(repos, url)); > +  SVN_ERR_ASSERT(! repos_root || svn_path_is_ancestor(repos_root, url)); >  SVN_ERR_ASSERT(depth == svn_depth_empty >          || depth == svn_depth_files >          || depth == svn_depth_immediates >          || depth == svn_depth_infinity); > > -  /* ### chicken and egg problem: we don't have an adm_access baton to > -   ### use to open the initial entries database, we we've got to do it > -   ### manually. */ > -  SVN_ERR(svn_wc__db_open(&db, svn_wc__db_openmode_readwrite, path, > -              NULL, scratch_pool, scratch_pool)); > - > -  /* Open the sqlite database, and insert the REPOS and WCROOT. > -   ### this is redundant, but we currently need it for the entry > -   ### inserting API.  DB and WC_DB should be pointing to the *same* > -   ### sqlite database, and it works fine thanks for sqlite's > -   ### concurrency handling.  However, this should eventually disappear. */ > -  SVN_ERR(svn_sqlite__open(&wc_db, wc_db_path, svn_sqlite__mode_rwcreate, > -              statements, > -              SVN_WC__VERSION_EXPERIMENTAL, upgrade_sql, > -              scratch_pool, scratch_pool)); > - > -#ifdef SVN_DEBUG > -  { > -   SVN_ERR(svn_sqlite__exec(wc_db, WC_CHECKS_SQL)); > -  } > -#endif > - > -  /* Insert the repository. */ > -  SVN_ERR(svn_sqlite__get_statement(&stmt, wc_db, STMT_INSERT_REPOSITORY)); > -  SVN_ERR(svn_sqlite__bindf(stmt, "ss", repos, uuid)); > -  SVN_ERR(svn_sqlite__insert(&repos_id, stmt)); > - > -  /* Insert the wcroot. */ > -  /* ### Right now, this just assumes wc metadata is being stored locally. */ > -  SVN_ERR(svn_sqlite__get_statement(&stmt, wc_db, STMT_INSERT_WCROOT)); > -  SVN_ERR(svn_sqlite__insert(&wc_id, stmt)); > - > -  /* Add an entry for the dir itself.  The directory has no name.  It > -   might have a UUID, but otherwise only the revision and default > -   ancestry are present, and possibly an 'incomplete' flag if the revnum > -   is > 0. */ > -  entry->kind = svn_node_dir; > -  entry->url = url; > -  entry->revision = initial_rev; > -  entry->uuid = uuid; > -  entry->repos = repos; > -  entry->depth = depth; > -  if (initial_rev > 0) > -   entry->incomplete = TRUE; > - > -  SVN_ERR(write_entry(db, wc_db, wc_id, repos_id, repos, entry, > -            SVN_WC_ENTRY_THIS_DIR, path, entry, scratch_pool)); > +  /* Initialize the db for this directory. */ > +  SVN_ERR(svn_dirent_get_absolute(&abspath, path, scratch_pool)); > +  repos_relpath = svn_uri_is_child(repos_root, url, scratch_pool); > +  SVN_ERR(svn_wc__db_init(abspath, repos_relpath == NULL ? "" > +               : svn_path_uri_decode(repos_relpath, scratch_pool), > +              repos_root, uuid, initial_rev, depth, scratch_pool)); > >  svn_pool_destroy(scratch_pool); >  return SVN_NO_ERROR; > > Modified: trunk/subversion/libsvn_wc/wc_db.c > URL: http://svn.collab.net/viewvc/svn/trunk/subversion/libsvn_wc/wc_db.c?pathrev=36758&r1=36757&r2=36758 > ============================================================================== > --- trunk/subversion/libsvn_wc/wc_db.c  Tue Mar 24 09:59:55 2009     (r36757) > +++ trunk/subversion/libsvn_wc/wc_db.c  Tue Mar 24 14:09:14 2009     (r36758) > @@ -166,7 +166,8 @@ enum statement_keys { >  STMT_UPDATE_ACTUAL_PROPS, >  STMT_SELECT_ALL_PROPS, >  STMT_SELECT_PRISTINE_PROPS, > -  STMT_INSERT_LOCK > +  STMT_INSERT_LOCK, > +  STMT_INSERT_WCROOT >  }; > >  static const char * const statements[] = { > @@ -209,9 +210,9 @@ static const char * const statements[] = >  "insert or replace into base_node (" >  "  wc_id, local_relpath, repos_id, repos_relpath, parent_relpath, presence, " >  "  kind, revnum, properties, changed_rev, changed_date, changed_author, " > -  "  depth, checksum, translated_size, symlink_target) " > +  "  depth, checksum, translated_size, symlink_target, incomplete_children) " >  "values (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9, ?10, ?11, ?12, ?13, ?14, " > -  "     ?15, ?16);", > +  "     ?15, ?16, ?17);", > >  "insert or ignore into base_node (" >  "  wc_id, local_relpath, parent_relpath, presence, kind, revnum) " > @@ -258,6 +259,9 @@ static const char * const statements[] = >   " lock_date)" >  "values (?1, ?2, ?3, ?4, ?5, ?6);", > > +  "insert into wcroot (local_abspath) " > +  "values (?1);", > + >  NULL >  }; > > @@ -289,6 +293,7 @@ typedef struct { >  const char *target; > >  /* for inserting absent nodes */ > +  svn_boolean_t incomplete_children; > >  /* for temporary allocations */ >  apr_pool_t *scratch_pool; > @@ -1102,6 +1107,8 @@ insert_base_node(void *baton, svn_sqlite >     SVN_ERR(svn_sqlite__bind_text(stmt, 16, pibb->target)); >   } > > +  SVN_ERR(svn_sqlite__bind_int64(stmt, 17, pibb->incomplete_children)); > + >  SVN_ERR(svn_sqlite__insert(NULL, stmt)); > >  if (pibb->kind == svn_wc__db_kind_dir && pibb->children) > @@ -1304,6 +1311,62 @@ svn_wc__db_close(svn_wc__db_t *db, > > >  svn_error_t * > +svn_wc__db_init(const char *local_abspath, > +         const char *repos_relpath, > +         const char *repos_root_url, > +         const char *repos_uuid, > +         svn_revnum_t initial_rev, > +         svn_depth_t depth, > +         apr_pool_t *scratch_pool) > +{ > +  svn_sqlite__db_t *sdb; > +  svn_sqlite__stmt_t *stmt; > +  apr_int64_t repos_id; > +  apr_int64_t wc_id; > +  insert_base_baton_t ibb; > + > +  SVN_ERR(svn_sqlite__open(&sdb, > +              svn_wc__adm_child(local_abspath, "wc.db", > +                       scratch_pool), > +              svn_sqlite__mode_rwcreate, statements, > +              SVN_WC__VERSION_EXPERIMENTAL, upgrade_sql, > +              scratch_pool, scratch_pool)); > + > +  /* Insert the repository. */ > +  SVN_ERR(create_repos_id(&repos_id, repos_root_url, repos_uuid, sdb, > +              scratch_pool)); > + > +  /* Insert the wcroot. */ > +  /* ### Right now, this just assumes wc metadata is being stored locally. */ > +  SVN_ERR(svn_sqlite__get_statement(&stmt, sdb, STMT_INSERT_WCROOT)); > +  SVN_ERR(svn_sqlite__insert(&wc_id, stmt)); > + > +  ibb.status = svn_wc__db_status_normal; > +  ibb.kind = svn_wc__db_kind_dir; > +  ibb.wc_id = wc_id; > +  ibb.local_relpath = ""; > +  ibb.repos_id = repos_id; > +  ibb.repos_relpath = repos_relpath; > +  ibb.revision = initial_rev; > + > +  ibb.props = NULL; > +  ibb.changed_rev = SVN_INVALID_REVNUM; > +  ibb.changed_date = 0; > +  ibb.changed_author = NULL; > + > +  ibb.children = NULL; > +  ibb.incomplete_children = TRUE; > +  ibb.depth = depth; > + > +  ibb.scratch_pool = scratch_pool; > + > +  SVN_ERR(insert_base_node(&ibb, sdb)); > + > +  return svn_sqlite__close(sdb); > +} > + > + > +svn_error_t * >  svn_wc__db_base_add_directory(svn_wc__db_t *db, >                const char *local_abspath, >                const char *repos_relpath, > > Modified: trunk/subversion/libsvn_wc/wc_db.h > URL: http://svn.collab.net/viewvc/svn/trunk/subversion/libsvn_wc/wc_db.h?pathrev=36758&r1=36757&r2=36758 > ============================================================================== > --- trunk/subversion/libsvn_wc/wc_db.h  Tue Mar 24 09:59:55 2009     (r36757) > +++ trunk/subversion/libsvn_wc/wc_db.h  Tue Mar 24 14:09:14 2009     (r36758) > @@ -274,6 +274,21 @@ svn_error_t * >  svn_wc__db_close(svn_wc__db_t *db, >          apr_pool_t *scratch_pool); > > + > +/** > + * Initialize the DB for LOCAL_ABSPATH, which should be a working copy path. > + * Use SCRATCH_POOL for temporary allocations. > + */ > +svn_error_t * > +svn_wc__db_init(const char *local_abspath, > +         const char *repos_relpath, > +         const char *repos_root_url, > +         const char *repos_uuid, > +         svn_revnum_t initial_rev, > +         svn_depth_t depth, > +         apr_pool_t *scratch_pool); > + > + >  /** @} */ > >  /** > > ------------------------------------------------------ > http://subversion.tigris.org/ds/viewMessage.do?dsForumId=495&dsMessageId=1406091 > ------------------------------------------------------ http://subversion.tigris.org/ds/viewMessage.do?dsForumId=462&dsMessageId=2126603Received on 2009-05-09 02:18:50 CEST |
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.