git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ramkumar Ramachandra <artagnon@gmail.com>
To: "Git Mailing List" <git@vger.kernel.org>
Cc: David Michael Barr <david.barr@cordelta.com>,
	Jonathan Nieder <jrnieder@gmail.com>,
	Sverre Rabbelier <srabbelier@gmail.com>,
	Daniel Shahaf <daniel@shahaf.name>
Subject: [WIP PATCH 6/7] Add file_baton and trigger dump_node in change_file_prop
Date: Wed, 23 Jun 2010 18:22:19 +0200	[thread overview]
Message-ID: <1277310140-16891-7-git-send-email-artagnon@gmail.com> (raw)
In-Reply-To: <1277310140-16891-1-git-send-email-artagnon@gmail.com>

Add a file_baton structure, and fill it in in open_file and add_file
functions. It is to be used by apply_textdelta and change_file_prop
functions. Trigger dump_node in change_file_prop. Dump the actual
properties along with the property lengths.

Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
---
 dump_editor.c |  100 ++++++++++++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 89 insertions(+), 11 deletions(-)

diff --git a/dump_editor.c b/dump_editor.c
index a80d711..7bd00a4 100644
--- a/dump_editor.c
+++ b/dump_editor.c
@@ -15,7 +15,6 @@
 
 #define ARE_VALID_COPY_ARGS(p,r) ((p) && SVN_IS_VALID_REVNUM(r))
 
