Greg Stein <gstein@lyra.org> writes:
> > One more patch. This fixes the same bug GregS pointed out
> > to similar code.
>
> Actually, the right choice is to use svn_fs__is_atom() :-)
Ah, you mean svn_fs__matches_atom (). I grepped is_atom
instead of looking at skel.h and concluded it is not
implemented yet.
> What is the svn_fs__dag_dup function for? I didn't see it used anywhere. I'm
> not sure if "dup" makes sense (rather than multiple references), so you may
> want to omit that function until a need arises.
I'm not sure why dup is necessary but it's called from
tree.c L201, function root_node.
> Also, note that most FS errors are generated by functions in err.c. This
> would include a "corrupt <whatever>" rather than using abort(). The "not
> found" would also go into err.c
Thanks. I have much to learn. I'm not sure which error is
used here but I hope this one does things right.
(svn_fs__dag_dup): New function.
(svn_fs__dag_open): Implement it.
(svn_fs__err_no_such_entry): New function.
Index: dag.c
===================================================================
RCS file: /cvs/subversion/subversion/libsvn_fs/dag.c,v
retrieving revision 1.27
diff -u -r1.27 dag.c
--- dag.c 2001/02/21 23:28:27 1.27
+++ dag.c 2001/02/22 07:05:26
@@ -103,6 +103,15 @@
*/
+dag_node_t *
+svn_fs__dag_dup (dag_node_t *node,
+ trail_t *trail)
+{
+ dag_node_t *dag_dup = apr_palloc (trail->pool, sizeof (*node));
+ memcpy (dag_dup, node, sizeof (*node));
+ return dag_dup;
+}
+
const svn_fs_id_t *svn_fs__dag_get_id (dag_node_t *node)
{
return node->id;
@@ -159,7 +168,7 @@
itself a list. */
skel_t *header = node->contents->children;
- /* The 3nd element of the header, IF it exists, is the header's
+ /* The 3rd element of the header, IF it exists, is the header's
first `flag'. It could be NULL. */
skel_t *flag = header->children->next->next;
@@ -288,14 +297,42 @@
}
-svn_error_t *svn_fs__dag_open (dag_node_t **child_p,
- dag_node_t *parent,
- const char *name,
- trail_t *trail)
-{
- abort();
- /* NOTREACHED */
- return NULL;
+svn_error_t *
+svn_fs__dag_open (dag_node_t **child_p,
+ dag_node_t *parent,
+ const char *name,
+ trail_t *trail)
+{
+ /* (HEADER ENTRY ...) */
+ skel_t *entry = parent->contents->next;
+ dag_node_t *child = apr_palloc (trail->pool, sizeof (*child));
+
+ while (entry)
+ {
+ if (entry->is_atom)
+ return svn_fs__err_corrupt_node_revision (parent->fs, parent->id);
+
+ /* (NAME ID) */
+ if (svn_fs__matches_atom (entry->children, name))
+ {
+ skel_t *id = entry->children->next;
+ child->id = svn_fs_parse_id (id->data, id->len, trail->pool);
+ break;
+ }
+
+ entry = entry->next;
+ }
+
+ if (! child->id)
+ return svn_fs__err_no_such_entry (parent->fs, parent->id, name);
+
+ child->fs = parent->fs;
+ SVN_ERR (svn_fs__get_rep (&child->contents, child->fs, child->id, trail));
+
+ child->pool = trail->pool;
+ *child_p = child;
+
+ return SVN_NO_ERROR;
}
svn_error_t *svn_fs__dag_delete (dag_node_t *parent,
Index: err.c
===================================================================
RCS file: /cvs/subversion/subversion/libsvn_fs/err.c,v
retrieving revision 1.24
diff -u -r1.24 err.c
--- err.c 2001/02/15 23:02:13 1.24
+++ err.c 2001/02/22 07:05:26
@@ -238,7 +238,18 @@
path, fs->env_path);
}
+svn_error_t *
+svn_fs__err_no_such_entry (svn_fs_t *fs,
+ const svn_fs_id_t *id,
+ const char *name)
+{
+ svn_string_t *unparsed_id = svn_fs_unparse_id (id, fs->pool);
+ return svn_error_createf
+ (SVN_ERR_FS_NOT_FOUND, 0, 0, fs->pool,
+ "No entry named `%s' in filesystem `%s', directory revision `%s'",
+ name, fs->env_path, unparsed_id->data);
+}
/*
Index: err.h
===================================================================
RCS file: /cvs/subversion/subversion/libsvn_fs/err.h,v
retrieving revision 1.20
diff -u -r1.20 err.h
--- err.h 2001/02/15 23:02:13 1.20
+++ err.h 2001/02/22 07:05:27
@@ -133,6 +133,9 @@
/* SVN_ERR_FS_NOT_DIRECTORY: PATH does not refer to a directory in FS. */
svn_error_t *svn_fs__err_not_directory (svn_fs_t *fs, const char *path);
+/* SVN_ERR_FS_NOT_FOUND: NAME does not exists in directory ID in FS. */
+svn_error_t *svn_fs__err_no_such_entry (svn_fs_t *fs, const svn_fs_id_t *id,
+ const char *name);
#endif /* SVN_LIBSVN_FS_ERR_H */
--
Yoshiki Hayashi
Received on Sat Oct 21 14:36:23 2006