[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

[PATCH] svn_fs__open_dag

From: Yoshiki Hayashi <yoshiki_at_xemacs.org>
Date: 2001-02-22 04:52:51 CET

I wanted to be more familiar with libsvn_fs code so I
started writing part of it. But be careful! This is my
first real function in subversion. You might want to
rewrite it from scratch. It does compile and I think it's
correct, though.

The upside of living in a different timezone is that it's
very unlikely that my work will collide with otheres. ;-)

I have one question with regard to svn_fs__dag_close which
was just deleted. It's still referenced by tree.c and I'd
like to resurrect it. It will call just apr_pool_destroy
(dag->pool) if I understand it correctly. The problem of
current implementation is that dag->pool points to
trail->pool. Shouldn't dag->pool be subpool of trail->pool?

Oh, the downside of different timezone is that we can't
communicate in real time basis. :-)

(svn_fs__dag_dup): New function.
(svn_fs__dag_open): Implement it.

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 03:51:05
@@ -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,45 @@
 }
 
 
-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)
+ {
+ /* Sanity check. All entry in dir must be a form of (NAME ID). */
+ if (entry->is_atom || ! entry->children->is_atom)
+ abort ();
+
+ if (! memcmp (entry->children->data, name, entry->children->len))
+ {
+ 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_error_createf
+ (SVN_ERR_FS_NOT_FOUND, 0, 0, trail->pool,
+ "entry not found: filesystem `%s', entry `%s'",
+ parent->fs->env_path, 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,

-- 
Yoshiki Hayashi
Received on Sat Oct 21 14:36:23 2006

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.