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

[PATCH 1/8] vcs-svn: move url parameter from _read to _init

From
Dmitry Ivankov <divanorama@gmail.com>
Date
Jul 3, 2011, 17:57 UTC
Message-ID
<1309715877-13814-2-git-send-email-divanorama@gmail.com>
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
Previous: Dmitry IvankovNext: Dmitry Ivankov
Message 2 of 14 in “vcs-svn, svn-fe: add a couple of options”
  1. 0/8 vcs-svn, svn-fe: add a couple of optionsDmitry Ivankov, Jul 3, 2011
  2. 1/8 vcs-svn: move url parameter from _read to _initDmitry Ivankov, Jul 3, 2011
  3. 2/8 svn-fe: add man target to MakefileDmitry Ivankov, Jul 3, 2011
  4. 3/8 svn-fe: add EXTLIBS needed for parse-optionsDmitry Ivankov, Jul 3, 2011
  5. 4/8 svn-fe: add usage and unpositional arguments versionsDmitry Ivankov, Jul 3, 2011
  6. 5/8 test-svn-fe: use parse-optionsDmitry Ivankov, Jul 3, 2011
  7. 6/8 vcs-svn: allow to specify dump destination refDmitry Ivankov, Jul 3, 2011
  8. 7/8 vcs-svn: convert REPORT_FILENO to an optionDmitry Ivankov, Jul 3, 2011
  9. Ramkumar RamachandraJul 6, 2011
  10. 8/8 vcs-svn: allow to disable 'progress' linesDmitry Ivankov, Jul 3, 2011
  11. Ramkumar RamachandraJul 6, 2011
  12. Dmitry IvankovJul 6, 2011
  13. Ramkumar RamachandraJul 6, 2011
  14. Sverre RabbelierJul 4, 2011

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.