From: Florian Achleitner <florian.achleitner.2.6.31@gmail.com>
To: git@vger.kernel.org, David Michael Barr <davidbarr@google.com>,
Jonathan Nieder <jrnieder@gmail.com>
Cc: florian.achleitner.2.6.31@gmail.com
Subject: [PATCH 2/4] Allow reading svn dumps from files via file:// urls.
Date: Wed, 11 Jul 2012 15:38:51 +0200 [thread overview]
Message-ID: <1342013933-14381-3-git-send-email-florian.achleitner.2.6.31@gmail.com> (raw)
In-Reply-To: <1342013933-14381-2-git-send-email-florian.achleitner.2.6.31@gmail.com>
Especially for testing and development it's useful
to bypass svnrdump and replay the svndump from a file
without connecting to an svn server.
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 | 53 +++++++++++++++++++++++++++++--------------
1 file changed, 36 insertions(+), 17 deletions(-)
diff --git a/contrib/svn-fe/remote-svn.c b/contrib/svn-fe/remote-svn.c
index 5ec7fbb..a248166 100644
--- a/contrib/svn-fe/remote-svn.c
+++ b/contrib/svn-fe/remote-svn.c
@@ -26,6 +26,7 @@ static inline void printd(const char* fmt, ...)
static struct remote* remote;
static const char* url;
+static int dump_from_file;
const char* private_refs = "refs/remote-svn/"; /* + remote->name. */
const char* remote_ref = "refs/heads/master";
@@ -56,6 +57,7 @@ enum cmd_result cmd_import(struct strbuf* line)
const char* revs = "-r0:HEAD";
int code, report_fd;
char* back_pipe_env;
+ int dumpin_fd;
struct child_process svndump_proc = {
.argv = NULL, /* comes later .. */
/* we want a pipe to the child's stdout, but stdin, stderr inherited.
@@ -90,27 +92,35 @@ enum cmd_result cmd_import(struct strbuf* line)
printd("Opened fast-import back-pipe %s for reading.", back_pipe_env);
- svndump_proc.argv = xcalloc(5, sizeof(char*));
- svndump_proc.argv[0] = "svnrdump";
- svndump_proc.argv[1] = "dump";
- svndump_proc.argv[2] = url;
- svndump_proc.argv[3] = revs;
-
- code = start_command(&svndump_proc);
- if(code)
- die("Unable to start %s, code %d", svndump_proc.argv[0], code);
-
+ 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 {
+ svndump_proc.argv = xcalloc(5, sizeof(char*));
+ svndump_proc.argv[0] = "svnrdump";
+ svndump_proc.argv[1] = "dump";
+ svndump_proc.argv[2] = url;
+ svndump_proc.argv[3] = revs;
+
+ 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(svndump_proc.out, report_fd);
+ svndump_init_fd(dumpin_fd, report_fd);
svndump_read(url);
svndump_deinit();
svndump_reset();
- close(svndump_proc.out);
+ close(dumpin_fd);
close(report_fd);
-
- code = finish_command(&svndump_proc);
+ if(!dump_from_file)
+ code = finish_command(&svndump_proc);
if(code)
warning("Something went wrong with termination of %s, code %d", svndump_proc.argv[0], code);
free(svndump_proc.argv);
@@ -166,14 +176,23 @@ int main(int argc, const char **argv)
remote = remote_get(argv[1]);
if (argc == 3) {
- end_url_with_slash(&buf, argv[2]);
+ url = argv[2];
} else if (argc == 2) {
- end_url_with_slash(&buf, remote->url[0]);
+ url = remote->url[0];
} else {
warning("Excess arguments!");
}
- 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);
--
1.7.9.5
next prev parent reply other threads:[~2012-07-11 13:40 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-11 13:38 [RFC/PATCH 0/4] GSOC remote-svn Florian Achleitner
2012-07-11 13:38 ` [PATCH 1/4] vcs-svn: add fast_export_note to create notes Florian Achleitner
2012-07-11 13:38 ` Florian Achleitner [this message]
2012-07-11 13:38 ` [PATCH 3/4] Create a note for every imported commit containing svn metadata Florian Achleitner
2012-07-11 13:38 ` [PATCH 4/4] When debug==1, start fast-import with "--stats" instead of "--quiet" Florian Achleitner
2012-07-11 14:29 ` [PATCH 2/4] Allow reading svn dumps from files via file:// urls Dmitry Ivankov
2012-07-11 17:00 ` Junio C Hamano
2012-07-11 17:49 ` Stephen Bash
2012-07-15 14:26 ` [PATCH] Fix overwritten remote ref on with fast-import Florian Achleitner
2012-07-16 0:30 ` Jonathan Nieder
2012-07-16 4:33 ` Junio C Hamano
2012-07-16 22:33 ` Florian Achleitner
2012-07-17 3:27 ` Jonathan Nieder
2012-07-17 9:54 ` Florian Achleitner
2012-07-17 13:48 ` Jonathan Nieder
2012-07-17 20:52 ` Florian Achleitner
2012-07-17 21:02 ` Jonathan Nieder
2012-07-17 22:25 ` Florian Achleitner
2012-07-17 9:56 ` [PATCH] Add explanatory comment for transport-helpers refs mapping Florian Achleitner
2012-07-17 16:04 ` Jonathan Nieder
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=1342013933-14381-3-git-send-email-florian.achleitner.2.6.31@gmail.com \
--to=florian.achleitner.2.6.31@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).