Author: philip
Date: Thu Dec 10 15:43:15 2009
New Revision: 889302
URL: http://svn.apache.org/viewvc?rev=889302&view=rev
Log:
obliterate-like-deltify branch: allow first version to be obliterated.
* subversion/libsvn_fs_base/reps-strings.c
(svn_fs_base__rep_obliterate): Construct an empty fulltext if there
is no predecessor.
* subversion/include/svn_fs.h
(svn_fs_obliterate): Tweak comment.
* subversion/libsvn_fs_base/dag.h
(svn_fs_base__dag_obliterate): Tweak comment.
* subversion/libsvn_fs_base/reps-strings.h
(svn_fs_base__rep_obliterate): Tweak comment.
* subversion/tests/libsvn_fs/fs-test.c
(obliterate_2): Obliterate first version of file.
Modified:
subversion/branches/obliterate-like-deltify/subversion/include/svn_fs.h
subversion/branches/obliterate-like-deltify/subversion/libsvn_fs_base/dag.h
subversion/branches/obliterate-like-deltify/subversion/libsvn_fs_base/reps-strings.c
subversion/branches/obliterate-like-deltify/subversion/libsvn_fs_base/reps-strings.h
subversion/branches/obliterate-like-deltify/subversion/tests/libsvn_fs/fs-test.c
Modified:
subversion/branches/obliterate-like-deltify/subversion/include/svn_fs.h
URL:
http://svn.apache.org/viewvc/subversion/branches/obliterate-like-deltify/subversion/include/svn_fs.h?rev=889302&r1=889301&r2=889302&view=diff
==============================================================================
--- subversion/branches/obliterate-like-deltify/subversion/include/svn_fs.h
(original)
+++ subversion/branches/obliterate-like-deltify/subversion/include/svn_fs.h Thu
Dec 10 15:43:15 2009
@@ -1842,7 +1842,10 @@
/** Obliterate the text associated with @revision of @a path in @a fs,
* where @a path must be a file. The text is replaced with the text
- * of the previous version of the file.
+ * of the previous version of the file, or with an empty text if there
+ * is no previous version.
+ *
+ * ### Exists for testing, no idea if this is the final interface.
*/
svn_error_t *
svn_fs_obliterate(svn_fs_t *fs,
Modified:
subversion/branches/obliterate-like-deltify/subversion/libsvn_fs_base/dag.h
URL:
http://svn.apache.org/viewvc/subversion/branches/obliterate-like-deltify/subversion/libsvn_fs_base/dag.h?rev=889302&r1=889301&r2=889302&view=diff
==============================================================================
--- subversion/branches/obliterate-like-deltify/subversion/libsvn_fs_base/dag.h
(original)
+++ subversion/branches/obliterate-like-deltify/subversion/libsvn_fs_base/dag.h
Thu Dec 10 15:43:15 2009
@@ -539,8 +539,9 @@
trail_t *trail,
apr_pool_t *pool);
-/* Obliterate NODE's representation by constructing an empty delta
- to PRED_NODE. */
+/* Obliterate NODE's data by constructing a new representation that
+ consists of a no-change delta from PRED_NODE. If PRED_NODE is null
+ then construct a representation with an empty fulltext instead. */
svn_error_t *svn_fs_base__dag_obliterate(dag_node_t *node,
dag_node_t *pred_node,
trail_t *trail,
Modified:
subversion/branches/obliterate-like-deltify/subversion/libsvn_fs_base/reps-strings.c
URL:
http://svn.apache.org/viewvc/subversion/branches/obliterate-like-deltify/subversion/libsvn_fs_base/reps-strings.c?rev=889302&r1=889301&r2=889302&view=diff
==============================================================================
---
subversion/branches/obliterate-like-deltify/subversion/libsvn_fs_base/reps-strings.c
(original)
+++
subversion/branches/obliterate-like-deltify/subversion/libsvn_fs_base/reps-strings.c
Thu Dec 10 15:43:15 2009
@@ -1628,6 +1628,8 @@
trail_t *trail,
apr_pool_t *pool)
{
+ const char *new_str;
+ representation_t *empty;
svn_stream_t *new_stream;
struct write_svndiff_strings_baton new_baton;
svn_stream_t *pred_stream1, *pred_stream2;
@@ -1648,13 +1650,20 @@
apr_array_header_t *chunks;
int i;
- /* ### Temporary error, really need an empty rep here to support
- obliteration of the first version. */
if (!pred_key)
- return svn_error_createf
- (SVN_ERR_UNSUPPORTED_FEATURE, NULL,
- _("Attempting to obliterate '%s' without a predecessor "),
- key);
+ {
+ /* No predecessor so just write a new empty rep */
+ SVN_ERR(svn_fs_bdb__string_append(fs, &new_str, 0, NULL, trail, pool));
+ empty = make_fulltext_rep(new_str, NULL,
+ svn_checksum_empty_checksum(svn_checksum_md5,
+ pool),
+ svn_checksum_empty_checksum(svn_checksum_sha1,
+ pool),
+ pool);
+ SVN_ERR(svn_fs_bdb__write_rep(fs, key, empty, trail, pool));
+
+ return SVN_NO_ERROR;
+ }
if (!strcmp(key, pred_key))
return svn_error_createf(SVN_ERR_FS_CORRUPT, NULL,
@@ -1667,7 +1676,7 @@
new_stream = svn_stream_create(&new_baton, pool);
svn_stream_set_write(new_stream, write_svndiff_strings);
- /* ### Is there a simpler way to write an empty delta? */
+ /* ### Is there a simpler way to write a no-change delta? */
SVN_ERR(svn_fs_base__rep_contents_read_stream(&pred_stream1, fs, pred_key,
TRUE, trail, pool));
SVN_ERR(svn_fs_base__rep_contents_read_stream(&pred_stream2, fs, pred_key,
@@ -1739,25 +1748,5 @@
new_rep.contents.delta.chunks = chunks;
SVN_ERR(svn_fs_bdb__write_rep(fs, key, &new_rep, trail, pool));
-#if 0
- /* ### Might have younger revs referring to the old rep? */
- {
- representation_t *old_rep;
- apr_array_header_t *orig_str_keys;
- SVN_ERR(svn_fs_bdb__read_rep(&old_rep, fs, key, trail, pool));
- if (old_rep->kind == rep_kind_fulltext)
- {
- const char *str_key = old_rep->contents.fulltext.string_key;
- orig_str_keys = apr_array_make(pool, 1, sizeof(str_key));
- APR_ARRAY_PUSH(orig_str_keys, const char *) = str_key;
- }
- else if (old_rep->kind == rep_kind_delta)
- SVN_ERR(delta_string_keys(&orig_str_keys, old_rep, pool));
- else /* unknown kind */
- return UNKNOWN_NODE_KIND(key);
- SVN_ERR(delete_strings(orig_str_keys, fs, trail, pool));
- }
-#endif
-
return SVN_NO_ERROR;
}
Modified:
subversion/branches/obliterate-like-deltify/subversion/libsvn_fs_base/reps-strings.h
URL:
http://svn.apache.org/viewvc/subversion/branches/obliterate-like-deltify/subversion/libsvn_fs_base/reps-strings.h?rev=889302&r1=889301&r2=889302&view=diff
==============================================================================
---
subversion/branches/obliterate-like-deltify/subversion/libsvn_fs_base/reps-strings.h
(original)
+++
subversion/branches/obliterate-like-deltify/subversion/libsvn_fs_base/reps-strings.h
Thu Dec 10 15:43:15 2009
@@ -168,9 +168,11 @@
trail_t *trail,
apr_pool_t *pool);
-/* Obliterate KEY's data by creating a new rep by constructing an
- empty delta from PRED_KEY's data. KEY's data remains in the
- database in case some other key's data is derived from it. */
+/* Obliterate KEY's data by creating a new rep that consists of a
+ no-change delta from PRED_KEY's data. If PRED_KEY is null then
+ construct an empty fulltext instead of a delta. KEY's old data
+ remains in the database in case some other key's data is derived
+ from it. */
svn_error_t *svn_fs_base__rep_obliterate(svn_fs_t *fs,
const char *key,
const char *pred_key,
Modified:
subversion/branches/obliterate-like-deltify/subversion/tests/libsvn_fs/fs-test.c
URL:
http://svn.apache.org/viewvc/subversion/branches/obliterate-like-deltify/subversion/tests/libsvn_fs/fs-test.c?rev=889302&r1=889301&r2=889302&view=diff
==============================================================================
---
subversion/branches/obliterate-like-deltify/subversion/tests/libsvn_fs/fs-test.c
(original)
+++
subversion/branches/obliterate-like-deltify/subversion/tests/libsvn_fs/fs-test.c
Thu Dec 10 15:43:15 2009
@@ -4896,8 +4896,7 @@
"abcdefghijklmnopqrstuvwxyz0123456789" },
};
SVN_ERR(svn_fs_revision_root(&rev_root, fs, 2, subpool));
- SVN_ERR(svn_test__validate_tree(rev_root, expected, 2,
- subpool));
+ SVN_ERR(svn_test__validate_tree(rev_root, expected, 2, subpool));
SVN_ERR(svn_fs_revision_root(&rev_root, fs, 3, subpool));
SVN_ERR(svn_test__validate_tree(rev_root, expected,
sizeof(expected)/sizeof(expected[0]),
@@ -4925,6 +4924,19 @@
}
svn_pool_clear(subpool);
+ SVN_ERR(svn_fs_obliterate(fs, "A/foo", 1, subpool));
+ {
+ svn_test__tree_entry_t expected[] = {
+ { "A", 0 },
+ { "A/foo", "" },
+ };
+ SVN_ERR(svn_fs_revision_root(&rev_root, fs, 1, subpool));
+ SVN_ERR(svn_test__validate_tree(rev_root, expected,
+ sizeof(expected)/sizeof(expected[0]),
+ subpool));
+ }
+ svn_pool_clear(subpool);
+
return SVN_NO_ERROR;
}