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>,
avarb@gmail.com, Daniel Shahaf <d.s@daniel.shahaf.name>,
Bert Huijben <rhuijben@collab.net>,
Junio C Hamano <gitster@pobox.com>,
Eric Wong <normalperson@yhbt.net>,
dev@subversion.apache.org
Subject: [PATCH 11/13] Implement apply_textdelta
Date: Wed, 7 Jul 2010 02:14:51 +0200 [thread overview]
Message-ID: <1278461693-3828-12-git-send-email-artagnon@gmail.com> (raw)
In-Reply-To: <1278461693-3828-1-git-send-email-artagnon@gmail.com>
apply_textdelta picks up information from the file_baton (set by
add_file or open_file) and sets handler/ handler_baton to write a text
delta. It uses a temporary file because the content length of the
delta needs to be determined. Also add a related window_handler helper
function gets the path of the temporary file written and cleans up
after apply_textdelta. The text and prop deltas will finally be dumped
in close_file.
Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
---
dump_editor.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
dumpr_util.h | 15 ++++++++++++++
2 files changed, 74 insertions(+), 1 deletions(-)
diff --git a/dump_editor.c b/dump_editor.c
index 7006a2c..51d5ebe 100644
--- a/dump_editor.c
+++ b/dump_editor.c
@@ -452,11 +452,69 @@ svn_error_t *change_file_prop(void *file_baton,
return SVN_NO_ERROR;
}
+svn_error_t *window_handler(svn_txdelta_window_t *window, void *baton)
+{
+ struct handler_baton *hb = baton;
+ struct edit_baton *eb = hb->eb;
+ svn_error_t *err;
+
+ err = hb->apply_handler(window, hb->apply_baton);
+ if (window != NULL && !err)
+ return SVN_NO_ERROR;
+
+ if (err)
+ SVN_ERR(err);
+
+ /* Write information about the filepath to hb->eb */
+ eb->temp_filepath = apr_pstrdup(eb->pool,
+ hb->temp_filepath);
+
+ /* Cleanup */
+ SVN_ERR(svn_io_file_close(hb->temp_file, hb->pool));
+ SVN_ERR(svn_stream_close(hb->temp_filestream));
+ svn_pool_destroy(hb->pool);
+ 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)
{
+ svn_stream_t *source_stream;
+ struct edit_baton *eb = file_baton;
+ apr_status_t apr_err;
+
+ /* Custom handler_baton allocated in a separate pool */
+ apr_pool_t *handler_pool = svn_pool_create(pool);
+ struct handler_baton *hb = apr_pcalloc(handler_pool, sizeof(*hb));
+ hb->pool = handler_pool;
+ hb->eb = eb;
+
+ /* Unset both handlers: To be set by two different functions later */
+ hb->apply_handler = NULL;
+
+ /* Use a temporary file to measure the text-content-length */
+ hb->temp_filepath = apr_psprintf(eb->pool, "/tmp/svn-fe/XXXXXX");
+ apr_err = apr_file_mktemp(&(hb->temp_file), hb->temp_filepath,
+ APR_CREATE | APR_READ | APR_WRITE | APR_EXCL,
+ hb->pool);
+ if (apr_err != APR_SUCCESS)
+ SVN_ERR(svn_error_wrap_apr(apr_err, NULL));
+
+ hb->temp_filestream = svn_stream_from_aprfile2(hb->temp_file, TRUE, hb->pool);
+ source_stream = svn_stream_empty(hb->pool);
+
+ /* Prepare to write the delta to the temporary file */
+ svn_txdelta_to_svndiff2(&(hb->apply_handler), &(hb->apply_baton),
+ hb->temp_filestream, 0, hb->pool);
+ must_dump_text = TRUE;
+
+ /* The actual writing takes place when this function has finished */
+ /* Set the handler and handler_baton */
+ *handler = window_handler;
+ *handler_baton = hb;
+
return SVN_NO_ERROR;
}
@@ -493,7 +551,7 @@ svn_error_t *get_dump_editor(const svn_delta_editor_t **editor,
de->close_directory = close_directory;
de->change_dir_prop = change_dir_prop;
de->change_file_prop = change_file_prop;
- /* de->apply_textdelta = apply_textdelta; */
+ de->apply_textdelta = apply_textdelta;
de->add_file = add_file;
de->open_file = open_file;
de->close_file = close_file;
diff --git a/dumpr_util.h b/dumpr_util.h
index 79de1ab..3830a1d 100644
--- a/dumpr_util.h
+++ b/dumpr_util.h
@@ -61,6 +61,21 @@ struct dir_baton {
apr_pool_t *pool;
};
+struct handler_baton
+{
+ svn_txdelta_window_handler_t apply_handler;
+ void *apply_baton;
+ apr_pool_t *pool;
+
+ /* Information about the path of the tempoarary file used */
+ char *temp_filepath;
+ apr_file_t *temp_file;
+ svn_stream_t *temp_filestream;
+
+ /* To fill in the edit baton fields */
+ struct edit_baton *eb;
+};
+
void write_hash_to_stringbuf(apr_hash_t *properties,
svn_boolean_t deleted,
svn_stringbuf_t **strbuf,
--
1.7.1
next prev parent reply other threads:[~2010-07-07 0:14 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-07-07 0:14 [GSoC update] git-remote-svn: Week 10 Ramkumar Ramachandra
2010-07-07 0:14 ` [PATCH 01/13] Add LICENSE Ramkumar Ramachandra
2010-07-07 0:14 ` [PATCH 02/13] Add skeleton SVN client and Makefile Ramkumar Ramachandra
2010-07-07 16:25 ` Jonathan Nieder
2010-07-07 17:09 ` Ramkumar Ramachandra
2010-07-07 19:30 ` Jonathan Nieder
2010-07-07 20:47 ` Ramkumar Ramachandra
2010-07-07 17:51 ` Daniel Shahaf
2010-07-07 0:14 ` [PATCH 03/13] Add debug editor from Subversion trunk Ramkumar Ramachandra
2010-07-07 17:55 ` Jonathan Nieder
2010-07-07 0:14 ` [PATCH 04/13] Add skeleton dump editor Ramkumar Ramachandra
2010-07-07 18:16 ` Jonathan Nieder
2010-07-08 6:17 ` Ramkumar Ramachandra
2010-07-07 0:14 ` [PATCH 05/13] Drive the debug editor Ramkumar Ramachandra
2010-07-07 18:26 ` Jonathan Nieder
2010-07-07 19:08 ` Ramkumar Ramachandra
2010-07-07 19:53 ` Jonathan Nieder
2010-07-08 6:04 ` Ramkumar Ramachandra
2010-07-07 0:14 ` [PATCH 06/13] Dump the revprops at the start of every revision Ramkumar Ramachandra
2010-07-07 19:04 ` Jonathan Nieder
2010-07-21 18:55 ` Ramkumar Ramachandra
2010-07-26 14:03 ` Julian Foad
2010-07-26 17:53 ` Ramkumar Ramachandra
2010-07-07 0:14 ` [PATCH 07/13] Implement open_root and close_edit Ramkumar Ramachandra
2010-07-07 0:14 ` [PATCH 08/13] Implement dump_node Ramkumar Ramachandra
2010-07-07 0:14 ` [PATCH 09/13] Implement directory-related functions Ramkumar Ramachandra
2010-07-07 0:14 ` [PATCH 10/13] Implement file-related functions Ramkumar Ramachandra
2010-07-07 0:14 ` Ramkumar Ramachandra [this message]
2010-07-07 0:14 ` [PATCH 12/13] Implement close_file Ramkumar Ramachandra
2010-07-07 0:14 ` [PATCH 13/13] Add a validation script Ramkumar Ramachandra
2010-07-07 20:24 ` [GSoC update] git-remote-svn: Week 10 Ramkumar Ramachandra
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1278461693-3828-12-git-send-email-artagnon@gmail.com \
--to=artagnon@gmail.com \
--cc=avarb@gmail.com \
--cc=d.s@daniel.shahaf.name \
--cc=david.barr@cordelta.com \
--cc=dev@subversion.apache.org \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=jrnieder@gmail.com \
--cc=normalperson@yhbt.net \
--cc=rhuijben@collab.net \
--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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).