Author: stefan2
Date: Fri Dec 28 00:57:11 2012
New Revision: 1426371

URL: http://svn.apache.org/viewvc?rev=1426371&view=rev
Log:
On the fsfs-format7 branch: define the low-level API to read and write
changed path lists.  Update callers.

* subversion/libsvn_fs_fs/low_level.h
  (svn_fs_fs__read_changes): renamed from read_all_changes; use streams
   instead of files
  (svn_fs_fs__write_changes): renamed from write_changed_path_info
  (write_change_entry): drop from API; use the above instead

* subversion/libsvn_fs_fs/low_level.c
  (read_change): switch from file to stream I/O
  (svn_fs_fs__read_changes): renamed from read_all_changes; update
  (svn_fs_fs__write_changes): renamed from write_changed_path_info; update

* subversion/libsvn_fs_fs/cached_data.c
  (svn_fs_fs__get_changes): update caller

* subversion/libsvn_fs_fs/transaction.c
  (svn_fs_fs__txn_changes_fetch,
   svn_fs_fs__add_change,
   write_final_changed_path_info): same here

Modified:
    subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/cached_data.c
    subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/low_level.c
    subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/low_level.h
    subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/transaction.c

Modified: subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/cached_data.c
URL: 
http://svn.apache.org/viewvc/subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/cached_data.c?rev=1426371&r1=1426370&r2=1426371&view=diff
==============================================================================
--- subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/cached_data.c 
(original)
+++ subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/cached_data.c Fri 
Dec 28 00:57:11 2012
@@ -1670,8 +1670,10 @@ svn_fs_fs__get_changes(apr_array_header_
                                   rev, pool));
 
   SVN_ERR(svn_io_file_seek(revision_file, APR_SET, &changes_offset, pool));
-  SVN_ERR(read_all_changes(changes, revision_file, pool));
-  
+  SVN_ERR(svn_fs_fs__read_changes(changes,
+                                  svn_stream_from_aprfile2(revision_file,
+                                                           TRUE, pool),
+                                  pool));
   SVN_ERR(svn_io_file_close(revision_file, pool));
 
   /* cache for future reference */

