git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dmitry Ivankov <divanorama@gmail.com>
To: git@vger.kernel.org
Cc: Jonathan Nieder <jrnieder@gmail.com>,
	David Barr <davidbarr@google.com>,
	Dmitry Ivankov <divanorama@gmail.com>
Subject: [PATCH 1/8] vcs-svn: move url parameter from _read to _init
Date: Sun,  3 Jul 2011 23:57:50 +0600	[thread overview]
Message-ID: <1309715877-13814-2-git-send-email-divanorama@gmail.com> (raw)
In-Reply-To: <1309715877-13814-1-git-send-email-divanorama@gmail.com>

svndump_read takes a url parameter that is used in git-svn-id: lines
generation. Internally it is stored in dump_ctx which is initialized
in svndump_init with reset_dump_ctx and then is reinitialized again
in svndump_read.

Move url parameter to svndump_init so that reset_dump_ctx is done
once per dump and in the same place as other resets. More parameters
will arise and all will go to svndump_init to setup the module for
dumping.

Signed-off-by: Dmitry Ivankov <divanorama@gmail.com>
---
 contrib/svn-fe/svn-fe.c |    4 ++--
 test-svn-fe.c           |    4 ++--
 vcs-svn/svndump.c       |    7 +++----
 vcs-svn/svndump.h       |    4 ++--
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/svn-fe/svn-fe.c b/contrib/svn-fe/svn-fe.c
index 35db24f..11d7128 100644
--- a/contrib/svn-fe/svn-fe.c
+++ b/contrib/svn-fe/svn-fe.c
@@ -8,9 +8,9 @@
 
 int main(int argc, char **argv)
 {
-	if (svndump_init(NULL))
+	if (svndump_init(NULL, (argc > 1) ? argv[1] : NULL))
 		return 1;
-	svndump_read((argc > 1) ? argv[1] : NULL);
+	svndump_read();
 	svndump_deinit();
 	svndump_reset();
 	return 0;
diff --git a/test-svn-fe.c b/test-svn-fe.c
index 332a5f7..3ee5559 100644
--- a/test-svn-fe.c
+++ b/test-svn-fe.c
@@ -40,9 +40,9 @@ static int apply_delta(int argc, char *argv[])
 int main(int argc, char *argv[])
 {
 	if (argc == 2) {
-		if (svndump_init(argv[1]))
+		if (svndump_init(argv[1], NULL))
 			return 1;
-		svndump_read(NULL);
+		svndump_read();
 		svndump_deinit();
 		svndump_reset();
 		return 0;
diff --git a/vcs-svn/svndump.c b/vcs-svn/svndump.c
index b1f4161..a88d392 100644
--- a/vcs-svn/svndump.c
+++ b/vcs-svn/svndump.c
@@ -313,14 +313,13 @@ static void end_revision(void)
 		fast_export_end_commit(rev_ctx.revision);
 }
 
-void svndump_read(const char *url)
+void svndump_read(void)
 {
 	char *val;
 	char *t;
 	uint32_t active_ctx = DUMP_CTX;
 	uint32_t len;
 
-	reset_dump_ctx(url);
 	while ((t = buffer_read_line(&input))) {
 		val = strchr(t, ':');
 		if (!val)
@@ -455,7 +454,7 @@ void svndump_read(const char *url)
 		end_revision();
 }
 
-int svndump_init(const char *filename)
+int svndump_init(const char *filename, const char *url)
 {
 	if (buffer_init(&input, filename))
 		return error("cannot open %s: %s", filename, strerror(errno));
@@ -466,7 +465,7 @@ int svndump_init(const char *filename)
 	strbuf_init(&rev_ctx.author, 4096);
 	strbuf_init(&node_ctx.src, 4096);
 	strbuf_init(&node_ctx.dst, 4096);
-	reset_dump_ctx(NULL);
+	reset_dump_ctx(url);
 	reset_rev_ctx(0);
 	reset_node_ctx(NULL);
 	return 0;
diff --git a/vcs-svn/svndump.h b/vcs-svn/svndump.h
index df9ceb0..1bcaab6 100644
--- a/vcs-svn/svndump.h
+++ b/vcs-svn/svndump.h
@@ -1,8 +1,8 @@
 #ifndef SVNDUMP_H_
 #define SVNDUMP_H_
 
-int svndump_init(const char *filename);
-void svndump_read(const char *url);
+int svndump_init(const char *filename, const char *url);
+void svndump_read(void);
 void svndump_deinit(void);
 void svndump_reset(void);
 
-- 
1.7.3.4

  reply	other threads:[~2011-07-03 17:56 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-03 17:57 [PATCH 0/8] vcs-svn, svn-fe: add a couple of options Dmitry Ivankov
2011-07-03 17:57 ` Dmitry Ivankov [this message]
2011-07-03 17:57 ` [PATCH 2/8] svn-fe: add man target to Makefile Dmitry Ivankov
2011-07-03 17:57 ` [PATCH 3/8] svn-fe: add EXTLIBS needed for parse-options Dmitry Ivankov
2011-07-03 17:57 ` [PATCH 4/8] svn-fe: add usage and unpositional arguments versions Dmitry Ivankov
2011-07-03 17:57 ` [PATCH 5/8] test-svn-fe: use parse-options Dmitry Ivankov
2011-07-03 17:57 ` [PATCH 6/8] vcs-svn: allow to specify dump destination ref Dmitry Ivankov
2011-07-03 17:57 ` [PATCH 7/8] vcs-svn: convert REPORT_FILENO to an option Dmitry Ivankov
2011-07-06 10:09   ` Ramkumar Ramachandra
2011-07-03 17:57 ` [PATCH 8/8] vcs-svn: allow to disable 'progress' lines Dmitry Ivankov
2011-07-06  8:25   ` Ramkumar Ramachandra
2011-07-06 10:14     ` Dmitry Ivankov
2011-07-06 11:40       ` Ramkumar Ramachandra
2011-07-04 11:06 ` [PATCH 0/8] vcs-svn, svn-fe: add a couple of options Sverre Rabbelier

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=1309715877-13814-2-git-send-email-divanorama@gmail.com \
    --to=divanorama@gmail.com \
    --cc=davidbarr@google.com \
    --cc=git@vger.kernel.org \
    --cc=jrnieder@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).