You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by ju...@apache.org on 2009/12/22 19:44:28 UTC
svn commit: r893267 - in /subversion/trunk/subversion/libsvn_fs_base:
bdb/node-origins-table.c bdb/node-origins-table.h dag.c revs-txns.c
Author: julianfoad
Date: Tue Dec 22 18:44:27 2009
New Revision: 893267
URL: http://svn.apache.org/viewvc?rev=893267&view=rev
Log:
For obliterate in BDB, implement updating the "node-origins" table.
* subversion/libsvn_fs_base/bdb/node-origins-table.c,
subversion/libsvn_fs_base/bdb/node-origins-table.h
(svn_fs_bdb__change_node_origin): New function to overwrite an existing
node-origins row.
* subversion/libsvn_fs_base/dag.c
(node_origins_update): New function.
(svn_fs_base__dag_commit_obliteration_txn): Update the "node-origins" table.
* subversion/libsvn_fs_base/revs-txns.c
(txn_body_begin_obliteration_txn): Remove a "TODO" comment about this.
Modified:
subversion/trunk/subversion/libsvn_fs_base/bdb/node-origins-table.c
subversion/trunk/subversion/libsvn_fs_base/bdb/node-origins-table.h
subversion/trunk/subversion/libsvn_fs_base/dag.c
subversion/trunk/subversion/libsvn_fs_base/revs-txns.c
Modified: subversion/trunk/subversion/libsvn_fs_base/bdb/node-origins-table.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_base/bdb/node-origins-table.c?rev=893267&r1=893266&r2=893267&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_base/bdb/node-origins-table.c (original)
+++ subversion/trunk/subversion/libsvn_fs_base/bdb/node-origins-table.c Tue Dec 22 18:44:27 2009
@@ -129,6 +129,39 @@
&key, &value, 0));
}
+svn_error_t *svn_fs_bdb__change_node_origin(svn_fs_t *fs,
+ const char *node_id,
+ const svn_fs_id_t *origin_id,
+ trail_t *trail,
+ apr_pool_t *pool)
+{
+ base_fs_data_t *bfd = fs->fsap_data;
+ DBT key, value;
+ int db_err;
+
+ /* Create a key from our NODE_ID. */
+ svn_fs_base__str_to_dbt(&key, node_id);
+
+ /* Check that we already have a mapping for NODE_ID. */
+ svn_fs_base__trail_debug(trail, "node-origins", "get");
+ db_err = bfd->node_origins->get(bfd->node_origins, trail->db_txn,
+ &key, svn_fs_base__result_dbt(&value), 0);
+ svn_fs_base__track_dbt(&value, pool);
+ if (db_err == DB_NOTFOUND)
+ {
+ return svn_error_createf
+ (SVN_ERR_FS_CORRUPT, NULL,
+ _("Node origin for '%s' not found"), node_id);
+ }
+
+ /* Create a value from our ORIGIN_ID, and add this record to the table. */
+ svn_fs_base__id_to_dbt(&value, origin_id, pool);
+ svn_fs_base__trail_debug(trail, "node-origins", "put");
+ return BDB_WRAP(fs, _("storing node-origins record"),
+ bfd->node_origins->put(bfd->node_origins, trail->db_txn,
+ &key, &value, 0));
+}
+
svn_error_t *svn_fs_bdb__delete_node_origin(svn_fs_t *fs,
const char *node_id,
trail_t *trail,
Modified: subversion/trunk/subversion/libsvn_fs_base/bdb/node-origins-table.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_base/bdb/node-origins-table.h?rev=893267&r1=893266&r2=893267&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_base/bdb/node-origins-table.h (original)
+++ subversion/trunk/subversion/libsvn_fs_base/bdb/node-origins-table.h Tue Dec 22 18:44:27 2009
@@ -62,6 +62,13 @@
trail_t *trail,
apr_pool_t *pool);
+/* Like svn_fs_bdb__set_node_origin() but replaces an existing entry. */
+svn_error_t *svn_fs_bdb__change_node_origin(svn_fs_t *fs,
+ const char *node_id,
+ const svn_fs_id_t *origin_id,
+ trail_t *trail,
+ apr_pool_t *pool);
+
/* Delete from the `node-origins' table the record for NODE_ID in FS.
Do this as part of TRAIL. Use POOL for temporary allocations. */
svn_error_t *svn_fs_bdb__delete_node_origin(svn_fs_t *fs,
Modified: subversion/trunk/subversion/libsvn_fs_base/dag.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_base/dag.c?rev=893267&r1=893266&r2=893267&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_base/dag.c (original)
+++ subversion/trunk/subversion/libsvn_fs_base/dag.c Tue Dec 22 18:44:27 2009
@@ -49,6 +49,8 @@
#include "bdb/reps-table.h"
#include "bdb/strings-table.h"
#include "bdb/checksum-reps-table.h"
+#include "bdb/changes-table.h"
+#include "bdb/node-origins-table.h"
#include "private/svn_skel.h"
#include "private/svn_fs_util.h"
@@ -1625,6 +1627,59 @@
&date, trail, pool);
}
+/* Modify all entries in the "node-origins" table that have a txn-id of
+ * OLD_TXN_ID to refer to NEW_TXN_ID instead.
+ *
+ * Work within TRAIL. */
+static svn_error_t *
+node_origins_update(const char *new_txn_id,
+ const char *old_txn_id,
+ trail_t *trail,
+ apr_pool_t *scratch_pool)
+{
+ apr_array_header_t *changes;
+ int i;
+
+ /* To find the nodes that originate in the old txn, we'll look in the
+ * "changes" table. Any change that added a node could have created a new
+ * node id. */
+ SVN_ERR(svn_fs_bdb__changes_fetch_raw(&changes, trail->fs, old_txn_id, trail,
+ scratch_pool));
+ for (i = 0; i < changes->nelts; i++)
+ {
+ change_t *change = APR_ARRAY_IDX(changes, i, change_t *);
+
+ if (change->kind == svn_fs_path_change_add
+ || change->kind == svn_fs_path_change_replace)
+ {
+ const svn_fs_id_t *origin_id;
+ const char *node_id, *id_copy_id, *id_txn_id;
+
+ /* Find the destination node id of this change */
+ node_id = svn_fs_base__id_node_id(change->noderev_id);
+
+ /* Fetch the old node-origin */
+ SVN_ERR(svn_fs_bdb__get_node_origin(&origin_id, trail->fs, node_id,
+ trail, scratch_pool));
+ id_copy_id = svn_fs_base__id_copy_id(origin_id);
+ id_txn_id = svn_fs_base__id_txn_id(origin_id);
+
+ if (svn_fs_base__key_compare(id_txn_id, old_txn_id) == 0)
+ {
+ /* Change its txn_id to NEW_TXN_ID */
+ origin_id = svn_fs_base__id_create(node_id, id_copy_id,
+ new_txn_id, scratch_pool);
+ /* Save the new node-origin */
+ SVN_ERR(svn_fs_bdb__change_node_origin(trail->fs, node_id,
+ origin_id, trail,
+ scratch_pool));
+ }
+ }
+ }
+
+ return SVN_NO_ERROR;
+}
+
svn_error_t *
svn_fs_base__dag_commit_obliteration_txn(svn_revnum_t replacing_rev,
svn_fs_txn_t *txn,
@@ -1633,8 +1688,13 @@
{
transaction_t *txn_obj;
revision_t revision;
+ const char *old_txn_id;
+
+ /* Find the old txn. */
+ SVN_ERR(svn_fs_base__rev_get_txn_id(&old_txn_id, trail->fs, replacing_rev,
+ trail, trail->pool));
- /* Read the txn so we can access its "copies" list */
+ /* Read the new txn so we can access its "copies" list */
SVN_ERR(svn_fs_bdb__get_txn(&txn_obj, trail->fs, txn->id, trail,
trail->pool));
@@ -1693,6 +1753,10 @@
/* Promote the unfinished transaction to a committed one. */
SVN_ERR(svn_fs_base__txn_make_committed(txn->fs, txn->id, replacing_rev,
trail, pool));
+
+ /* Update the "node-origins" table. */
+ SVN_ERR(node_origins_update(txn->id, old_txn_id, trail, trail->pool));
+
return SVN_NO_ERROR;
}
Modified: subversion/trunk/subversion/libsvn_fs_base/revs-txns.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_base/revs-txns.c?rev=893267&r1=893266&r2=893267&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_base/revs-txns.c (original)
+++ subversion/trunk/subversion/libsvn_fs_base/revs-txns.c Tue Dec 22 18:44:27 2009
@@ -848,10 +848,6 @@
/* Dup the "changes" that are keyed by the txn_id. */
SVN_ERR(changes_dup(new_txn_id, old_txn_id, trail, trail->pool));
- /* ### TODO: Update the "node-origins" table.
- * Or can this be deferred till commit time? Probably not. */
-
-
/* Save the modified transaction */
SVN_ERR(svn_fs_bdb__put_txn(trail->fs, new_txn, new_txn_id, trail,
trail->pool));
Re: svn commit: r893267 - in
/subversion/trunk/subversion/libsvn_fs_base: bdb/node-origins-table.c
bdb/node-origins-table.h dag.c revs-txns.c
Posted by Julian Foad <ju...@btopenworld.com>.
I (Julian Foad) wrote:
> C. Michael Pilato wrote:
> > julianfoad@apache.org wrote:
> > > Author: julianfoad
> > > Date: Tue Dec 22 18:44:27 2009
> > > New Revision: 893267
> > >
> > > URL: http://svn.apache.org/viewvc?rev=893267&view=rev
> > > Log:
> > > For obliterate in BDB, implement updating the "node-origins" table.
> > >
> > > * subversion/libsvn_fs_base/bdb/node-origins-table.c,
> > > subversion/libsvn_fs_base/bdb/node-origins-table.h
> > > (svn_fs_bdb__change_node_origin): New function to overwrite an existing
> > > node-origins row.
> >
> > Why not just re-use the existing __delete_node_origin() and
> > __set_node_origin() functions?
[...]
> Thanks for the suggestions. I should do one or the other.
Done in r893309.
- Julian
Re: svn commit: r893267 - in
/subversion/trunk/subversion/libsvn_fs_base: bdb/node-origins-table.c
bdb/node-origins-table.h dag.c revs-txns.c
Posted by Julian Foad <ju...@btopenworld.com>.
C. Michael Pilato wrote:
> julianfoad@apache.org wrote:
> > Author: julianfoad
> > Date: Tue Dec 22 18:44:27 2009
> > New Revision: 893267
> >
> > URL: http://svn.apache.org/viewvc?rev=893267&view=rev
> > Log:
> > For obliterate in BDB, implement updating the "node-origins" table.
> >
> > * subversion/libsvn_fs_base/bdb/node-origins-table.c,
> > subversion/libsvn_fs_base/bdb/node-origins-table.h
> > (svn_fs_bdb__change_node_origin): New function to overwrite an existing
> > node-origins row.
>
> Why not just re-use the existing __delete_node_origin() and
> __set_node_origin() functions?
Good idea.
> Or a boolean 'allow_overwrite' flag to
> __set_node_origin()?
I had a perfectly good solution that just disabled that function's check
for not changing an existing entry, but I didn't want to change that
function in that way. I was reluctant to change it at all. But yes, I
could add such a flag.
> Disclaimer: I haven't examined in detail the nuances of the calling
> requirements of these various functions or your new one.
Thanks for the suggestions. I should do one or the other.
- Julian
p.s. Do we really want follow-ups on both the dev@ list and the commits@
list? I don't. I'm removing commits@.
Re: svn commit: r893267 - in /subversion/trunk/subversion/libsvn_fs_base:
bdb/node-origins-table.c bdb/node-origins-table.h dag.c revs-txns.c
Posted by "C. Michael Pilato" <cm...@collab.net>.
julianfoad@apache.org wrote:
> Author: julianfoad
> Date: Tue Dec 22 18:44:27 2009
> New Revision: 893267
>
> URL: http://svn.apache.org/viewvc?rev=893267&view=rev
> Log:
> For obliterate in BDB, implement updating the "node-origins" table.
>
> * subversion/libsvn_fs_base/bdb/node-origins-table.c,
> subversion/libsvn_fs_base/bdb/node-origins-table.h
> (svn_fs_bdb__change_node_origin): New function to overwrite an existing
> node-origins row.
Why not just re-use the existing __delete_node_origin() and
__set_node_origin() functions? Or a boolean 'allow_overwrite' flag to
__set_node_origin()?
Disclaimer: I haven't examined in detail the nuances of the calling
requirements of these various functions or your new one.
--
C. Michael Pilato <cm...@collab.net>
CollabNet <> www.collab.net <> Distributed Development On Demand
Re: svn commit: r893267 - in /subversion/trunk/subversion/libsvn_fs_base:
bdb/node-origins-table.c bdb/node-origins-table.h dag.c revs-txns.c
Posted by "C. Michael Pilato" <cm...@collab.net>.
julianfoad@apache.org wrote:
> Author: julianfoad
> Date: Tue Dec 22 18:44:27 2009
> New Revision: 893267
>
> URL: http://svn.apache.org/viewvc?rev=893267&view=rev
> Log:
> For obliterate in BDB, implement updating the "node-origins" table.
>
> * subversion/libsvn_fs_base/bdb/node-origins-table.c,
> subversion/libsvn_fs_base/bdb/node-origins-table.h
> (svn_fs_bdb__change_node_origin): New function to overwrite an existing
> node-origins row.
Why not just re-use the existing __delete_node_origin() and
__set_node_origin() functions? Or a boolean 'allow_overwrite' flag to
__set_node_origin()?
Disclaimer: I haven't examined in detail the nuances of the calling
requirements of these various functions or your new one.
--
C. Michael Pilato <cm...@collab.net>
CollabNet <> www.collab.net <> Distributed Development On Demand