Modified: subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/low_level.c
URL: 
http://svn.apache.org/viewvc/subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/low_level.c?rev=1426371&r1=1426370&r2=1426371&view=diff
==============================================================================
--- subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/low_level.c 
(original)
+++ subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/low_level.c Fri 
Dec 28 00:57:11 2012
@@ -678,34 +678,25 @@ svn_fs_fs__write_rep_header(svn_fs_fs__r
    store NULL there.  Perform all allocations from POOL. */
 static svn_error_t *
 read_change(change_t **change_p,
-            apr_file_t *file,
+            svn_stream_t *stream,
             apr_pool_t *pool)
 {
-  char buf[MAX_CHANGE_LINE_LEN];
-  apr_size_t len = sizeof(buf);
+  svn_stringbuf_t *line;
+  svn_boolean_t eof = TRUE;
   change_t *change;
-  char *str, *last_str = buf, *kind_str;
-  svn_error_t *err;
+  char *str, *last_str, *kind_str;
 
   /* Default return value. */
   *change_p = NULL;
 
-  err = svn_io_read_length_line(file, buf, &len, pool);
+  SVN_ERR(svn_stream_readline(stream, &line, "\n", &eof, pool));
 
   /* Check for a blank line. */
-  if (err || (len == 0))
-    {
-      if (err && APR_STATUS_IS_EOF(err->apr_err))
-        {
-          svn_error_clear(err);
-          return SVN_NO_ERROR;
-        }
-      if ((len == 0) && (! err))
-        return SVN_NO_ERROR;
-      return svn_error_trace(err);
-    }
+  if (eof || (line->len == 0))
+    return SVN_NO_ERROR;
 
   change = apr_pcalloc(pool, sizeof(*change));
+  last_str = line->data;
 
   /* Get the node-id of the change. */
   str = svn_cstring_tokenize(" ", &last_str);
@@ -813,17 +804,15 @@ read_change(change_t **change_p,
 
 
   /* Read the next line, the copyfrom line. */
-  len = sizeof(buf);
-  SVN_ERR(svn_io_read_length_line(file, buf, &len, pool));
-
-  if (len == 0)
+  SVN_ERR(svn_stream_readline(stream, &line, "\n", &eof, pool));
+  if (eof || line->len == 0)
     {
       change->copyfrom_rev = SVN_INVALID_REVNUM;
       change->copyfrom_path = NULL;
     }
   else
     {
-      last_str = buf;
+      last_str = line->data;
       str = svn_cstring_tokenize(" ", &last_str);
       if (! str)
         return svn_error_create(SVN_ERR_FS_CORRUPT, NULL,
@@ -845,9 +834,9 @@ read_change(change_t **change_p,
 /* Fetch all the changes from FILE and store them in *CHANGES.  Do all
    allocations in POOL. */
 svn_error_t *
-read_all_changes(apr_array_header_t **changes,
-                 apr_file_t *file,
-                 apr_pool_t *pool)
+svn_fs_fs__read_changes(apr_array_header_t **changes,
+                        svn_stream_t *stream,
+                        apr_pool_t *pool)
 {
   change_t *change;
 
@@ -855,11 +844,11 @@ read_all_changes(apr_array_header_t **ch
      (will be auto-expanded as necessary) */
   *changes = apr_array_make(pool, 30, sizeof(change_t *));
   
-  SVN_ERR(read_change(&change, file, pool));
+  SVN_ERR(read_change(&change, stream, pool));
   while (change)
     {
       APR_ARRAY_PUSH(*changes, change_t*) = change;
-      SVN_ERR(read_change(&change, file, pool));
+      SVN_ERR(read_change(&change, stream, pool));
     }
 
   return SVN_NO_ERROR;
@@ -869,7 +858,7 @@ read_all_changes(apr_array_header_t **ch
    string COPYFROM, into the file specified by FILE.  Only include the
    node kind field if INCLUDE_NODE_KIND is true.  All temporary
    allocations are in POOL. */
-svn_error_t *
+static svn_error_t *
 write_change_entry(svn_stream_t *stream,
                    const char *path,
                    svn_fs_path_change2_t *change,
@@ -939,10 +928,10 @@ write_change_entry(svn_stream_t *stream,
    in the file of the beginning of this information.  Perform
    temporary allocations in POOL. */
 svn_error_t *
-write_changed_path_info(svn_stream_t *stream,
-                        svn_fs_t *fs,
-                        apr_hash_t *changed_paths,
-                        apr_pool_t *pool)
+svn_fs_fs__write_changes(svn_stream_t *stream,
+                         svn_fs_t *fs,
+                         apr_hash_t *changes,
+                         apr_pool_t *pool)
 {
   apr_pool_t *iterpool = svn_pool_create(pool);
   fs_fs_data_t *ffd = fs->fsap_data;
@@ -954,7 +943,7 @@ write_changed_path_info(svn_stream_t *st
   /* For the sake of the repository administrator sort the changes so
      that the final file is deterministic and repeatable, however the
      rest of the FSFS code doesn't require any particular order here. */
-  sorted_changed_paths = svn_sort__hash(changed_paths,
+  sorted_changed_paths = svn_sort__hash(changes,
                                         svn_sort_compare_items_lexically, 
pool);
 
   /* Iterate through the changed paths one at a time, and convert the

Modified: subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/low_level.h
URL: 
http://svn.apache.org/viewvc/subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/low_level.h?rev=1426371&r1=1426370&r2=1426371&view=diff
==============================================================================
--- subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/low_level.h 
(original)
+++ subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/low_level.h Fri 
Dec 28 00:57:11 2012
@@ -162,33 +162,21 @@ svn_fs_fs__write_rep_header(svn_fs_fs__r
                             svn_stream_t *stream,
                             apr_pool_t *pool);
 
-/* Fetch all the changes from FILE and store them in *CHANGES.  Do all
+/* Read all the changes from STREAM and store them in *CHANGES.  Do all
    allocations in POOL. */
 svn_error_t *
-read_all_changes(apr_array_header_t **changes,
-                 apr_file_t *file,
-                 apr_pool_t *pool);
-
-/* Write a single change entry, path PATH, change CHANGE, and copyfrom
-   string COPYFROM, into the file specified by FILE.  Only include the
-   node kind field if INCLUDE_NODE_KIND is true.  All temporary
-   allocations are in POOL. */
-svn_error_t *
-write_change_entry(svn_stream_t *stream,
-                   const char *path,
-                   svn_fs_path_change2_t *change,
-                   svn_boolean_t include_node_kind,
-                   apr_pool_t *pool);
+svn_fs_fs__read_changes(apr_array_header_t **changes,
+                        svn_stream_t *stream,
+                        apr_pool_t *pool);
 
-/* Write the changed path info from transaction TXN_ID in filesystem
-   FS to the permanent rev-file FILE.  *OFFSET_P is set the to offset
-   in the file of the beginning of this information.  Perform
-   temporary allocations in POOL. */
+/* Write the changed path info from CHANGES in filesystem FS to the
+   output stream STREAM.  Perform temporary allocations in POOL.
+ */
 svn_error_t *
-write_changed_path_info(svn_stream_t *stream,
-                        svn_fs_t *fs,
-                        apr_hash_t *changed_paths,
-                        apr_pool_t *pool);
+svn_fs_fs__write_changes(svn_stream_t *stream,
+                         svn_fs_t *fs,
+                         apr_hash_t *changes,
+                         apr_pool_t *pool);
 
 svn_error_t *
 get_root_changes_offset(apr_off_t *root_offset,

Modified: subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/transaction.c
URL: 
http://svn.apache.org/viewvc/subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/transaction.c?rev=1426371&r1=1426370&r2=1426371&view=diff
==============================================================================
--- subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/transaction.c 
(original)
+++ subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/transaction.c Fri 
Dec 28 00:57:11 2012
@@ -906,15 +906,17 @@ svn_fs_fs__txn_changes_fetch(apr_hash_t 
   apr_array_header_t *changes;
   apr_pool_t *scratch_pool = svn_pool_create(pool);
 
-  SVN_ERR(svn_io_file_open(&file, path_txn_changes(fs, txn_id, pool),
-                           APR_READ | APR_BUFFERED, APR_OS_DEFAULT, pool));
-
-  SVN_ERR(read_all_changes(&changes, file, scratch_pool));
+  SVN_ERR(svn_io_file_open(&file, path_txn_changes(fs, txn_id, scratch_pool),
+                           APR_READ | APR_BUFFERED, APR_OS_DEFAULT,
+                           scratch_pool));
+
+  SVN_ERR(svn_fs_fs__read_changes(&changes,
+                                  svn_stream_from_aprfile2(file, TRUE,
+                                                           scratch_pool),
+                                  scratch_pool));
   SVN_ERR(process_changes(changed_paths, NULL, changes, FALSE, pool));
   svn_pool_destroy(scratch_pool);
 
-  SVN_ERR(svn_io_file_close(file, pool));
-
   *changed_paths_p = changed_paths;
 
   return SVN_NO_ERROR;
@@ -1567,6 +1569,7 @@ svn_fs_fs__add_change(svn_fs_t *fs,
 {
   apr_file_t *file;
   svn_fs_path_change2_t *change;
+  apr_hash_t *changes = apr_hash_make(pool);
 
   SVN_ERR(svn_io_file_open(&file, path_txn_changes(fs, txn_id, pool),
                            APR_APPEND | APR_WRITE | APR_CREATE
@@ -1579,8 +1582,9 @@ svn_fs_fs__add_change(svn_fs_t *fs,
   change->copyfrom_rev = copyfrom_rev;
   change->copyfrom_path = apr_pstrdup(pool, copyfrom_path);
 
-  SVN_ERR(write_change_entry(svn_stream_from_aprfile2(file, TRUE, pool),
-                             path, change, TRUE, pool));
+  apr_hash_set(changes, path, APR_HASH_KEY_STRING, change);
+  SVN_ERR(svn_fs_fs__write_changes(svn_stream_from_aprfile2(file, TRUE, pool),
+                                   fs, changes, pool));
 
   return svn_io_file_close(file, pool);
 }
@@ -2651,8 +2655,8 @@ write_final_changed_path_info(apr_off_t 
 
   SVN_ERR(svn_fs_fs__txn_changes_fetch(&changed_paths, fs, txn_id, pool));
 
-  SVN_ERR(write_changed_path_info(svn_stream_from_aprfile2(file, TRUE, pool),
-                                  fs, changed_paths, pool));
+  SVN_ERR(svn_fs_fs__write_changes(svn_stream_from_aprfile2(file, TRUE, pool),
+                                   fs, changed_paths, pool));
 
   *offset_p = offset;
 


Reply via email to