@matheusbsbs / matheus-bagliano / commits / 7e11902c99
Fork 0

vcs-svn: add a comment before each commit

Current svn-fe produces output like this: blob mark :7382321 data 5 hello blob mark :7382322 data 5 Hello commit mark :3 [...] M 100644 :7382321 hello.c M 100644 :7382322 hello2.c This means svn-fe has to keep track of the paths modified in each commit and the corresponding marks, instead of dealing with each file as it arrives in input and then forgetting about it. A better strategy would be to use inline blobs: commit mark :3 [...] M 100644 inline hello.c data 5 hello [...] As a first step towards that, teach svn-fe to notice when the collection of blobs for each commit starts and write a comment ("# commit 3.") there. Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>

Jonathan Nieder committed Jan 4, 2011 at 21:53 UTC 7e11902c995715836dec140eb55cfef1d24334bb
3 files changed +28 -7
vcs-svn/fast_export.c
+5
@@ -48,6 +48,11 @@ void fast_export_modify(uint32_t depth, uint32_t *path, uint32_t mode,
48 putchar('\n');
49 }
50
51 +void fast_export_begin_commit(uint32_t revision)
52 +{
53 + printf("# commit %"PRIu32".\n", revision);
54 +}
55 +
56 static char gitsvnline[MAX_GITSVN_LINE_LEN];
57 void fast_export_commit(uint32_t revision, uint32_t author, char *log,
58 uint32_t uuid, uint32_t url,
vcs-svn/fast_export.h
+1
@@ -10,6 +10,7 @@ void fast_export_reset(void);
10 void fast_export_delete(uint32_t depth, uint32_t *path);
11 void fast_export_modify(uint32_t depth, uint32_t *path, uint32_t mode,
12 uint32_t mark);
13 +void fast_export_begin_commit(uint32_t revision);
14 void fast_export_commit(uint32_t revision, uint32_t author, char *log,
15 uint32_t uuid, uint32_t url, unsigned long timestamp);
16 void fast_export_blob(uint32_t mode, uint32_t mark, uint32_t len,
vcs-svn/svndump.c
+22 -7
@@ -22,9 +22,11 @@
22 #define NODEACT_CHANGE 1
23 #define NODEACT_UNKNOWN 0
24
25 -#define DUMP_CTX 0
26 -#define REV_CTX 1
27 -#define NODE_CTX 2
25 +/* States: */
26 +#define DUMP_CTX 0 /* dump metadata */
27 +#define REV_CTX 1 /* revision metadata */
28 +#define NODE_CTX 2 /* node metadata */
29 +#define INTERNODE_CTX 3 /* between nodes */
30
31 #define LENGTH_UNKNOWN (~0)
32 #define DATE_RFC2822_LEN 31
@@ -269,7 +271,14 @@ static void handle_node(void)
271 node_ctx.textLength, &input);
272 }
273
272 -static void handle_revision(void)
274 +static void begin_revision(void)
275 +{
276 + if (!rev_ctx.revision) /* revision 0 gets no git commit. */
277 + return;
278 + fast_export_begin_commit(rev_ctx.revision);
279 +}
280 +
281 +static void end_revision(void)
282 {
283 if (rev_ctx.revision)
284 repo_commit(rev_ctx.revision, rev_ctx.author, rev_ctx.log,
@@ -303,13 +312,17 @@ void svndump_read(const char *url)
312 } else if (key == keys.revision_number) {
313 if (active_ctx == NODE_CTX)
314 handle_node();
315 + if (active_ctx == REV_CTX)
316 + begin_revision();
317 if (active_ctx != DUMP_CTX)
307 - handle_revision();
318 + end_revision();
319 active_ctx = REV_CTX;
320 reset_rev_ctx(atoi(val));
321 } else if (key == keys.node_path) {
322 if (active_ctx == NODE_CTX)
323 handle_node();
324 + if (active_ctx == REV_CTX)
325 + begin_revision();
326 active_ctx = NODE_CTX;
327 reset_node_ctx(val);
328 } else if (key == keys.node_kind) {
@@ -351,7 +364,7 @@ void svndump_read(const char *url)
364 read_props();
365 } else if (active_ctx == NODE_CTX) {
366 handle_node();
354 - active_ctx = REV_CTX;
367 + active_ctx = INTERNODE_CTX;
368 } else {
369 fprintf(stderr, "Unexpected content length header: %"PRIu32"\n", len);
370 buffer_skip_bytes(&input, len);
@@ -360,8 +373,10 @@ void svndump_read(const char *url)
373 }
374 if (active_ctx == NODE_CTX)
375 handle_node();
376 + if (active_ctx == REV_CTX)
377 + begin_revision();
378 if (active_ctx != DUMP_CTX)
364 - handle_revision();
379 + end_revision();
380 }
381
382 int svndump_init(const char *filename)