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 07/13] Implement open_root and close_edit
Date: Wed, 7 Jul 2010 02:14:47 +0200 [thread overview]
Message-ID: <1278461693-3828-8-git-send-email-artagnon@gmail.com> (raw)
In-Reply-To: <1278461693-3828-1-git-send-email-artagnon@gmail.com>
open_root first creates a special edit_baton pool, and then allocates
memory from that pool to various items in edit_baton. Then it creates
a new directory baton to set as the root_baton. close_edit destroys
the special edit_baton pool (hence destroying all the items that were
allocated there), and increments current_rev. Add related
make_dir_baton function and dir_baton_t structure.
Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
---
dump_editor.c | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
dumpr_util.h | 30 ++++++++++++++++++++++++
2 files changed, 100 insertions(+), 0 deletions(-)
diff --git a/dump_editor.c b/dump_editor.c
index 70d6c0b..6e9b0f5 100644
--- a/dump_editor.c
+++ b/dump_editor.c
@@ -15,11 +15,77 @@
#include "dumpr_util.h"
+
+/* Make a directory baton to represent the directory was path
+ (relative to EDIT_BATON's path) is PATH.
+
+ CMP_PATH/CMP_REV are the path/revision against which this directory
+ should be compared for changes. If either is omitted (NULL for the
+ path, SVN_INVALID_REVNUM for the rev), just compare this directory
+ PATH against itself in the previous revision.
+
+ PARENT_DIR_BATON is the directory baton of this directory's parent,
+ or NULL if this is the top-level directory of the edit. ADDED
+ indicated if this directory is newly added in this revision.
+ Perform all allocations in POOL. */
+struct dir_baton *make_dir_baton(const char *path,
+ const char *cmp_path,
+ svn_revnum_t cmp_rev,
+ void *edit_baton,
+ void *parent_dir_baton,
+ svn_boolean_t added,
+ 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));
+ const char *full_path;
+ apr_array_header_t *compose_path = apr_array_make(pool, 2, sizeof(const char *));
+
+ /* A path relative to nothing? I don't think so. */
+ SVN_ERR_ASSERT_NO_RETURN(!path || pb);
+
+ /* Construct the full path of this node. */
+ if (pb) {
+ APR_ARRAY_PUSH(compose_path, const char *) = "/";
+ APR_ARRAY_PUSH(compose_path, const char *) = path;
+ full_path = svn_path_compose(compose_path, pool);
+ }
+ else
+ full_path = apr_pstrdup(pool, "/");
+
+ /* Remove leading slashes from copyfrom paths. */
+ if (cmp_path)
+ cmp_path = ((*cmp_path == '/') ? cmp_path + 1 : cmp_path);
+
+ new_db->eb = eb;
+ new_db->parent_dir_baton = pb;
+ new_db->path = full_path;
+ new_db->cmp_path = cmp_path ? apr_pstrdup(pool, cmp_path) : NULL;
+ new_db->cmp_rev = cmp_rev;
+ new_db->added = added;
+ new_db->written_out = FALSE;
+ new_db->deleted_entries = apr_hash_make(pool);
+ new_db->pool = pool;
+
+ return new_db;
+}
svn_error_t *open_root(void *edit_baton,
svn_revnum_t base_revision,
apr_pool_t *pool,
void **root_baton)
{
+ /* Allocate a special pool for the edit_baton to avoid pool
+ lifetime issues */
+ struct edit_baton *eb = edit_baton;
+ eb->pool = svn_pool_create(pool);
+ eb->properties = apr_hash_make(eb->pool);
+ eb->del_properties = apr_hash_make(eb->pool);
+ eb->propstring = svn_stringbuf_create("", eb->pool);
+ eb->is_copy = FALSE;
+
+ *root_baton = make_dir_baton(NULL, NULL, SVN_INVALID_REVNUM,
+ edit_baton, NULL, FALSE, pool);
return SVN_NO_ERROR;
}
@@ -108,6 +174,10 @@ svn_error_t *close_file(void *file_baton,
svn_error_t *close_edit(void *edit_baton, apr_pool_t *pool)
{
+ struct edit_baton *eb = edit_baton;
+ svn_pool_destroy(eb->pool);
+ (eb->current_rev) ++;
+
return SVN_NO_ERROR;
}
diff --git a/dumpr_util.h b/dumpr_util.h
index 1a5752b..96670ff 100644
--- a/dumpr_util.h
+++ b/dumpr_util.h
@@ -31,6 +31,36 @@ struct edit_baton {
svn_checksum_t *checksum;
};
+struct dir_baton {
+ struct edit_baton *eb;
+ struct dir_baton *parent_dir_baton;
+
+ /* is this directory a new addition to this revision? */
+ svn_boolean_t added;
+
+ /* has this directory been written to the output stream? */
+ svn_boolean_t written_out;
+
+ /* the absolute path to this directory */
+ const char *path;
+
+ /* the comparison path and revision of this directory. if both of
+ these are valid, use them as a source against which to compare
+ the directory instead of the default comparison source of PATH in
+ the previous revision. */
+ const char *cmp_path;
+ svn_revnum_t cmp_rev;
+
+ /* hash of paths that need to be deleted, though some -might- be
+ replaced. maps const char * paths to this dir_baton. (they're
+ full paths, because that's what the editor driver gives us. but
+ really, they're all within this directory.) */
+ apr_hash_t *deleted_entries;
+
+ /* pool to be used for deleting the hash items */
+ apr_pool_t *pool;
+};
+
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:13 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 ` Ramkumar Ramachandra [this message]
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 ` [PATCH 11/13] Implement apply_textdelta Ramkumar Ramachandra
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-8-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).