remote-svn, vcs-svn: Enable fetching to private refs

The reference to update by the fast-import stream is hard-coded. When fetching from a remote the remote-helper shall update refs in a private namespace, i.e. a private subdir of refs/. This namespace is defined by the 'refspec' capability, that the remote-helper advertises as a reply to the 'capabilities' command. Extend svndump and fast-export to allow passing the target ref. Update svn-fe to be compatible. Signed-off-by: Florian Achleitner <florian.achleitner.2.6.31@gmail.com> Acked-by: David Michael Barr <b@rr-dav.id.au> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Florian Achleitner committed Sep 19, 2012 at 17:21 UTC 271fd1fc2a25ebfc1782aab0d39b613555d22315
6 files changed +12 -12
contrib/svn-fe/svn-fe.c
+1 -1
@@ -10,7 +10,7 @@ int main(int argc, char **argv)
10 {
11 if (svndump_init(NULL))
12 return 1;
13 - svndump_read((argc > 1) ? argv[1] : NULL);
13 + svndump_read((argc > 1) ? argv[1] : NULL, "refs/heads/master");
14 svndump_deinit();
15 svndump_reset();
16 return 0;
test-svn-fe.c
+1 -1
@@ -40,7 +40,7 @@ int main(int argc, char *argv[])
40 if (argc == 2) {
41 if (svndump_init(argv[1]))
42 return 1;
43 - svndump_read(NULL);
43 + svndump_read(NULL, "refs/heads/master");
44 svndump_deinit();
45 svndump_reset();
46 return 0;
vcs-svn/fast_export.c
+2 -2
@@ -72,7 +72,7 @@ static char gitsvnline[MAX_GITSVN_LINE_LEN];
72 void fast_export_begin_commit(uint32_t revision, const char *author,
73 const struct strbuf *log,
74 const char *uuid, const char *url,
75 - unsigned long timestamp)
75 + unsigned long timestamp, const char *local_ref)
76 {
77 static const struct strbuf empty = STRBUF_INIT;
78 if (!log)
@@ -84,7 +84,7 @@ void fast_export_begin_commit(uint32_t revision, const char *author,
84 } else {
85 *gitsvnline = '\0';
86 }
87 - printf("commit refs/heads/master\n");
87 + printf("commit %s\n", local_ref);
88 printf("mark :%"PRIu32"\n", revision);
89 printf("committer %s <%s@%s> %ld +0000\n",
90 *author ? author : "nobody",
vcs-svn/fast_export.h
+1 -1
@@ -11,7 +11,7 @@ void fast_export_delete(const char *path);
11 void fast_export_modify(const char *path, uint32_t mode, const char *dataref);
12 void fast_export_begin_commit(uint32_t revision, const char *author,
13 const struct strbuf *log, const char *uuid,
14 - const char *url, unsigned long timestamp);
14 + const char *url, unsigned long timestamp, const char *local_ref);
15 void fast_export_end_commit(uint32_t revision);
16 void fast_export_data(uint32_t mode, off_t len, struct line_buffer *input);
17 void fast_export_blob_delta(uint32_t mode,
vcs-svn/svndump.c
+6 -6
@@ -299,13 +299,13 @@ static void handle_node(void)
299 node_ctx.text_length, &input);
300 }
301
302 -static void begin_revision(void)
302 +static void begin_revision(const char *remote_ref)
303 {
304 if (!rev_ctx.revision) /* revision 0 gets no git commit. */
305 return;
306 fast_export_begin_commit(rev_ctx.revision, rev_ctx.author.buf,
307 &rev_ctx.log, dump_ctx.uuid.buf, dump_ctx.url.buf,
308 - rev_ctx.timestamp);
308 + rev_ctx.timestamp, remote_ref);
309 }
310
311 static void end_revision(void)
@@ -314,7 +314,7 @@ static void end_revision(void)
314 fast_export_end_commit(rev_ctx.revision);
315 }
316
317 -void svndump_read(const char *url)
317 +void svndump_read(const char *url, const char *local_ref)
318 {
319 char *val;
320 char *t;
@@ -353,7 +353,7 @@ void svndump_read(const char *url)
353 if (active_ctx == NODE_CTX)
354 handle_node();
355 if (active_ctx == REV_CTX)
356 - begin_revision();
356 + begin_revision(local_ref);
357 if (active_ctx != DUMP_CTX)
358 end_revision();
359 active_ctx = REV_CTX;
@@ -366,7 +366,7 @@ void svndump_read(const char *url)
366 if (active_ctx == NODE_CTX)
367 handle_node();
368 if (active_ctx == REV_CTX)
369 - begin_revision();
369 + begin_revision(local_ref);
370 active_ctx = NODE_CTX;
371 reset_node_ctx(val);
372 break;
@@ -463,7 +463,7 @@ void svndump_read(const char *url)
463 if (active_ctx == NODE_CTX)
464 handle_node();
465 if (active_ctx == REV_CTX)
466 - begin_revision();
466 + begin_revision(local_ref);
467 if (active_ctx != DUMP_CTX)
468 end_revision();
469 }
vcs-svn/svndump.h
+1 -1
@@ -3,7 +3,7 @@
3
4 int svndump_init(const char *filename);
5 int svndump_init_fd(int in_fd, int back_fd);
6 -void svndump_read(const char *url);
6 +void svndump_read(const char *url, const char *local_ref);
7 void svndump_deinit(void);
8 void svndump_reset(void);
9