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

[RFC 07/16] Allow reading svn dumps from files via file:// urls.

From
Florian Achleitner <florian.achleitner.2.6.31@gmail.com>
Date
Jul 26, 2012, 07:32 UTC
Message-ID
<1343287957-22040-8-git-send-email-florian.achleitner.2.6.31@gmail.com>
In-Reply-To
<1343287957-22040-7-git-send-email-florian.achleitner.2.6.31@gmail.com>

For testing as well as for importing large, already available dumps, it's useful to bypass svnrdump and replay the svndump from a file directly.

Add support for file:// urls in the remote url. e.g. svn::file:///path/to/dump When the remote helper finds an url starting with file:// it tries to open that file instead of invoking svnrdump.

Signed-off-by: Florian Achleitner <florian.achleitner.2.6.31@gmail.com>
---
 contrib/svn-fe/remote-svn.c |   56 +++++++++++++++++++++++++++++--------------
 1 file changed, 38 insertions(+), 18 deletions(-)
diff --git a/contrib/svn-fe/remote-svn.c b/contrib/svn-fe/remote-svn.c
index 29fc371..862b739 100644
--- a/contrib/svn-fe/remote-svn.c
+++ b/contrib/svn-fe/remote-svn.c
@@ -23,6 +23,7 @@ static inline void printd(const char *fmt, ...)
 }
 
 static const char *url;
+static int dump_from_file;
 static const char *private_ref;
 static const char *remote_ref = "refs/heads/master";
 
@@ -105,18 +106,28 @@ enum cmd_result cmd_import(struct strbuf *line)
 	}
 	printd("Opened fast-import back-pipe %s for reading.", back_pipe_env);
 
-	memset(&svndump_proc, 0, sizeof (struct child_process));
-	svndump_proc.out = -1;
-	argv_array_push(&svndump_argv, "svnrdump");
-	argv_array_push(&svndump_argv, "dump");
-	argv_array_push(&svndump_argv, url);
-	argv_array_pushf(&svndump_argv, "-r%u:HEAD", startrev);
-	svndump_proc.argv = svndump_argv.argv;
+	if(dump_from_file) {
+		dumpin_fd = open(url, O_RDONLY);
+		if(dumpin_fd < 0) {
+			die_errno("Couldn't open svn dump file %s.", url);
+		}
+	}
+	else {
+		memset(&svndump_proc, 0, sizeof (struct child_process));
+		svndump_proc.out = -1;
+		argv_array_push(&svndump_argv, "svnrdump");
+		argv_array_push(&svndump_argv, "dump");
+		argv_array_push(&svndump_argv, url);
+		argv_array_pushf(&svndump_argv, "-r%u:HEAD", startrev);
+		svndump_proc.argv = svndump_argv.argv;
+
+		code = start_command(&svndump_proc);
+		if (code)
+			die("Unable to start %s, code %d", svndump_proc.argv[0], code);
+		dumpin_fd = svndump_proc.out;
+
+	}
 
-	code = start_command(&svndump_proc);
-	if (code)
-		die("Unable to start %s, code %d", svndump_proc.argv[0], code);
-	dumpin_fd = svndump_proc.out;
 
 	svndump_init_fd(dumpin_fd, report_fd);
 	svndump_read(url, private_ref);
@@ -125,10 +136,12 @@ enum cmd_result cmd_import(struct strbuf *line)
 
 	close(dumpin_fd);
 	close(report_fd);
-	code = finish_command(&svndump_proc);
-	if (code)
-		warning("%s, returned %d", svndump_proc.argv[0], code);
-	argv_array_clear(&svndump_argv);
+	if(!dump_from_file) {
+		code = finish_command(&svndump_proc);
+		if (code)
+			warning("%s, returned %d", svndump_proc.argv[0], code);
+		argv_array_clear(&svndump_argv);
+	}
 
 	return SUCCESS;
 }
@@ -191,9 +204,16 @@ int main(int argc, const char **argv)
 	else
 		warning("Excess arguments!");
 
-	end_url_with_slash(&buf, url);
-	url = strbuf_detach(&buf, NULL);
-
+	if (!prefixcmp(url, "file://")) {
+		dump_from_file = 1;
+		url = url_decode(url + sizeof("file://")-1);
+		printd("remote-svn uses a file as dump input.");
+	}
+	else {
+		dump_from_file = 0;
+		end_url_with_slash(&buf, url);
+		url = strbuf_detach(&buf, NULL);
+	}
 	printd("remote-svn starting with url %s", url);
 
 	strbuf_init(&buf, 0);
