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/08/10 19:03:37 UTC

svn commit: r984122 [24/40] - in /subversion/branches/ignore-mergeinfo: ./ build/ build/ac-macros/ build/generator/ build/generator/swig/ build/generator/templates/ build/generator/util/ build/hudson/ build/hudson/jobs/ build/hudson/jobs/subversion-1.6...

Modified: subversion/branches/ignore-mergeinfo/subversion/libsvn_wc/diff.c
URL: http://svn.apache.org/viewvc/subversion/branches/ignore-mergeinfo/subversion/libsvn_wc/diff.c?rev=984122&r1=984121&r2=984122&view=diff
==============================================================================
--- subversion/branches/ignore-mergeinfo/subversion/libsvn_wc/diff.c (original)
+++ subversion/branches/ignore-mergeinfo/subversion/libsvn_wc/diff.c Tue Aug 10 17:03:06 2010
@@ -3,10 +3,10 @@
  *           repository.
  *
  * ====================================================================
- *    Licensed to the Subversion Corporation (SVN Corp.) under one
+ *    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 SVN Corp. licenses this file
+ *    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
@@ -311,7 +311,7 @@ make_edit_baton(struct edit_baton **edit
   eb->reverse_order = reverse_order;
   eb->changelist_hash = changelist_hash;
   eb->cancel_func = cancel_func;
-  eb->cancel_baton = cancel_baton;  
+  eb->cancel_baton = cancel_baton;
   eb->pool = pool;
 
   *edit_baton = eb;
@@ -496,7 +496,7 @@ get_working_mimetype(const char **mimety
     workingprops = &props;
 
   if (*workingprops == NULL)
-    SVN_ERR(svn_wc__load_props(NULL, workingprops, NULL, db, local_abspath,
+    SVN_ERR(svn_wc__load_props(NULL, workingprops, db, local_abspath,
                                result_pool, scratch_pool));
 
   *mimetype = get_prop_mimetype(*workingprops);
@@ -607,6 +607,20 @@ file_diff(struct dir_baton *db,
     if (kind == svn_node_none)
       SVN_ERR(svn_wc__text_revert_path(&textbase, eb->db, local_abspath,
                                        pool));
+
+    /* If there is no revert base to diff either, don't attempt to diff it.
+     * ### This is a band-aid.
+     * ### In WC-NG, files added within a copied subtree are marked "copied",
+     * ### which will cause the code below to end up calling
+     * ### eb->callbacks->file_changed() with a non-existent text-base.
+     * ### Not sure how to properly tell apart a file added within a copied
+     * ### subtree from a copied file. But eventually we'll have to get the
+     * ### base text from the pristine store anyway and use tempfiles (or
+     * ### streams, hopefully) for diffing, so all this horrible statting
+     * ### the disk for text bases, and this hack, will just go away. */
+    SVN_ERR(svn_io_check_path(textbase, &kind, pool));
+    if (kind == svn_node_none)
+      textbase = NULL;
   }
 
   SVN_ERR(get_empty_file(eb, &empty_file));
@@ -1038,7 +1052,7 @@ report_wc_directory_as_added(struct dir_
         SVN_ERR(svn_wc__internal_propdiff(NULL, &wcprops, eb->db, dir_abspath,
                                           pool, pool));
       else
-        SVN_ERR(svn_wc__load_props(NULL, &wcprops, NULL, eb->db, dir_abspath,
+        SVN_ERR(svn_wc__load_props(NULL, &wcprops, eb->db, dir_abspath,
                                    pool, pool));
 
       SVN_ERR(svn_prop_diffs(&propchanges, wcprops, emptyprops, pool));
@@ -1120,7 +1134,7 @@ report_wc_directory_as_added(struct dir_
           break;
         }
     }
-  
+
   svn_pool_destroy(iterpool);
 
   return SVN_NO_ERROR;
@@ -1325,7 +1339,7 @@ close_directory(void *dir_baton,
             {
               apr_hash_t *base_props, *repos_props;
 
-              SVN_ERR(svn_wc__load_props(NULL, &originalprops, NULL,
+              SVN_ERR(svn_wc__load_props(NULL, &originalprops,
                                          eb->db, db->local_abspath, pool, pool));
 
               /* Load the BASE and repository directory properties. */
@@ -1448,17 +1462,24 @@ apply_textdelta(void *file_baton,
   svn_stream_t *source;
   svn_stream_t *temp_stream;
   svn_error_t *err;
+  svn_boolean_t found;
 
   err = svn_wc__db_read_info(&status, NULL, NULL, NULL, NULL, NULL, NULL,
                              NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
                              NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
                              NULL, eb->db, fb->local_abspath, pool, pool);
   if (err && err->apr_err == SVN_ERR_WC_PATH_NOT_FOUND)
-    svn_error_clear(err);
+    {
+      svn_error_clear(err);
+      found = FALSE;
+    }
   else
-    SVN_ERR(err);
+    {
+      SVN_ERR(err);
+      found = TRUE;
+    }
 
-  if (status == svn_wc__db_status_added)
+  if (found && status == svn_wc__db_status_added)
     SVN_ERR(svn_wc__db_scan_addition(&status, NULL, NULL, NULL, NULL, NULL,
                                      NULL, NULL, NULL, eb->db,
                                      fb->local_abspath, pool, pool));
@@ -1467,8 +1488,8 @@ apply_textdelta(void *file_baton,
 
   /* If the node is added-with-history, then this is not actually
      an add, but a modification. */
-  if (status == svn_wc__db_status_copied ||
-      status == svn_wc__db_status_moved_here)
+  if (found && (status == svn_wc__db_status_copied ||
+                status == svn_wc__db_status_moved_here))
     fb->added = FALSE;
 
   if (fb->added)
@@ -1540,14 +1561,13 @@ close_file(void *file_baton,
                              NULL, eb->db, fb->local_abspath, pool, pool);
   if (err && err->apr_err == SVN_ERR_WC_PATH_NOT_FOUND)
     svn_error_clear(err);
-  else
-    SVN_ERR(err);
-
-  if (status == svn_wc__db_status_added)
+  else if (err)
+    return err;
+  else if (status == svn_wc__db_status_added)
     SVN_ERR(svn_wc__db_scan_addition(&status, NULL, NULL, NULL, NULL, NULL,
                                      NULL, NULL, NULL, eb->db,
                                      fb->local_abspath, pool, pool));
-    
+
   SVN_ERR(get_empty_file(eb, &empty_file));
 
   /* Load the BASE and repository file properties. */
@@ -1618,7 +1638,7 @@ close_file(void *file_baton,
                                      apr_hash_make(pool),
                                      eb->callback_baton,
                                      pool);
-    
+
   /* If we didn't see any content changes between the BASE and repository
      versions (i.e. we only saw property changes), then, if we're diffing
      against WORKING, we also need to check whether there are any local
@@ -1650,7 +1670,7 @@ close_file(void *file_baton,
     }
   else
     {
-      SVN_ERR(svn_wc__load_props(NULL, &originalprops, NULL, eb->db,
+      SVN_ERR(svn_wc__load_props(NULL, &originalprops, eb->db,
                                  fb->local_abspath, pool, pool));
 
       /* We have the repository properties in repos_props, and the
@@ -1863,7 +1883,7 @@ svn_wc_diff6(svn_wc_context_t *wc_ctx,
   SVN_ERR(make_edit_baton(&eb,
                           wc_ctx->db,
                           anchor_path,
-                          target, 
+                          target,
                           callbacks, callback_baton,
                           depth, ignore_ancestry, show_copies_as_adds,
                           FALSE, FALSE, changelists,

Modified: subversion/branches/ignore-mergeinfo/subversion/libsvn_wc/entries.c
URL: http://svn.apache.org/viewvc/subversion/branches/ignore-mergeinfo/subversion/libsvn_wc/entries.c?rev=984122&r1=984121&r2=984122&view=diff
==============================================================================
--- subversion/branches/ignore-mergeinfo/subversion/libsvn_wc/entries.c (original)
+++ subversion/branches/ignore-mergeinfo/subversion/libsvn_wc/entries.c Tue Aug 10 17:03:06 2010
@@ -2,10 +2,10 @@
  * entries.c :  manipulating the administrative `entries' file.
  *
  * ====================================================================
- *    Licensed to the Subversion Corporation (SVN Corp.) under one
+ *    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 SVN Corp. licenses this file
+ *    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
@@ -48,7 +48,6 @@
 #include "private/svn_wc_private.h"
 #include "private/svn_sqlite.h"
 #include "private/svn_skel.h"
-#include "private/svn_debug.h"
 
 #define MAYBE_ALLOC(x,p) ((x) ? (x) : apr_pcalloc((p), sizeof(*(x))))
 
@@ -195,24 +194,6 @@ fetch_wc_id(apr_int64_t *wc_id, svn_sqli
 }
 
 
-static svn_error_t *
-determine_keep_local(svn_boolean_t *keep_local,
-                     svn_sqlite__db_t *sdb,
-                     apr_int64_t wc_id,
-                     const char *local_relpath)
-{
-  svn_sqlite__stmt_t *stmt;
-
-  SVN_ERR(svn_sqlite__get_statement(&stmt, sdb, STMT_SELECT_KEEP_LOCAL_FLAG));
-  SVN_ERR(svn_sqlite__bindf(stmt, "is", wc_id, local_relpath));
-  SVN_ERR(svn_sqlite__step_row(stmt));
-
-  *keep_local = svn_sqlite__column_boolean(stmt, 0);
-
-  return svn_error_return(svn_sqlite__reset(stmt));
-}
-
-
 /* Hit the database to check the file external information for the given
    entry.  The entry will be modified in place. */
 static svn_error_t *
@@ -522,7 +503,7 @@ read_entries_new(apr_hash_t **result_ent
 
   entries = apr_hash_make(result_pool);
 
-  /* ### need database to determine: incomplete, keep_local, ACTUAL info.  */
+  /* ### need database to determine: incomplete, ACTUAL info.  */
   SVN_ERR(svn_wc__db_temp_get_sdb(&sdb, db, local_abspath, FALSE,
                                   handle_pool, iterpool));
 
@@ -608,7 +589,7 @@ read_entries_new(apr_hash_t **result_ent
               const apr_array_header_t *child_conflicts;
               const char *child_name;
               const char *child_abspath;
-              
+
               child_name = APR_ARRAY_IDX(conflict_victims, k, const char *);
               child_abspath = svn_dirent_join(local_abspath, child_name,
                                                              iterpool);
@@ -701,7 +682,7 @@ read_entries_new(apr_hash_t **result_ent
              stub when the directory is recorded as deleted in the directory
              itself. (This last value is the status that brought us in this
              if block).
-             
+
              This is safe because we will only write this flag in the
              directory itself (see mark_deleted() in adm_ops.c), and also
              because we will never use keep_local in the final version of
@@ -710,8 +691,9 @@ read_entries_new(apr_hash_t **result_ent
              directories after the delete operation are always kept locally.
              */
           if (*entry->name == '\0')
-            SVN_ERR(determine_keep_local(&entry->keep_local, sdb,
-                                         wc_id, entry->name));
+            SVN_ERR(svn_wc__db_temp_determine_keep_local(&entry->keep_local,
+                                                         db, entry_abspath,
+                                                         scratch_pool));
         }
       else if (status == svn_wc__db_status_added
                || status == svn_wc__db_status_obstructed_add)
@@ -1569,29 +1551,25 @@ svn_wc__set_depth(svn_wc__db_t *db,
 
       if (entry != NULL)
         {
+          /* The entries in the parent stub only store excluded vs infinity. */
           entry->depth = (depth == svn_depth_exclude) ? svn_depth_exclude
                                                       : svn_depth_infinity;
         }
     }
 
-  /* ### setting depth exclude on a wcroot breaks svn_wc_crop() */
-  if (depth != svn_depth_exclude)
+   /* Fetch the entries for the directory, and write our depth there. */
+  adm_access = svn_wc__adm_retrieve_internal2(db, local_dir_abspath,
+                                              scratch_pool);
+  if (adm_access != NULL)
     {
-       /* We aren't excluded, so fetch the entries for the directory, and write
-        our depth there. */
-      adm_access = svn_wc__adm_retrieve_internal2(db, local_dir_abspath,
-                                                  scratch_pool);
-      if (adm_access != NULL)
-        {
-          apr_hash_t *entries = svn_wc__adm_access_entries(adm_access);
+      apr_hash_t *entries = svn_wc__adm_access_entries(adm_access);
 
-          entry = (entries != NULL)
-                           ? apr_hash_get(entries, "", APR_HASH_KEY_STRING)
-                           : NULL;
+      entry = (entries != NULL)
+                       ? apr_hash_get(entries, "", APR_HASH_KEY_STRING)
+                       : NULL;
 
-          if (entry != NULL)
-            entry->depth = depth;
-        }
+      if (entry != NULL)
+        entry->depth = depth;
     }
 
   return svn_error_return(svn_wc__db_temp_op_set_dir_depth(db,
@@ -1666,16 +1644,8 @@ insert_base_node(svn_sqlite__db_t *sdb,
   SVN_ERR(svn_sqlite__bind_int64(stmt, 15, base_node->last_mod_time));
 
   if (base_node->properties)
-    {
-      svn_skel_t *skel;
-      svn_stringbuf_t *properties;
-
-      SVN_ERR(svn_skel__unparse_proplist(&skel, base_node->properties,
-                                         scratch_pool));
-      properties = svn_skel__unparse(skel, scratch_pool);
-      SVN_ERR(svn_sqlite__bind_blob(stmt, 16, properties->data,
-                                    properties->len));
-    }
+    SVN_ERR(svn_sqlite__bind_properties(stmt, 16, base_node->properties,
+                                        scratch_pool));
 
   /* Execute and reset the insert clause. */
   return svn_error_return(svn_sqlite__insert(NULL, stmt));
@@ -1687,8 +1657,6 @@ insert_working_node(svn_sqlite__db_t *sd
                     apr_pool_t *scratch_pool)
 {
   svn_sqlite__stmt_t *stmt;
-  svn_stringbuf_t *properties;
-  svn_skel_t *skel;
 
   SVN_ERR(svn_sqlite__get_statement(&stmt, sdb, STMT_INSERT_WORKING_NODE));
 
@@ -1753,13 +1721,8 @@ insert_working_node(svn_sqlite__db_t *sd
   SVN_ERR(svn_sqlite__bind_int64(stmt, 17, working_node->last_mod_time));
 
   if (working_node->properties)
-    SVN_ERR(svn_skel__unparse_proplist(&skel, working_node->properties,
-                                       scratch_pool));
-  else
-    skel = svn_skel__make_empty_list(scratch_pool);
-
-  properties = svn_skel__unparse(skel, scratch_pool);
-  SVN_ERR(svn_sqlite__bind_blob(stmt, 18, properties->data, properties->len));
+    SVN_ERR(svn_sqlite__bind_properties(stmt, 18, working_node->properties,
+                                        scratch_pool));
 
   SVN_ERR(svn_sqlite__bind_int64(stmt, 19, working_node->keep_local));
 
@@ -1781,16 +1744,8 @@ insert_actual_node(svn_sqlite__db_t *sdb
   SVN_ERR(svn_sqlite__bind_text(stmt, 3, actual_node->parent_relpath));
 
   if (actual_node->properties)
-    {
-      svn_skel_t *skel;
-      svn_stringbuf_t *properties;
-
-      SVN_ERR(svn_skel__unparse_proplist(&skel, actual_node->properties,
-                                         scratch_pool));
-      properties = svn_skel__unparse(skel, scratch_pool);
-      SVN_ERR(svn_sqlite__bind_blob(stmt, 4, properties->data,
-                                    properties->len));
-    }
+    SVN_ERR(svn_sqlite__bind_properties(stmt, 4, actual_node->properties,
+                                        scratch_pool));
 
   if (actual_node->conflict_old)
     {
@@ -2116,7 +2071,7 @@ write_entry(svn_wc__db_t *db,
                                                   &entry->file_external_peg_rev,
                                                   &entry->file_external_rev,
                                                   scratch_pool));
-       
+
           SVN_ERR(svn_sqlite__get_statement(&stmt, sdb,
                                             STMT_UPDATE_FILE_EXTERNAL));
           SVN_ERR(svn_sqlite__bindf(stmt, "iss",
@@ -2168,7 +2123,7 @@ write_entry(svn_wc__db_t *db,
               /* If the entry is part of a COPIED (not REPLACED) subtree,
                  then the deletion is referring to the WORKING node, not
                  the BASE node. */
-              if (entry->copied 
+              if (entry->copied
                   || (this_dir->copied
                       && this_dir->schedule == svn_wc_schedule_add))
                 working_node->presence = svn_wc__db_status_not_present;
@@ -2391,10 +2346,10 @@ write_one_entry_cb(void *baton,
   SVN_ERR(svn_sqlite__step(&got_row, stmt));
   if (got_row)
     {
-      base_props = svn_sqlite__column_blob(stmt, 15, &base_prop_len,
+      base_props = svn_sqlite__column_blob(stmt, 13, &base_prop_len,
                                            scratch_pool);
 
-      err = svn_sqlite__column_checksum(&base_checksum, stmt, 7, scratch_pool);
+      err = svn_sqlite__column_checksum(&base_checksum, stmt, 5, scratch_pool);
       SVN_ERR(svn_error_compose_create(err, svn_sqlite__reset(stmt)));
     }
   else
@@ -3097,7 +3052,7 @@ svn_wc__tweak_entry(svn_wc__db_t *db,
   const svn_wc_entry_t *entry;
   svn_wc_entry_t tmp_entry;
   apr_uint64_t modify_flags = 0;
- 
+
   SVN_ERR(svn_wc__get_entry(&entry, db, local_abspath, FALSE, kind,
                             parent_stub, scratch_pool, scratch_pool));
 
@@ -3148,44 +3103,8 @@ svn_wc__tweak_entry(svn_wc__db_t *db,
 }
 
 
-
-
-svn_error_t *
-svn_wc__entries_init(const char *path,
-                     const char *uuid,
-                     const char *url,
-                     const char *repos_root,
-                     svn_revnum_t initial_rev,
-                     svn_depth_t depth,
-                     apr_pool_t *pool)
-{
-  apr_pool_t *scratch_pool = svn_pool_create(pool);
-  const char *abspath;
-  const char *repos_relpath;
-
-  SVN_ERR_ASSERT(! repos_root || svn_uri_is_ancestor(repos_root, url));
-  SVN_ERR_ASSERT(depth == svn_depth_empty
-                 || depth == svn_depth_files
-                 || depth == svn_depth_immediates
-                 || depth == svn_depth_infinity);
-
-  /* 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;
-}
-
-
-/*--------------------------------------------------------------- */
-
 /*** Generic Entry Walker */
 
-
 /* A recursive entry-walker, helper for svn_wc_walk_entries3().
  *
  * For this directory (DIRPATH, ADM_ACCESS), call the "found_entry" callback
@@ -3294,7 +3213,7 @@ walker_helper(const char *dirpath,
 
           entry_access = svn_wc__adm_retrieve_internal2(db, entry_abspath,
                                                         subpool);
-          
+
           if (entry_access)
             SVN_ERR(walker_helper(entrypath, entry_access,
                                   walk_callbacks, walk_baton,

Modified: subversion/branches/ignore-mergeinfo/subversion/libsvn_wc/entries.h
URL: http://svn.apache.org/viewvc/subversion/branches/ignore-mergeinfo/subversion/libsvn_wc/entries.h?rev=984122&r1=984121&r2=984122&view=diff
==============================================================================
--- subversion/branches/ignore-mergeinfo/subversion/libsvn_wc/entries.h (original)
+++ subversion/branches/ignore-mergeinfo/subversion/libsvn_wc/entries.h Tue Aug 10 17:03:06 2010
@@ -2,10 +2,10 @@
  * entries.h :  manipulating entries
  *
  * ====================================================================
- *    Licensed to the Subversion Corporation (SVN Corp.) under one
+ *    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 SVN Corp. licenses this file
+ *    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
@@ -77,26 +77,6 @@ extern "C" {
 #define SVN_WC__ENTRY_VALUE_REPLACE    "replace"
 
 
-
-/* Initialize an entries file based on URL at INITIAL_REV, in the adm
-   area for PATH.  The adm area must not already have an entries
-   file.  UUID is the repository UUID, and may be NULL.  REPOS is the
-   repository root URL and, if not NULL, must be a prefix of URL.
-   DEPTH is the initial depth of the working copy, it must be a
-   definite depth, not svn_depth_unknown.
-
-   If initial rev is valid and non-zero, then mark the 'this_dir'
-   entry as being incomplete.
-*/
-svn_error_t *svn_wc__entries_init(const char *path,
-                                  const char *uuid,
-                                  const char *url,
-                                  const char *repos,
-                                  svn_revnum_t initial_rev,
-                                  svn_depth_t depth,
-                                  apr_pool_t *pool);
-
-
 /* Set *NEW_ENTRY to a new entry, taking attributes from ATTS, whose
    keys and values are both char *.  Allocate the entry and copy
    attributes into POOL as needed.
@@ -291,7 +271,7 @@ svn_wc__set_depth(svn_wc__db_t *db,
 /* For internal use by entries.c to read/write old-format working copies. */
 svn_error_t *
 svn_wc__read_entries_old(apr_hash_t **entries,
-                         const char *path,
+                         const char *dir_abspath,
                          apr_pool_t *result_pool,
                          apr_pool_t *scratch_pool);
 

Modified: subversion/branches/ignore-mergeinfo/subversion/libsvn_wc/lock.c
URL: http://svn.apache.org/viewvc/subversion/branches/ignore-mergeinfo/subversion/libsvn_wc/lock.c?rev=984122&r1=984121&r2=984122&view=diff
==============================================================================
--- subversion/branches/ignore-mergeinfo/subversion/libsvn_wc/lock.c (original)
+++ subversion/branches/ignore-mergeinfo/subversion/libsvn_wc/lock.c Tue Aug 10 17:03:06 2010
@@ -2,10 +2,10 @@
  * lock.c:  routines for locking working copy subdirectories.
  *
  * ====================================================================
- *    Licensed to the Subversion Corporation (SVN Corp.) under one
+ *    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 SVN Corp. licenses this file
+ *    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
@@ -41,7 +41,6 @@
 
 #include "svn_private_config.h"
 #include "private/svn_wc_private.h"
-#include "private/svn_debug.h"
 
 
 
@@ -80,6 +79,10 @@ struct svn_wc_adm_access_t
 static const svn_wc_adm_access_t missing;
 #define IS_MISSING(lock) ((lock) == &missing)
 
+/* ### hack for now. future functionality coming in a future revision.  */
+#define svn_wc__db_is_closed(db) FALSE
+
+
 
 /* ### these functions are here for forward references. generally, they're
    ### here to avoid the code churn from moving the definitions.  */
@@ -91,6 +94,17 @@ do_close(svn_wc_adm_access_t *adm_access
 static svn_error_t *
 add_to_shared(svn_wc_adm_access_t *lock, apr_pool_t *scratch_pool);
 
+static svn_error_t *
+close_single(svn_wc_adm_access_t *adm_access,
+             svn_boolean_t preserve_lock,
+             apr_pool_t *scratch_pool);
+
+static svn_error_t *
+alloc_db(svn_wc__db_t **db,
+         svn_config_t *config,
+         apr_pool_t *result_pool,
+         apr_pool_t *scratch_pool);
+
 
 svn_error_t *
 svn_wc__internal_check_wc(int *wc_format,
@@ -145,12 +159,13 @@ svn_wc_check_wc2(int *wc_format,
 }
 
 
-/* An APR pool cleanup handler.  This handles access batons that have not
-   been closed when their pool gets destroyed.  The physical locks
-   associated with such batons remain in the working copy if they are
-   protecting a log file. */
+/* Cleanup for a locked access baton.
+
+   This handles closing access batons when their pool gets destroyed.
+   The physical locks associated with such batons remain in the working
+   copy if they are protecting work items in the workqueue.  */
 static apr_status_t
-pool_cleanup(void *p)
+pool_cleanup_locked(void *p)
 {
   svn_wc_adm_access_t *lock = p;
   apr_uint64_t id;
@@ -158,15 +173,59 @@ pool_cleanup(void *p)
   svn_error_t *err;
 
   if (lock->closed)
-    return SVN_NO_ERROR;
+    return APR_SUCCESS;
+
+  /* If the DB is closed, then we have a bunch of extra work to do.  */
+  if (svn_wc__db_is_closed(lock->db))
+    {
+      apr_pool_t *scratch_pool;
+      svn_wc__db_t *db;
+
+      lock->closed = TRUE;
+
+      /* If there is no ADM area, then we definitely have no work items
+         or physical locks to worry about. Bail out.  */
+      if (!svn_wc__adm_area_exists(lock, lock->pool))
+        return APR_SUCCESS;
+
+      /* Creating a subpool is safe within a pool cleanup, as long as
+         we're absolutely sure to destroy it before we exit this function.
+
+         We avoid using LOCK->POOL to keep the following functions from
+         hanging cleanups or subpools from it. (the cleanups *might* get
+         run, but the subpools will NOT be destroyed)  */
+      scratch_pool = svn_pool_create(lock->pool);
+
+      err = alloc_db(&db, NULL /* config */, scratch_pool, scratch_pool);
+      if (!err)
+        {
+          err = svn_wc__db_wq_fetch(&id, &work_item, db, lock->abspath,
+                                    scratch_pool, scratch_pool);
+          if (!err && work_item == NULL)
+            {
+              /* There is no remaining work, so we're good to remove any
+                 potential "physical" lock.  */
+              err = svn_wc__db_wclock_remove(db, lock->abspath, scratch_pool);
+            }
+        }
+      svn_error_clear(err);
+
+      /* Closes the DB, too.  */
+      svn_pool_destroy(scratch_pool);
+
+      return APR_SUCCESS;
+    }
 
   /* ### should we create an API that just looks, but doesn't return?  */
   err = svn_wc__db_wq_fetch(&id, &work_item, lock->db, lock->abspath,
                             lock->pool, lock->pool);
+
+  /* Close just this access baton. The pool cleanup will close the rest.  */
   if (!err)
-    err = do_close(lock, work_item != NULL /* preserve_lock */, lock->pool);
+    err = close_single(lock,
+                       work_item != NULL /* preserve_lock */,
+                       lock->pool);
 
-  /* ### Is this the correct way to handle the error? */
   if (err)
     {
       apr_status_t apr_err = err->apr_err;
@@ -177,13 +236,48 @@ pool_cleanup(void *p)
   return APR_SUCCESS;
 }
 
+
+/* Cleanup for a readonly access baton.  */
+static apr_status_t
+pool_cleanup_readonly(void *data)
+{
+  svn_wc_adm_access_t *lock = data;
+  svn_error_t *err;
+
+  if (lock->closed)
+    return APR_SUCCESS;
+
+  /* If the DB is closed, then we have nothing to do. There are no
+     "physical" locks to remove, and we don't care whether this baton
+     is registered with the DB.  */
+  if (svn_wc__db_is_closed(lock->db))
+    return APR_SUCCESS;
+
+  /* Close this baton. No lock to preserve. Since this is part of the
+     pool cleanup, we don't need to close children -- the cleanup process
+     will close all children.  */
+  err = close_single(lock, FALSE /* preserve_lock */, lock->pool);
+  if (err)
+    {
+      apr_status_t result = err->apr_err;
+      svn_error_clear(err);
+      return result;
+    }
+
+  return APR_SUCCESS;
+}
+
+
 /* An APR pool cleanup handler.  This is a child handler, it removes the
    main pool handler. */
 static apr_status_t
 pool_cleanup_child(void *p)
 {
   svn_wc_adm_access_t *lock = p;
-  apr_pool_cleanup_kill(lock->pool, lock, pool_cleanup);
+
+  apr_pool_cleanup_kill(lock->pool, lock, pool_cleanup_locked);
+  apr_pool_cleanup_kill(lock->pool, lock, pool_cleanup_readonly);
+
   return APR_SUCCESS;
 }
 
@@ -216,7 +310,7 @@ adm_access_alloc(svn_wc_adm_access_t **a
 
   if (write_lock)
     {
-      SVN_ERR(svn_wc__db_wclock_set(db, lock->abspath, scratch_pool));
+      SVN_ERR(svn_wc__db_wclock_set(db, lock->abspath, 0, scratch_pool));
       SVN_ERR(svn_wc__db_temp_mark_locked(db, lock->abspath, scratch_pool));
     }
 
@@ -234,7 +328,13 @@ adm_access_alloc(svn_wc_adm_access_t **a
      when the cleanup handler runs.  If the apr_xlate_t cleanup handler
      were to run *before* the access baton cleanup handler, then the access
      baton's handler won't work. */
-  apr_pool_cleanup_register(lock->pool, lock, pool_cleanup,
+
+  /* Register an appropriate cleanup handler, based on the whether this
+     access baton is locked or not.  */
+  apr_pool_cleanup_register(lock->pool, lock,
+                            write_lock
+                              ? pool_cleanup_locked
+                              : pool_cleanup_readonly,
                             pool_cleanup_child);
 
   return SVN_NO_ERROR;
@@ -612,7 +712,7 @@ open_all(svn_wc_adm_access_t **adm_acces
         }
     }
 
-  return err;
+  return svn_error_return(err);
 }
 
 
@@ -660,8 +760,9 @@ svn_wc_adm_open3(svn_wc_adm_access_t **a
       db_provided = FALSE;
     }
 
-  return open_all(adm_access, path, db, db_provided,
-                  write_lock, levels_to_lock, cancel_func, cancel_baton, pool);
+  return svn_error_return(open_all(adm_access, path, db, db_provided,
+                                   write_lock, levels_to_lock,
+                                   cancel_func, cancel_baton, pool));
 }
 
 
@@ -757,106 +858,84 @@ svn_wc_adm_retrieve(svn_wc_adm_access_t 
                     const char *path,
                     apr_pool_t *pool)
 {
-  if (strcmp(associated->path, path) == 0)
-    {
-      *adm_access = associated;
-    }
-  else
-    {
-      const char *abspath;
-
-      SVN_ERR(svn_dirent_get_absolute(&abspath, path, pool));
+  const char *local_abspath;
+  svn_wc__db_kind_t kind = svn_wc__db_kind_unknown;
+  svn_node_kind_t wckind;
+  svn_error_t *err;
 
-      *adm_access = svn_wc__adm_retrieve_internal2(associated->db, abspath,
-                                                   pool);
+  SVN_ERR(svn_dirent_get_absolute(&local_abspath, path, pool));
 
-      /* Relative paths can play stupid games with the lookup, and we might
-         try to return the wrong baton. Look for that case, and zap it.
+  if (strcmp(associated->path, path) == 0)
+    *adm_access = associated;
+  else
+    *adm_access = svn_wc__adm_retrieve_internal2(associated->db, local_abspath,
+                                                 pool);
 
-         The specific case observed happened during "svn status .. -u -v".
-         svn_wc_status2() would do dirname("..") returning "". When that
-         came into this function, we'd map it to an absolute path and find
-         it in the DB, then return it. The (apparently) *desired* behavior
-         is to not find "" in the set of batons.
-
-         Sigh.  */
-      if (*adm_access != NULL
-          && strcmp(path, (*adm_access)->path) != 0)
-        *adm_access = NULL;
-    }
+  /* We found what we're looking for, so bail. */
+  if (*adm_access)
+    return SVN_NO_ERROR;
 
   /* Most of the code expects access batons to exist, so returning an error
      generally makes the calling code simpler as it doesn't need to check
      for NULL batons. */
-  if (! *adm_access)
-    {
-      /* We are going to send a SVN_ERR_WC_NOT_LOCKED, but let's provide
-         a bit more information to our caller */
+  /* We are going to send a SVN_ERR_WC_NOT_LOCKED, but let's provide
+     a bit more information to our caller */
 
-      const char *local_abspath;
-      svn_wc__db_kind_t kind = svn_wc__db_kind_unknown;
-      svn_node_kind_t wckind;
-      svn_error_t *err;
+  err = svn_io_check_path(path, &wckind, pool);
 
-      err = svn_io_check_path(path, &wckind, pool);
+  /* If we can't check the path, we can't make a good error message.  */
+  if (err)
+    {
+      return svn_error_createf(SVN_ERR_WC_NOT_LOCKED, err,
+                               _("Unable to check path existence for '%s'"),
+                               svn_dirent_local_style(path, pool));
+    }
+
+  if (associated)
+    {
+      err = svn_wc__db_read_kind(&kind, svn_wc__adm_get_db(associated),
+                                 local_abspath, TRUE, pool);
 
-      /* If we can't check the path, we can't make a good error
-         message.  */
       if (err)
         {
-          return svn_error_createf(SVN_ERR_WC_NOT_LOCKED, err,
-                                   _("Unable to check path existence for '%s'"),
-                                   svn_dirent_local_style(path, pool));
+          kind = svn_wc__db_kind_unknown;
+          svn_error_clear(err);
         }
+    }
 
-      SVN_ERR(svn_dirent_get_absolute(&local_abspath, path, pool));
-
-      if (associated)
-        {
-          err = svn_wc__db_read_kind(&kind, svn_wc__adm_get_db(associated),
-                                     local_abspath, TRUE, pool);
-
-          if (err)
-            {
-              kind = svn_wc__db_kind_unknown;
-              svn_error_clear(err);
-            }
-        }
+  if (kind == svn_wc__db_kind_dir && wckind == svn_node_file)
+    {
+      err = svn_error_createf(
+               SVN_ERR_WC_NOT_WORKING_COPY, NULL,
+               _("Expected '%s' to be a directory but found a file"),
+               svn_dirent_local_style(path, pool));
 
-      if (kind == svn_wc__db_kind_dir && wckind == svn_node_file)
-        {
-          err = svn_error_createf(
-                   SVN_ERR_WC_NOT_WORKING_COPY, NULL,
-                   _("Expected '%s' to be a directory but found a file"),
-                   svn_dirent_local_style(path, pool));
+      return svn_error_create(SVN_ERR_WC_NOT_LOCKED, err, err->message);
+    }
 
-          return svn_error_create(SVN_ERR_WC_NOT_LOCKED, err, err->message);
-        }
-      else if (kind != svn_wc__db_kind_dir && kind != svn_wc__db_kind_unknown)
-        {
-          err = svn_error_createf(
-                   SVN_ERR_WC_NOT_WORKING_COPY, NULL,
-                   _("Can't retrieve an access baton for non-directory '%s'"),
-                   svn_dirent_local_style(path, pool));
+  if (kind != svn_wc__db_kind_dir && kind != svn_wc__db_kind_unknown)
+    {
+      err = svn_error_createf(
+               SVN_ERR_WC_NOT_WORKING_COPY, NULL,
+               _("Can't retrieve an access baton for non-directory '%s'"),
+               svn_dirent_local_style(path, pool));
 
-          return svn_error_create(SVN_ERR_WC_NOT_LOCKED, err, err->message);
-        }
-      else if (kind == svn_wc__db_kind_unknown || wckind == svn_node_none)
-        {
-          err = svn_error_createf(SVN_ERR_WC_PATH_NOT_FOUND, NULL,
-                                  _("Directory '%s' is missing"),
-                                  svn_dirent_local_style(path, pool));
+      return svn_error_create(SVN_ERR_WC_NOT_LOCKED, err, err->message);
+    }
 
-          return svn_error_create(SVN_ERR_WC_NOT_LOCKED, err, err->message);
-        }
+  if (kind == svn_wc__db_kind_unknown || wckind == svn_node_none)
+    {
+      err = svn_error_createf(SVN_ERR_WC_PATH_NOT_FOUND, NULL,
+                              _("Directory '%s' is missing"),
+                              svn_dirent_local_style(path, pool));
 
-      /* If all else fails, return our useless generic error.  */
-      return svn_error_createf(SVN_ERR_WC_NOT_LOCKED, NULL,
-                               _("Working copy '%s' is not locked"),
-                               svn_dirent_local_style(path, pool));
+      return svn_error_create(SVN_ERR_WC_NOT_LOCKED, err, err->message);
     }
 
-  return SVN_NO_ERROR;
+  /* If all else fails, return our useless generic error.  */
+  return svn_error_createf(SVN_ERR_WC_NOT_LOCKED, NULL,
+                           _("Working copy '%s' is not locked"),
+                           svn_dirent_local_style(path, pool));
 }
 
 
@@ -1008,7 +1087,7 @@ child_is_disjoint(svn_boolean_t *disjoin
     }
 
   SVN_ERR(svn_wc__db_read_info(&parent_status, NULL, NULL,
-                               &parent_repos_relpath, &parent_repos_root, 
+                               &parent_repos_relpath, &parent_repos_root,
                                &parent_repos_uuid, NULL, NULL,
                                NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
                                NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
@@ -1136,7 +1215,7 @@ open_anchor(svn_wc_adm_access_t **anchor
             {
               /* Couldn't open the parent or the target. Bail out.  */
               svn_error_clear(p_access_err);
-              return err;
+              return svn_error_return(err);
             }
 
           if (err->apr_err != SVN_ERR_WC_NOT_WORKING_COPY)
@@ -1144,7 +1223,7 @@ open_anchor(svn_wc_adm_access_t **anchor
               if (p_access)
                 svn_error_clear(svn_wc_adm_close2(p_access, pool));
               svn_error_clear(p_access_err);
-              return err;
+              return svn_error_return(err);
             }
 
           /* This directory is not under version control. Ignore it.  */
@@ -1177,7 +1256,7 @@ open_anchor(svn_wc_adm_access_t **anchor
                 {
                   svn_error_clear(p_access_err);
                   svn_error_clear(svn_wc_adm_close2(t_access, pool));
-                  return err;
+                  return svn_error_return(err);
                 }
               p_access = NULL;
             }
@@ -1192,7 +1271,7 @@ open_anchor(svn_wc_adm_access_t **anchor
           if (t_access)
             svn_error_clear(svn_wc_adm_close2(t_access, pool));
           svn_error_clear(svn_wc_adm_close2(p_access, pool));
-          return p_access_err;
+          return svn_error_return(p_access_err);
         }
       svn_error_clear(p_access_err);
 
@@ -1209,7 +1288,7 @@ open_anchor(svn_wc_adm_access_t **anchor
           else if (err)
             {
               svn_error_clear(svn_wc_adm_close2(p_access, pool));
-              return err;
+              return svn_error_return(err);
             }
           if (obstructed && kind == svn_wc__db_kind_dir)
             {
@@ -1276,8 +1355,8 @@ svn_wc__adm_retrieve_from_context(svn_wc
 {
   SVN_ERR_ASSERT(svn_dirent_is_absolute(local_abspath));
 
-  *adm_access = svn_wc__adm_retrieve_internal2(wc_ctx->db, 
-                                               local_abspath, 
+  *adm_access = svn_wc__adm_retrieve_internal2(wc_ctx->db,
+                                               local_abspath,
                                                pool);
 
   return SVN_NO_ERROR;
@@ -1334,13 +1413,14 @@ do_close(svn_wc_adm_access_t *adm_access
         }
     }
 
-  return close_single(adm_access, preserve_lock, scratch_pool);
+  return svn_error_return(close_single(adm_access, preserve_lock,
+                                       scratch_pool));
 }
 
 svn_error_t *
 svn_wc_adm_close2(svn_wc_adm_access_t *adm_access, apr_pool_t *scratch_pool)
 {
-  return do_close(adm_access, FALSE, scratch_pool);
+  return svn_error_return(do_close(adm_access, FALSE, scratch_pool));
 }
 
 svn_boolean_t
@@ -1459,7 +1539,7 @@ svn_wc__adm_missing(svn_wc__db_t *db,
 
   /* When we switch to a single database an access baton can't be
      missing, but until then it can. But if there are no access batons we
-     would always return FALSE. 
+     would always return FALSE.
      For this case we check if an access baton could be opened
 
 */
@@ -1568,7 +1648,7 @@ svn_wc__adm_probe_in_context(svn_wc_adm_
      that we don't end up trying to lock more than we need.  */
   if (dir != path)
     levels_to_lock = 0;
-    
+
   err = svn_wc__adm_open_in_context(adm_access, wc_ctx, dir, write_lock,
                                     levels_to_lock, cancel_func, cancel_baton,
                                     pool);
@@ -1642,3 +1722,129 @@ svn_wc__temp_get_relpath(const char **re
   }
 }
 
+
+svn_error_t *
+svn_wc__acquire_write_lock(const char **anchor_abspath,
+                           svn_wc_context_t *wc_ctx,
+                           const char *local_abspath,
+                           apr_pool_t *result_pool,
+                           apr_pool_t *scratch_pool)
+{
+  svn_wc__db_kind_t kind;
+  apr_pool_t *iterpool;
+  const apr_array_header_t *children;
+  svn_boolean_t parent_is_anchor = FALSE;
+  int format, i;
+  svn_error_t *err;
+
+  if (anchor_abspath)
+    {
+      const char *parent_abspath, *base;
+
+      svn_dirent_split(local_abspath, &parent_abspath, &base, scratch_pool);
+      err = svn_wc__db_read_children(&children, wc_ctx->db, parent_abspath,
+                                     scratch_pool, scratch_pool);
+      if (err)
+        svn_error_clear(err);
+      else
+        {
+          for (i = 0; i < children->nelts; ++i)
+            if (! strcmp(APR_ARRAY_IDX(children, i, const char *), base))
+              break;
+          if (i < children->nelts)
+            parent_is_anchor = TRUE;
+        }
+      local_abspath = parent_is_anchor ? parent_abspath : local_abspath;
+      *anchor_abspath = apr_pstrdup(result_pool, local_abspath);
+    }
+
+  if (! parent_is_anchor)
+    {
+      SVN_ERR(svn_wc__db_read_kind(&kind, wc_ctx->db, local_abspath, TRUE,
+                                   scratch_pool));
+      if (kind != svn_wc__db_kind_dir)
+        local_abspath = svn_dirent_dirname(local_abspath, scratch_pool);
+
+      SVN_ERR(svn_wc__db_read_children(&children, wc_ctx->db, local_abspath,
+                                       scratch_pool, scratch_pool));
+    }
+
+  /* The current lock paradigm is that each directory holds a lock for itself,
+     and there are no inherited locks.  In the eventual wc-ng paradigm, a
+     lock on a directory, would imply a infinite-depth lock on the children.
+     But since we aren't quite there yet, we do the infinite locking
+     manually (and be sure to release them in svn_wc__release_write_lock(). */
+
+  iterpool = svn_pool_create(scratch_pool);
+  for (i = 0; i < children->nelts; i ++)
+    {
+      const char *child_relpath = APR_ARRAY_IDX(children, i, const char *);
+      const char *child_abspath;
+
+      svn_pool_clear(iterpool);
+      child_abspath = svn_dirent_join(local_abspath, child_relpath, iterpool);
+
+      SVN_ERR(svn_wc__db_read_kind(&kind, wc_ctx->db, child_abspath, FALSE,
+                                   iterpool));
+      if (kind == svn_wc__db_kind_dir)
+        SVN_ERR(svn_wc__acquire_write_lock(NULL, wc_ctx, child_abspath,
+                                           NULL, iterpool));
+    }
+
+  /* We don't want to try and lock an unversioned directory that
+     obstructs a versioned directory. */
+  err = svn_wc__internal_check_wc(&format, wc_ctx->db, local_abspath, iterpool);
+  if (!err && format)
+    {
+      SVN_ERR(svn_wc__db_wclock_set(wc_ctx->db, local_abspath, 0, iterpool));
+      SVN_ERR(svn_wc__db_temp_mark_locked(wc_ctx->db, local_abspath, iterpool));
+    }
+  svn_error_clear(err);
+
+  svn_pool_destroy(iterpool);
+
+  return SVN_NO_ERROR;
+}
+
+
+svn_error_t *
+svn_wc__release_write_lock(svn_wc_context_t *wc_ctx,
+                           const char *local_abspath,
+                           apr_pool_t *scratch_pool)
+{
+  svn_wc__db_kind_t kind;
+  apr_pool_t *iterpool;
+  const apr_array_header_t *children;
+  int i;
+
+  SVN_ERR(svn_wc__db_read_kind(&kind, wc_ctx->db, local_abspath, TRUE,
+                               scratch_pool));
+  if (kind != svn_wc__db_kind_dir)
+    local_abspath = svn_dirent_dirname(local_abspath, scratch_pool);
+
+  /* We need to recursively remove locks (see comment in
+     svn_wc__acquire_write_lock(). */
+
+  SVN_ERR(svn_wc__db_read_children(&children, wc_ctx->db, local_abspath,
+                                   scratch_pool, scratch_pool));
+  iterpool = svn_pool_create(scratch_pool);
+  for (i = 0; i < children->nelts; i ++)
+    {
+      const char *child_relpath = APR_ARRAY_IDX(children, i, const char *);
+      const char *child_abspath;
+
+      svn_pool_clear(iterpool);
+      child_abspath = svn_dirent_join(local_abspath, child_relpath, iterpool);
+
+      SVN_ERR(svn_wc__db_read_kind(&kind, wc_ctx->db, child_abspath, FALSE,
+                                   iterpool));
+      if (kind == svn_wc__db_kind_dir)
+        SVN_ERR(svn_wc__release_write_lock(wc_ctx, child_abspath, iterpool));
+    }
+
+  SVN_ERR(svn_wc__db_wclock_remove(wc_ctx->db, local_abspath, iterpool));
+
+  svn_pool_destroy(iterpool);
+
+  return SVN_NO_ERROR;
+}

Modified: subversion/branches/ignore-mergeinfo/subversion/libsvn_wc/lock.h
URL: http://svn.apache.org/viewvc/subversion/branches/ignore-mergeinfo/subversion/libsvn_wc/lock.h?rev=984122&r1=984121&r2=984122&view=diff
==============================================================================
--- subversion/branches/ignore-mergeinfo/subversion/libsvn_wc/lock.h (original)
+++ subversion/branches/ignore-mergeinfo/subversion/libsvn_wc/lock.h Tue Aug 10 17:03:06 2010
@@ -2,10 +2,10 @@
  * lock.h:  routines for locking working copy subdirectories.
  *
  * ====================================================================
- *    Licensed to the Subversion Corporation (SVN Corp.) under one
+ *    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 SVN Corp. licenses this file
+ *    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
@@ -52,8 +52,8 @@ apr_hash_t *svn_wc__adm_access_entries(s
 
 /* Returns TRUE if LOCAL_ABSPATH is a working copy directory that is obstructed
    or missing such that an access baton is not available for LOCAL_ABSPATH.
-   This means DB must also include the parent of LOCAL_ABSPATH. 
-   
+   This means DB must also include the parent of LOCAL_ABSPATH.
+
    This function falls back to using svn_wc__adm_available() if no access batons
    for LOCAL_ABSPATH are stored in DB. */
 svn_boolean_t svn_wc__adm_missing(svn_wc__db_t *db,

Modified: subversion/branches/ignore-mergeinfo/subversion/libsvn_wc/log.c
URL: http://svn.apache.org/viewvc/subversion/branches/ignore-mergeinfo/subversion/libsvn_wc/log.c?rev=984122&r1=984121&r2=984122&view=diff
==============================================================================
--- subversion/branches/ignore-mergeinfo/subversion/libsvn_wc/log.c (original)
+++ subversion/branches/ignore-mergeinfo/subversion/libsvn_wc/log.c Tue Aug 10 17:03:06 2010
@@ -2,10 +2,10 @@
  * log.c:  handle the adm area's log file.
  *
  * ====================================================================
- *    Licensed to the Subversion Corporation (SVN Corp.) under one
+ *    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 SVN Corp. licenses this file
+ *    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
@@ -599,7 +599,7 @@ log_do_delete_entry(struct log_runner *l
         {
           /* Removing a missing wcroot is easy, just remove its parent entry
              ### BH: I can't tell why we don't use this for adds.
-                     We might want to remove WC obstructions? 
+                     We might want to remove WC obstructions?
 
              We don't have a missing status in the final version of WC-NG,
              so why bother researching its history.
@@ -886,25 +886,27 @@ loggy_path(const char **logy_path,
 }
 
 svn_error_t *
-svn_wc__loggy_append(svn_stringbuf_t **log_accum,
+svn_wc__loggy_append(svn_wc__db_t *db,
                      const char *adm_abspath,
                      const char *src, const char *dst,
-                     apr_pool_t *pool)
+                     apr_pool_t *scratch_pool)
 {
   const char *loggy_path1;
   const char *loggy_path2;
+  svn_stringbuf_t *buf = NULL;
 
   SVN_ERR_ASSERT(svn_dirent_is_absolute(adm_abspath));
 
-  SVN_ERR(loggy_path(&loggy_path1, src, adm_abspath, pool));
-  SVN_ERR(loggy_path(&loggy_path2, dst, adm_abspath, pool));
-  svn_xml_make_open_tag(log_accum, pool,
+  SVN_ERR(loggy_path(&loggy_path1, src, adm_abspath, scratch_pool));
+  SVN_ERR(loggy_path(&loggy_path2, dst, adm_abspath, scratch_pool));
+  svn_xml_make_open_tag(&buf, scratch_pool,
                         svn_xml_self_closing, SVN_WC__LOG_APPEND,
                         SVN_WC__LOG_ATTR_NAME, loggy_path1,
                         SVN_WC__LOG_ATTR_DEST, loggy_path2,
                         NULL);
 
-  return SVN_NO_ERROR;
+  return svn_error_return(svn_wc__wq_add_loggy(db, adm_abspath, buf,
+                                               scratch_pool));
 }
 
 
@@ -926,30 +928,30 @@ svn_wc__loggy_copy(svn_stringbuf_t **log
 }
 
 svn_error_t *
-svn_wc__loggy_translated_file(svn_stringbuf_t **log_accum,
+svn_wc__loggy_translated_file(svn_wc__db_t *db,
                               const char *adm_abspath,
                               const char *dst,
                               const char *src,
                               const char *versioned,
-                              apr_pool_t *result_pool,
                               apr_pool_t *scratch_pool)
 {
   const char *loggy_path1;
   const char *loggy_path2;
   const char *loggy_path3;
+  svn_stringbuf_t *buf = NULL;
 
   SVN_ERR(loggy_path(&loggy_path1, src, adm_abspath, scratch_pool));
   SVN_ERR(loggy_path(&loggy_path2, dst, adm_abspath, scratch_pool));
   SVN_ERR(loggy_path(&loggy_path3, versioned, adm_abspath, scratch_pool));
-  svn_xml_make_open_tag
-    (log_accum, result_pool, svn_xml_self_closing,
-     SVN_WC__LOG_CP_AND_TRANSLATE,
-     SVN_WC__LOG_ATTR_NAME, loggy_path1,
-     SVN_WC__LOG_ATTR_DEST, loggy_path2,
-     SVN_WC__LOG_ATTR_ARG_2, loggy_path3,
-     NULL);
+  svn_xml_make_open_tag(&buf, scratch_pool, svn_xml_self_closing,
+                        SVN_WC__LOG_CP_AND_TRANSLATE,
+                        SVN_WC__LOG_ATTR_NAME, loggy_path1,
+                        SVN_WC__LOG_ATTR_DEST, loggy_path2,
+                        SVN_WC__LOG_ATTR_ARG_2, loggy_path3,
+                        NULL);
 
-  return SVN_NO_ERROR;
+  return svn_error_return(svn_wc__wq_add_loggy(db, adm_abspath, buf,
+                                               scratch_pool));
 }
 
 svn_error_t *
@@ -1311,7 +1313,7 @@ svn_wc__loggy_add_tree_conflict(svn_stri
   victim_basename = svn_dirent_basename(conflict->local_abspath, pool);
   SVN_ERR(svn_wc__serialize_conflict(&skel, conflict, pool, pool));
   conflict_data = svn_skel__unparse(skel, pool)->data,
- 
+
   svn_xml_make_open_tag(log_accum, pool, svn_xml_self_closing,
                         SVN_WC__LOG_ADD_TREE_CONFLICT,
                         SVN_WC__LOG_ATTR_NAME,
@@ -1332,14 +1334,14 @@ can_be_cleaned(int *wc_format,
                const char *local_abspath,
                apr_pool_t *scratch_pool)
 {
-  SVN_ERR(svn_wc__internal_check_wc(wc_format, db, 
+  SVN_ERR(svn_wc__internal_check_wc(wc_format, db,
                                     local_abspath, scratch_pool));
 
   /* a "version" of 0 means a non-wc directory */
   if (*wc_format == 0)
     return svn_error_createf(SVN_ERR_WC_NOT_WORKING_COPY, NULL,
                              _("'%s' is not a working copy directory"),
-                             svn_dirent_local_style(local_abspath, 
+                             svn_dirent_local_style(local_abspath,
                                                     scratch_pool));
 
   if (*wc_format < SVN_WC__WC_NG_VERSION)
@@ -1372,7 +1374,7 @@ cleanup_internal(svn_wc__db_t *db,
   SVN_ERR(can_be_cleaned(&wc_format, db, adm_abspath, iterpool));
 
   /* Lock this working copy directory, or steal an existing lock */
-  err = svn_wc__db_wclock_set(db, adm_abspath, iterpool);
+  err = svn_wc__db_wclock_set(db, adm_abspath, 0, iterpool);
   if (err && err->apr_err == SVN_ERR_WC_LOCKED)
     svn_error_clear(err);
   else if (err)
@@ -1445,7 +1447,7 @@ svn_wc_cleanup3(svn_wc_context_t *wc_ctx
                           NULL /* ### config */, TRUE, FALSE,
                           scratch_pool, scratch_pool));
 
-  SVN_ERR(cleanup_internal(db, local_abspath, cancel_func, cancel_baton, 
+  SVN_ERR(cleanup_internal(db, local_abspath, cancel_func, cancel_baton,
                            scratch_pool));
 
   /* We're done with this DB, so proactively close it.  */

Modified: subversion/branches/ignore-mergeinfo/subversion/libsvn_wc/log.h
URL: http://svn.apache.org/viewvc/subversion/branches/ignore-mergeinfo/subversion/libsvn_wc/log.h?rev=984122&r1=984121&r2=984122&view=diff
==============================================================================
--- subversion/branches/ignore-mergeinfo/subversion/libsvn_wc/log.h (original)
+++ subversion/branches/ignore-mergeinfo/subversion/libsvn_wc/log.h Tue Aug 10 17:03:06 2010
@@ -2,10 +2,10 @@
  * log.h :  interfaces for running .svn/log files.
  *
  * ====================================================================
- *    Licensed to the Subversion Corporation (SVN Corp.) under one
+ *    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 SVN Corp. licenses this file
+ *    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
@@ -57,7 +57,7 @@ extern "C" {
    current items in LOG_ACCUM to the work queue, and then reinitializes
    LOG_ACCUM to an empty buffer. */
 #define SVN_WC__FLUSH_LOG_ACCUM(db, adm_abspath, log_accum, scratch_pool)   \
-  if (!svn_stringbuf_isempty(log_accum))                                    \
+  if ((log_accum) && !svn_stringbuf_isempty(log_accum))                     \
     {                                                                       \
       SVN_ERR(svn_wc__wq_add_loggy(db, adm_abspath, log_accum, scratch_pool));\
       svn_stringbuf_setempty(log_accum);                                    \
@@ -65,7 +65,7 @@ extern "C" {
   else {}
 
 
-/* Extend **LOG_ACCUM with log instructions to append the contents
+/* Insert into DB a work queue instruction to append the contents
    of SRC to DST.
    SRC and DST are relative to ADM_ABSPATH.
 
@@ -77,10 +77,10 @@ extern "C" {
 */
 SVN_DEPRECATED
 svn_error_t *
-svn_wc__loggy_append(svn_stringbuf_t **log_accum,
+svn_wc__loggy_append(svn_wc__db_t *db,
                      const char *adm_abspath,
                      const char *src, const char *dst,
-                     apr_pool_t *pool);
+                     apr_pool_t *scratch_pool);
 
 
 /* Extend **LOG_ACCUM with log instructions to copy (and translate!) the
@@ -103,7 +103,7 @@ svn_wc__loggy_copy(svn_stringbuf_t **log
                    apr_pool_t *scratch_pool);
 
 
-/* Extend **LOG_ACCUM with log instructions to generate a translated
+/* Insert into DB a work queue instruction to generate a translated
    file from SRC to DST with translation settings from VERSIONED.
    ADM_ABSPATH is the absolute path for the admin directory for PATH.
    DST and SRC and VERSIONED are relative to ADM_ABSPATH.
@@ -112,12 +112,11 @@ svn_wc__loggy_copy(svn_stringbuf_t **log
    temporary allocations.
 */
 svn_error_t *
-svn_wc__loggy_translated_file(svn_stringbuf_t **log_accum,
+svn_wc__loggy_translated_file(svn_wc__db_t *db,
                               const char *adm_abspath,
                               const char *dst,
                               const char *src,
                               const char *versioned,
-                              apr_pool_t *result_pool,
                               apr_pool_t *scratch_pool);
 
 /* Insert into DB a work queue instruction to delete the entry

Modified: subversion/branches/ignore-mergeinfo/subversion/libsvn_wc/merge.c
URL: http://svn.apache.org/viewvc/subversion/branches/ignore-mergeinfo/subversion/libsvn_wc/merge.c?rev=984122&r1=984121&r2=984122&view=diff
==============================================================================
--- subversion/branches/ignore-mergeinfo/subversion/libsvn_wc/merge.c (original)
+++ subversion/branches/ignore-mergeinfo/subversion/libsvn_wc/merge.c Tue Aug 10 17:03:06 2010
@@ -2,10 +2,10 @@
  * merge.c:  merging changes into a working file
  *
  * ====================================================================
- *    Licensed to the Subversion Corporation (SVN Corp.) under one
+ *    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 SVN Corp. licenses this file
+ *    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
@@ -211,8 +211,9 @@ detranslate_wc_file(const char **detrans
 
       /* ### svn_subst_copy_and_translate3() also creates a tempfile
          ### internally.  Anyway to piggyback on that? */
-      SVN_ERR(svn_io_mktemp(NULL, &detranslated, NULL, NULL,
-                            svn_io_file_del_none, scratch_pool, scratch_pool));
+      SVN_ERR(svn_io_open_unique_file3(NULL, &detranslated, NULL,
+                                      svn_io_file_del_on_pool_cleanup,
+                                      result_pool, scratch_pool));
 
       /* Always 'repair' EOLs here, so that we can apply a diff that
          changes from inconsistent newlines and no 'svn:eol-style' to
@@ -262,8 +263,9 @@ maybe_update_target_eols(const char **ne
       const char *tmp_new;
 
       svn_subst_eol_style_from_value(NULL, &eol, prop->value->data);
-      SVN_ERR(svn_io_mktemp(NULL, &tmp_new, NULL, NULL,
-                            svn_io_file_del_none, scratch_pool, scratch_pool));
+      SVN_ERR(svn_io_open_unique_file3(NULL, &tmp_new, NULL,
+                                       svn_io_file_del_on_pool_cleanup,
+                                       result_pool, scratch_pool));
 
       /* Always 'repair' EOLs here, so that we can apply a diff that
          changes from inconsistent newlines and no 'svn:eol-style' to
@@ -609,7 +611,8 @@ preserve_pre_merge_files(svn_stringbuf_t
   if (! svn_dirent_is_ancestor(dir_abspath, left_abspath))
     {
       SVN_ERR(svn_io_open_unique_file3(NULL, &tmp_left, temp_dir,
-                                       svn_io_file_del_none, pool, pool));
+                                       svn_io_file_del_on_pool_cleanup,
+                                       pool, pool));
       SVN_ERR(svn_io_copy_file(left_abspath, tmp_left, TRUE, pool));
     }
   else
@@ -618,7 +621,8 @@ preserve_pre_merge_files(svn_stringbuf_t
   if (! svn_dirent_is_ancestor(dir_abspath, right_abspath))
     {
       SVN_ERR(svn_io_open_unique_file3(NULL, &tmp_right, temp_dir,
-                                       svn_io_file_del_none, pool, pool));
+                                       svn_io_file_del_on_pool_cleanup,
+                                       pool, pool));
       SVN_ERR(svn_io_copy_file(right_abspath, tmp_right, TRUE, pool));
     }
   else
@@ -639,14 +643,13 @@ preserve_pre_merge_files(svn_stringbuf_t
   /* Create LEFT and RIGHT backup files, in expanded form.
      We use merge_target's current properties to do the translation. */
   /* Derive the basenames of the 3 backup files. */
-  SVN_ERR(svn_wc__loggy_translated_file(log_accum,
-                                        dir_abspath,
+  SVN_WC__FLUSH_LOG_ACCUM(db, dir_abspath, *log_accum, pool);
+  SVN_ERR(svn_wc__loggy_translated_file(db, dir_abspath,
                                         left_copy, tmp_left,
-                                        target_abspath, pool, pool));
-  SVN_ERR(svn_wc__loggy_translated_file(log_accum,
-                                        dir_abspath,
+                                        target_abspath, pool));
+  SVN_ERR(svn_wc__loggy_translated_file(db, dir_abspath,
                                         right_copy, tmp_right,
-                                        target_abspath, pool, pool));
+                                        target_abspath, pool));
 
   /* Back up MERGE_TARGET through detranslation/retranslation:
      the new translation properties may not match the current ones */
@@ -654,10 +657,9 @@ preserve_pre_merge_files(svn_stringbuf_t
            &detranslated_target_copy, target_abspath, db, target_abspath,
            SVN_WC_TRANSLATE_TO_NF | SVN_WC_TRANSLATE_NO_OUTPUT_CLEANUP,
            pool, pool));
-  SVN_ERR(svn_wc__loggy_translated_file(log_accum,
-                                        dir_abspath,
+  SVN_ERR(svn_wc__loggy_translated_file(db, dir_abspath,
                                         target_copy, detranslated_target_copy,
-                                        target_abspath, pool, pool));
+                                        target_abspath, pool));
 
   tmp_entry.conflict_old = svn_dirent_is_child(dir_abspath, left_copy, pool);
   tmp_entry.conflict_new = svn_dirent_is_child(dir_abspath, right_copy, pool);

Modified: subversion/branches/ignore-mergeinfo/subversion/libsvn_wc/node.c
URL: http://svn.apache.org/viewvc/subversion/branches/ignore-mergeinfo/subversion/libsvn_wc/node.c?rev=984122&r1=984121&r2=984122&view=diff
==============================================================================
--- subversion/branches/ignore-mergeinfo/subversion/libsvn_wc/node.c (original)
+++ subversion/branches/ignore-mergeinfo/subversion/libsvn_wc/node.c Tue Aug 10 17:03:06 2010
@@ -2,10 +2,10 @@
  * node.c:  routines for getting information about nodes in the working copy.
  *
  * ====================================================================
- *    Licensed to the Subversion Corporation (SVN Corp.) under one
+ *    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 SVN Corp. licenses this file
+ *    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
@@ -53,7 +53,6 @@
 
 #include "svn_private_config.h"
 #include "private/svn_wc_private.h"
-#include "private/svn_debug.h"
 
 
 svn_error_t *
@@ -366,7 +365,7 @@ walker_helper(svn_wc__db_t *db,
     {
       const char *child_abspath;
       svn_wc__db_kind_t child_kind;
-      
+
       svn_pool_clear(iterpool);
 
       /* See if someone wants to cancel this operation. */
@@ -485,10 +484,10 @@ svn_wc__node_walk_children(svn_wc_contex
 }
 
 svn_error_t *
-svn_wc__node_is_status_delete(svn_boolean_t *is_deleted,
-                              svn_wc_context_t *wc_ctx,
-                              const char *local_abspath,
-                              apr_pool_t *scratch_pool)
+svn_wc__node_is_status_deleted(svn_boolean_t *is_deleted,
+                               svn_wc_context_t *wc_ctx,
+                               const char *local_abspath,
+                               apr_pool_t *scratch_pool)
 {
   svn_wc__db_status_t status;
 
@@ -624,3 +623,24 @@ svn_wc__node_get_base_rev(svn_revnum_t *
 
   return SVN_NO_ERROR;
 }
+
+svn_error_t *
+svn_wc__node_get_lock_token(const char **lock_token,
+                            svn_wc_context_t *wc_ctx,
+                            const char *local_abspath,
+                            apr_pool_t *result_pool,
+                            apr_pool_t *scratch_pool)
+{
+  svn_wc__db_lock_t *lock;
+
+  SVN_ERR(svn_wc__db_read_info(NULL,
+                               NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+                               NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+                               NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+                               NULL, &lock,
+                               wc_ctx->db, local_abspath,
+                               result_pool, scratch_pool));
+  *lock_token = lock ? lock->token : NULL;
+
+  return SVN_NO_ERROR;
+}

Modified: subversion/branches/ignore-mergeinfo/subversion/libsvn_wc/old-and-busted.c
URL: http://svn.apache.org/viewvc/subversion/branches/ignore-mergeinfo/subversion/libsvn_wc/old-and-busted.c?rev=984122&r1=984121&r2=984122&view=diff
==============================================================================
--- subversion/branches/ignore-mergeinfo/subversion/libsvn_wc/old-and-busted.c (original)
+++ subversion/branches/ignore-mergeinfo/subversion/libsvn_wc/old-and-busted.c Tue Aug 10 17:03:06 2010
@@ -2,10 +2,10 @@
  * old-and-busted.c:  routines for reading pre-1.7 working copies.
  *
  * ====================================================================
- *    Licensed to the Subversion Corporation (SVN Corp.) under one
+ *    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 SVN Corp. licenses this file
+ *    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
@@ -160,7 +160,7 @@ read_str(const char **result,
 
 /* This is wrapper around read_str() (which see for details); it
    simply asks svn_path_is_canonical() of the string it reads,
-   returning an error if the test fails. 
+   returning an error if the test fails.
    ### It seems this is only called for entrynames now
    */
 static svn_error_t *
@@ -1071,7 +1071,7 @@ handle_start_tag(void *userData, const c
    entries in ENTRIES.  Use SCRATCH_POOL for temporary allocations and
    RESULT_POOL for the returned entries.  */
 static svn_error_t *
-parse_entries_xml(const char *path,
+parse_entries_xml(const char *dir_abspath,
                   apr_hash_t *entries,
                   const char *buf,
                   apr_size_t size,
@@ -1101,7 +1101,7 @@ parse_entries_xml(const char *path,
   SVN_ERR_W(svn_xml_parse(svn_parser, buf, size, TRUE),
             apr_psprintf(scratch_pool,
                          _("XML parser failed in '%s'"),
-                         svn_dirent_local_style(path, scratch_pool)));
+                         svn_dirent_local_style(dir_abspath, scratch_pool)));
 
   svn_pool_destroy(accum.scratch_pool);
 
@@ -1206,7 +1206,7 @@ resolve_to_defaults(apr_hash_t *entries,
    SCRATCH_POOL.  */
 svn_error_t *
 svn_wc__read_entries_old(apr_hash_t **entries,
-                         const char *path,
+                         const char *dir_abspath,
                          apr_pool_t *result_pool,
                          apr_pool_t *scratch_pool)
 {
@@ -1220,7 +1220,7 @@ svn_wc__read_entries_old(apr_hash_t **en
   *entries = apr_hash_make(result_pool);
 
   /* Open the entries file. */
-  SVN_ERR(svn_wc__open_adm_stream(&stream, path, SVN_WC__ADM_ENTRIES,
+  SVN_ERR(svn_wc__open_adm_stream(&stream, dir_abspath, SVN_WC__ADM_ENTRIES,
                                   scratch_pool, scratch_pool));
   SVN_ERR(svn_string_from_stream(&buf, stream, scratch_pool, scratch_pool));
 
@@ -1231,7 +1231,7 @@ svn_wc__read_entries_old(apr_hash_t **en
   /* If the first byte of the file is not a digit, then it is probably in XML
      format. */
   if (curp != endp && !svn_ctype_isdigit(*curp))
-    SVN_ERR(parse_entries_xml(path, *entries, buf->data, buf->len,
+    SVN_ERR(parse_entries_xml(dir_abspath, *entries, buf->data, buf->len,
                               result_pool, scratch_pool));
   else
     {
@@ -1242,12 +1242,13 @@ svn_wc__read_entries_old(apr_hash_t **en
          original format pre-upgrade. */
       SVN_ERR(read_val(&val, &curp, endp));
       if (val)
-        entries_format = (apr_off_t)apr_strtoi64(val, NULL, 0);
+        entries_format = (int)apr_strtoi64(val, NULL, 0);
       else
         return svn_error_createf(SVN_ERR_WC_CORRUPT, NULL,
                                  _("Invalid version line in entries file "
                                    "of '%s'"),
-                                 svn_dirent_local_style(path, scratch_pool));
+                                 svn_dirent_local_style(dir_abspath,
+                                                        scratch_pool));
       entryno = 1;
 
       while (curp != endp)
@@ -1271,7 +1272,7 @@ svn_wc__read_entries_old(apr_hash_t **en
                                      _("Error at entry %d in entries file for "
                                        "'%s':"),
                                      entryno,
-                                     svn_dirent_local_style(path,
+                                     svn_dirent_local_style(dir_abspath,
                                                             scratch_pool));
 
           ++curp;
@@ -1348,7 +1349,7 @@ svn_wc_entry(const svn_wc_entry_t **entr
       /* We got the parent stub instead of the real entry. Fine.  */
       svn_error_clear(err);
     }
-  
+
   if (!show_hidden && *entry != NULL)
     {
       svn_boolean_t hidden;