git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[WIP PATCH 7/7] Dump the text delta

From
Ramkumar Ramachandra <artagnon@gmail.com>
Date
Jun 23, 2010, 16:22 UTC
Message-ID
<1277310140-16891-8-git-send-email-artagnon@gmail.com>
In-Reply-To
<1277310140-16891-1-git-send-email-artagnon@gmail.com>

Add a handler and handler_baton to handle text deltas in the editor baton. Currently, program exits with code 01 because delta source ends unexpectedly.

Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
---
 dump_editor.c |   51 +++++++++++++++++++++++++++++++--------------------
 1 files changed, 31 insertions(+), 20 deletions(-)
diff --git a/dump_editor.c b/dump_editor.c
index 7bd00a4..2192177 100644
--- a/dump_editor.c
+++ b/dump_editor.c
@@ -27,12 +27,13 @@ struct edit_baton {
 	apr_hash_t *properties;
 	apr_hash_t *del_properties; /* Value is always 0x1 */
 
-	/* Store the text delta */
-	const char *delta_text;
-
 	/* reusable buffer for writing file contents */
 	char buffer[SVN__STREAM_CHUNK_SIZE];
 	apr_size_t bufsize;
+
+	/* The txdelta handler and handler baton */
+	svn_txdelta_window_handler_t *handler;
+	void **handler_baton;
 };
 
 struct dir_baton {
@@ -351,22 +352,9 @@ static svn_error_t *dump_node(struct edit_baton *eb,
 		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)); */
-	/* } */
+	if (must_dump_text && (kind == svn_node_file) && eb->handler) {
+		svn_txdelta_to_svndiff2(eb->handler, eb->handler_baton, eb->stream, 0, pool);
+	}
 
 	return SVN_NO_ERROR;
 }
@@ -610,6 +598,28 @@ svn_error_t *change_file_prop(void *file_baton,
 	return SVN_NO_ERROR;
 }
 
+svn_error_t *apply_textdelta(void *file_baton, const char *base_checksum,
+                             apr_pool_t *pool,
+                             svn_txdelta_window_handler_t *handler,
+                             void **handler_baton)
+{
+	struct file_baton *fb = file_baton;
+	svn_stream_t *source_stream = svn_stream_empty(pool);
+	svn_txdelta_apply(source_stream, fb->eb->stream,
+	                  NULL, fb->path, pool, handler,
+	                  handler_baton);
+	fb->eb->handler = handler;
+	fb->eb->handler_baton = handler_baton;
+
+	text_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,
@@ -630,7 +640,8 @@ 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->change_file_prop = change_file_prop;
+	dump_editor->apply_textdelta = apply_textdelta;
 	dump_editor->add_file = add_file;
 	dump_editor->open_file = open_file;
 
-- 
1.7.1
Previous: Ramkumar RamachandraNext: Ramkumar Ramachandra
Message 16 of 18 in “[GSoC update] git-remote-svn: Week 8”
  1. Ramkumar RamachandraJun 23, 2010
  2. 1/7 Add skeleton RA svnclientRamkumar Ramachandra, Jun 23, 2010
  3. Jonathan NiederJun 25, 2010
  4. Daniel ShahafJun 25, 2010
  5. Ramkumar RamachandraJun 25, 2010
  6. Daniel ShahafJun 25, 2010
  7. OT: typesafe callbacks in C (Re: [WIP PATCH 1/7] Add skeleton RA svnclient)Jonathan Nieder, Jun 25, 2010
  8. Jonathan NiederJun 25, 2010
  9. Jonathan NiederJun 25, 2010
  10. 2/7 Add stripped dump editorRamkumar Ramachandra, Jun 23, 2010
  11. 3/7 Import dump_node to dump what changed and cleanup whitespaceRamkumar Ramachandra, Jun 23, 2010
  12. Ramkumar RamachandraJun 23, 2010
  13. 4/7 Replace deprecated svn_path_joinRamkumar Ramachandra, Jun 23, 2010
  14. 5/7 Trigger dump_node in change_dir_propRamkumar Ramachandra, Jun 23, 2010
  15. 6/7 Add file_baton and trigger dump_node in change_file_propRamkumar Ramachandra, Jun 23, 2010
  16. 7/7 Dump the text deltaRamkumar Ramachandra, Jun 23, 2010
  17. Ramkumar RamachandraJun 23, 2010
  18. Jonathan NiederJun 25, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.