-- 
1.7.9.5
Previous: Florian AchleitnerNext: Florian Achleitner
Message 8 of 47 in “[RFC 00/16] GSOC remote-svn, rewritten patch series”
  1. Florian AchleitnerJul 26, 2012
  2. 01/16 Implement a remote helper for svn in C.Florian Achleitner, Jul 26, 2012
  3. 02/16 Integrate remote-svn into svn-fe/Makefile.Florian Achleitner, Jul 26, 2012
  4. 03/16 Add svndump_init_fd to allow reading dumps from arbitrary FDs.Florian Achleitner, Jul 26, 2012
  5. 04/16 Add cat-blob report fifo from fast-import to remote-helper.Florian Achleitner, Jul 26, 2012
  6. 05/16 remote-svn, vcs-svn: Enable fetching to private refs.Florian Achleitner, Jul 26, 2012
  7. 06/16 Add a symlink 'git-remote-svn' in base dir.Florian Achleitner, Jul 26, 2012
  8. 07/16 Allow reading svn dumps from files via file:// urls.Florian Achleitner, Jul 26, 2012
  9. 08/16 vcs-svn: add fast_export_note to create notesFlorian Achleitner, Jul 26, 2012
  10. 09/16 Create a note for every imported commit containing svn metadata.Florian Achleitner, Jul 26, 2012
  11. 10/16 When debug==1, start fast-import with "--stats" instead of "--quiet".Florian Achleitner, Jul 26, 2012
  12. 11/16 Add explanatory comment for transport-helpers refs mapping.Florian Achleitner, Jul 26, 2012
  13. 12/16 remote-svn: add incremental import.Florian Achleitner, Jul 26, 2012
  14. 13/16 Add a svnrdump-simulator replaying a dump file for testing.Florian Achleitner, Jul 26, 2012
  15. 14/16 transport-helper: add import|export-marks to fast-import command line.Florian Achleitner, Jul 26, 2012
  16. 15/16 remote-svn: add marks-file regeneration.Florian Achleitner, Jul 26, 2012
  17. 16/16 Add a test script for remote-svn.Florian Achleitner, Jul 26, 2012
  18. Florian AchleitnerJul 26, 2012
  19. Jonathan NiederJul 28, 2012
  20. Jonathan NiederJul 26, 2012
  21. Florian AchleitnerJul 26, 2012
  22. Jonathan NiederJul 26, 2012
  23. Florian AchleitnerJul 26, 2012
  24. 00/16 GSOC remote-svn, rewritten patch seriesFlorian Achleitner, Jul 30, 2012
  25. 01/16 Implement a remote helper for svn in C.Florian Achleitner, Jul 30, 2012
  26. 02/16 Integrate remote-svn into svn-fe/Makefile.Florian Achleitner, Jul 30, 2012
  27. 03/16 Add svndump_init_fd to allow reading dumps from arbitrary FDs.Florian Achleitner, Jul 30, 2012
  28. 04/16 Add cat-blob report fifo from fast-import to remote-helper.Florian Achleitner, Jul 30, 2012
  29. 05/16 remote-svn, vcs-svn: Enable fetching to private refs.Florian Achleitner, Jul 30, 2012
  30. 06/16 Add a symlink 'git-remote-svn' in base dir.Florian Achleitner, Jul 30, 2012
  31. 07/16 Allow reading svn dumps from files via file:// urls.Florian Achleitner, Jul 30, 2012
  32. 08/16 vcs-svn: add fast_export_note to create notesFlorian Achleitner, Jul 30, 2012
  33. 09/16 Create a note for every imported commit containing svn metadata.Florian Achleitner, Jul 30, 2012
  34. 10/16 When debug==1, start fast-import with "--stats" instead of "--quiet".Florian Achleitner, Jul 30, 2012
  35. 11/16 Add explanatory comment for transport-helpers refs mapping.Florian Achleitner, Jul 30, 2012
  36. 12/16 remote-svn: add incremental import.Florian Achleitner, Jul 30, 2012
  37. 13/16 Add a svnrdump-simulator replaying a dump file for testing.Florian Achleitner, Jul 30, 2012
  38. 14/16 transport-helper: add import|export-marks to fast-import command line.Florian Achleitner, Jul 30, 2012
  39. 15/16 remote-svn: add marks-file regeneration.Florian Achleitner, Jul 30, 2012
  40. 16/16 Add a test script for remote-svn.Florian Achleitner, Jul 30, 2012
  41. Jonathan NiederJul 30, 2012
  42. Junio C HamanoJul 30, 2012
  43. Junio C HamanoJul 30, 2012
  44. Jonathan NiederJul 30, 2012
  45. Florian AchleitnerJul 30, 2012
  46. Junio C HamanoJul 30, 2012
  47. Florian AchleitnerJul 31, 2012

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.