-static svn_boolean_t must_dump_text = FALSE, must_dump_props = FALSE;
 static svn_boolean_t text_changed = FALSE, props_changed = FALSE;
 
 struct edit_baton {
@@ -66,9 +65,16 @@ struct dir_baton {
 	apr_pool_t *pool;
 };
 
+struct file_baton {
+	/* Store the path of the file */
+	const char *path;
+	struct edit_baton *eb;
+};
+
 static void write_hash_to_stringbuf(apr_hash_t *hash,
                                     svn_stringbuf_t **strbuf,
-                                    apr_pool_t *pool) {
+                                    apr_pool_t *pool)
+{
 	apr_hash_index_t *this;
 	*strbuf = svn_stringbuf_create("", pool);
 
@@ -120,7 +126,8 @@ struct dir_baton *make_dir_baton(const char *path,
                                  void *edit_baton,
                                  void *parent_dir_baton,
                                  svn_boolean_t added,
-                                 apr_pool_t *pool) {
+                                 apr_pool_t *pool)
+{
 	struct edit_baton *eb = edit_baton;
 	struct dir_baton *pb = parent_dir_baton;
 	struct dir_baton *new_db = apr_pcalloc(pool, sizeof(*new_db));
@@ -156,6 +163,18 @@ struct dir_baton *make_dir_baton(const char *path,
 	return new_db;
 }
 
+struct file_baton *make_file_baton(struct edit_baton *eb,
+                                   const char *path,
+                                   apr_pool_t *pool)
+{
+	struct file_baton *new_fb = apr_pcalloc(pool, sizeof(struct file_baton));
+	new_fb->path = apr_pcalloc(pool, sizeof(const char *));
+	new_fb->path = path;
+	new_fb->eb = eb;
+
+	return new_fb;
+}
+
 static svn_error_t *dump_node(struct edit_baton *eb,
                               const char *path,    /* an absolute path. */
                               svn_node_kind_t kind,
@@ -170,6 +189,7 @@ static svn_error_t *dump_node(struct edit_baton *eb,
 	svn_revnum_t compare_rev = eb->current_rev - 1;
 	svn_stringbuf_t *propstring;
 	svn_filesize_t content_length = 0;
+	svn_boolean_t must_dump_text = FALSE, must_dump_props = FALSE;
 
 	/* Write out metadata headers for this file node. */
 	SVN_ERR(svn_stream_printf(eb->stream, pool,
@@ -310,10 +330,44 @@ static svn_error_t *dump_node(struct edit_baton *eb,
 		                          SVN_REPOS_DUMPFILE_PROP_CONTENT_LENGTH
 		                          ": %" APR_SIZE_T_FMT "\n", proplen));
 	}
+
+	/* If we are supposed to dump text, write out a text length header
+	   here, and an MD5 checksum (if available). */
 	if (must_dump_text && (kind == svn_node_file)) {
-		/* svn_stream_t *contents; */
 		;
 	}
+
+	/* 'Content-length:' is the last header before we dump the content,
+	   and is the sum of the text and prop contents lengths.  We write
+	   this only for the benefit of non-Subversion RFC-822 parsers. */
+	SVN_ERR(svn_stream_printf(eb->stream, pool,
+	                          SVN_REPOS_DUMPFILE_CONTENT_LENGTH
+	                          ": %" SVN_FILESIZE_T_FMT "\n\n",
+	                          content_length));
+
+	/* Now dump the text and properties */
+	if (must_dump_props)
+	{
+		len = propstring->len;
+		SVN_ERR(svn_stream_write(eb->stream, propstring->data, &len));
+	}
+	/* if (must_dump_text && (kind == svn_node_file)) */
+	/* { */
+	/* 	svn_stream_t *contents; */
+
+	/* 	if (delta_file) */
+	/* 	{ */
+	/* 		/\* Make sure to close the underlying file when the stream is */
+	/* 		   closed. *\/ */
+	/* 		contents = svn_stream_from_aprfile2(delta_file, FALSE, pool); */
+	/* 	} */
+	/* 	else */
+	/* 		SVN_ERR(svn_fs_file_contents(&contents, eb->fs_root, path, pool)); */
+
+	/* 	SVN_ERR(svn_stream_copy3(contents, svn_stream_disown(eb->stream, pool), */
+	/* 	                         NULL, NULL, pool)); */
+	/* } */
+
 	return SVN_NO_ERROR;
 }
 svn_error_t *open_root(void *edit_baton,
@@ -467,12 +521,12 @@ svn_error_t *add_file(const char *path,
 		/* delete the path, it's now been dumped. */
 		apr_hash_set(pb->deleted_entries, path, APR_HASH_KEY_STRING, NULL);
 
-	/* TODO: Store the delta in file_baton */
-	*file_baton = NULL;
+	/* Build a nice file baton to pass to change_file_prop and apply_textdelta */
+	*file_baton = make_file_baton(eb, path, pool);
+
 	return SVN_NO_ERROR;
 }
 
-
 svn_error_t *open_file(const char *path,
                        void *parent_baton,
                        svn_revnum_t ancestor_revision,
@@ -497,9 +551,10 @@ svn_error_t *open_file(const char *path,
 	SVN_ERR(dump_node(eb, path,
 	                  svn_node_file, svn_node_action_change,
 	                  FALSE, cmp_path, cmp_rev, pool));
-
-	/* TODO: Store the delta in file_baton */
-	*file_baton = NULL;
+	
+	/* Build a nice file baton to pass to change_file_prop and apply_textdelta */
+	*file_baton = make_file_baton(eb, path, pool);
+	
 	return SVN_NO_ERROR;
 }
 
@@ -532,6 +587,29 @@ svn_error_t *change_dir_prop(void *parent_baton,
 	return SVN_NO_ERROR;
 }
 
+svn_error_t *change_file_prop(void *file_baton,
+                              const char *name,
+                              const svn_string_t *value,
+                              apr_pool_t *pool)
+{
+	struct file_baton *fb = file_baton;
+	
+	if (svn_property_kind(NULL, name) != svn_prop_regular_kind)
+		return SVN_NO_ERROR;
+
+	value ? apr_hash_set(fb->eb->properties, apr_pstrdup(pool, name),
+	                     APR_HASH_KEY_STRING, svn_string_dup(value, pool)) :
+		apr_hash_set(fb->eb->del_properties, apr_pstrdup(pool, name),
+		             APR_HASH_KEY_STRING, (void *)0x1);
+	props_changed = TRUE;
+	
+	SVN_ERR(dump_node(fb->eb, fb->path,
+	                  svn_node_dir, svn_node_action_change,
+	                  FALSE, NULL, 0, pool));
+
+	return SVN_NO_ERROR;
+}
+
 svn_error_t *get_dump_editor(const svn_delta_editor_t **editor,
                              void **edit_baton,
                              svn_revnum_t to_rev,
@@ -545,7 +623,6 @@ svn_error_t *get_dump_editor(const svn_delta_editor_t **editor,
 	eb->current_rev = to_rev;
 	eb->properties = apr_hash_make(pool);
 	eb->del_properties = apr_hash_make(pool);
-	eb->delta_text = apr_pcalloc(pool, sizeof(const char *));
 
 	dump_editor->open_root = open_root;
 	dump_editor->delete_entry = delete_entry;
@@ -553,6 +630,7 @@ svn_error_t *get_dump_editor(const svn_delta_editor_t **editor,
 	dump_editor->open_directory = open_directory;
 	dump_editor->close_directory = close_directory;
 	dump_editor->change_dir_prop = change_dir_prop;
+	dump_editor->change_file_prop = change_file_prop;	
 	dump_editor->add_file = add_file;
 	dump_editor->open_file = open_file;
 
-- 
1.7.1

  parent reply	other threads:[~2010-06-23 16:21 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-23 16:22 [GSoC update] git-remote-svn: Week 8 Ramkumar Ramachandra
2010-06-23 16:22 ` [WIP PATCH 1/7] Add skeleton RA svnclient Ramkumar Ramachandra
2010-06-25  0:14   ` Jonathan Nieder
2010-06-25  9:07     ` Daniel Shahaf
2010-06-25 11:07       ` Ramkumar Ramachandra
2010-06-25 11:30         ` Daniel Shahaf
2010-06-25 15:30           ` OT: typesafe callbacks in C (Re: [WIP PATCH 1/7] Add skeleton RA svnclient) Jonathan Nieder
2010-06-25 14:45         ` [WIP PATCH 1/7] Add skeleton RA svnclient Jonathan Nieder
2010-06-25 13:34       ` Jonathan Nieder
2010-06-23 16:22 ` [WIP PATCH 2/7] Add stripped dump editor Ramkumar Ramachandra
2010-06-23 16:22 ` [WIP PATCH 3/7] Import dump_node to dump what changed and cleanup whitespace Ramkumar Ramachandra
2010-06-23 17:05   ` Ramkumar Ramachandra
2010-06-23 16:22 ` [WIP PATCH 4/7] Replace deprecated svn_path_join Ramkumar Ramachandra
2010-06-23 16:22 ` [WIP PATCH 5/7] Trigger dump_node in change_dir_prop Ramkumar Ramachandra
2010-06-23 16:22 ` Ramkumar Ramachandra [this message]
2010-06-23 16:22 ` [WIP PATCH 7/7] Dump the text delta Ramkumar Ramachandra
2010-06-23 17:18 ` [GSoC update] git-remote-svn: Week 8 Ramkumar Ramachandra
2010-06-25  0:42   ` Jonathan Nieder

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1277310140-16891-7-git-send-email-artagnon@gmail.com \
    --to=artagnon@gmail.com \
    --cc=daniel@shahaf.name \
    --cc=david.barr@cordelta.com \
    --cc=git@vger.kernel.org \
    --cc=jrnieder@gmail.com \
    --cc=srabbelier@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).