Mockup an svndiff version 0 parser
PATCH 1/1 Mockup an svndiff version 0 parser
Hi,
I finally rolled up my sleeves and wrote that svndiff0 parser yesterday. I've tested it with a few source-target combinations, and it seems to work fine. It's based on master, now that jn/svn-fe has graduated. It's not intended for inclusion yet- it's more of a "here's what I've been upto, and I'd like some feedback". TODO:
1. malloc, realloc and free calls: I should factor these out to use the obj_pool library in vcs-svn/
2. line_buffer. Only operations on stdin are currently buffered. Should we extend the line_buffer library to be more generic?
3. Performance: The applier I've written is VERY naively. I can't help but think that there must be a better way to do it. I still don't have a solution though- the main problem is copyfrom_target.
4. Using the context dumpfilev3. The svndiff0 itself has no end markers and it's difficult to say when it's going to end. Instead of unconditionally waiting for more data (which is a problem when the connection breaks), limit the number of bytes to parse using the Content-Length header in the dumpfile v3.
Thanks.
p.s- I'll be MIA for a few weeks; exams are coming up in a week.
Ramkumar Ramachandra (1):
vcs-svn: Add an svndiff0 parser
vcs-svn/Makefile | 2 + vcs-svn/line_buffer.c | 7 +- vcs-svn/line_buffer.h | 2 +- vcs-svn/svndiff.c | 240 +++++++++++++++++++++++++++++++++++++++++++++++++ vcs-svn/svndiff.h | 41 +++++++++ 5 files changed, 288 insertions(+), 4 deletions(-) create mode 100644 vcs-svn/Makefile create mode 100644 vcs-svn/svndiff.c create mode 100644 vcs-svn/svndiff.h
Signature · 1 line
1.7.2.2.409.gdbb11.dirty
PATCH 1/1 vcs-svn: Add an svndiff0 parser
Add a parser to apply one window from an svndiff version 0 stream to a given source. svndiff version 0 is used by dumpfile version 3; this is one step towards getting svn-fe to parse the output produced by svnrdump. The svndiff format is described in $SVN_TRUNK/notes/svndiff.
--- vcs-svn/Makefile | 2 + vcs-svn/line_buffer.c | 7 +- vcs-svn/line_buffer.h | 2 +- vcs-svn/svndiff.c | 240 +++++++++++++++++++++++++++++++++++++++++++++++++ vcs-svn/svndiff.h | 41 +++++++++ 5 files changed, 288 insertions(+), 4 deletions(-) create mode 100644 vcs-svn/Makefile create mode 100644 vcs-svn/svndiff.c create mode 100644 vcs-svn/svndiff.h
vcs-svn/Makefile new file +2 -0
@@ -0,0 +1,2 @@ +default: svndiff.c line_buffer.c + $(CC) -I../ -g3 -O0 -o svndiff svndiff.c line_buffer.c
vcs-svn/line_buffer.c +4 -3
@@ -66,15 +66,16 @@ char *buffer_read_string(uint32_t len)return ferror (infile) ?NULL : s; } -void buffer_copy_bytes (uint32_t len) +void buffer_copy_bytes (uint32_t len,FILE *dst) {uint32_t in; + dst = dst ? dst : stdout;while (len >0 && !feof (infile) && !ferror (infile)) { in = len <COPY_BUFFER_LEN ? len :COPY_BUFFER_LEN ; in =fread (byte_buffer,1 , in, infile); len -= in; -fwrite (byte_buffer,1 , in, stdout); -if (ferror (stdout)) { +fwrite (byte_buffer,1 , in, dst); +if (ferror (dst)) {buffer_skip_bytes (len);return ; }
vcs-svn/line_buffer.h +1 -1
@@ -5,7 +5,7 @@ int buffer_init(const char *filename);int buffer_deinit (void );char *buffer_read_line (void );char *buffer_read_string (uint32_t len); -void buffer_copy_bytes (uint32_t len); +void buffer_copy_bytes (uint32_t len,FILE *dst);void buffer_skip_bytes (uint32_t len);void buffer_reset (void );
vcs-svn/svndiff.c new file +241 -0
241 lines not on this page · raw message
vcs-svn/svndiff.h new file +41 -0
41 lines not on this page · raw message
Signature · 1 line
1.7.2.2.409.gdbb11.dirty
PATCH 1/1 vcs-svn: Avoid %z in format string
In the spirit of v1.6.4-rc0~124 (MinGW: Fix compiler warning in merge-recursive, 2009-05-23), use a 64-bit integer instead.
--- vcs-svn/svndiff.c | 41 +++++++++++++++++++++++++---------------- 1 files changed, 25 insertions(+), 16 deletions(-)
vcs-svn/svndiff.c +25 -16
@@ -57,7 +57,7 @@ size_t read_one_instruction(struct svndiff_instruction *op)bits; the remaining 6 bits may contain the length */ action = (c >>6 ) &3 ;if (action >=3 ) -die ("Invalid instruction %d" , action); +die ("Invalid instruction %" PRIu64, (uint64_t ) action); op->action_code = (enum svndiff_action )(action);
@@ -93,39 +93,44 @@ size_t read_instructions(struct svndiff_window *window, size_t *ninst) bsize +=read_one_instruction (op);if (DEBUG ) -fprintf (stderr,"Instruction: %d %d %d (%d)\n" , - op->action_code, op->length, op->offset, bsize); +fprintf (stderr, +"Instruction: %" PRIu64" %" PRIu64" %" PRIu64" (%" PRIu64")\n" , + (uint64_t ) op->action_code, + (uint64_t ) op->length, + (uint64_t ) op->offset, + (uint64_t ) bsize);if (op ==NULL )die ("Invalid diff stream: " -"instruction %d cannot be decoded" , *ninst); +"instruction %" PRIu64" cannot be decoded" , (uint64_t ) *ninst);else if (op->length ==0 )die ("Invalid diff stream: " -"instruction %d has length zero" , *ninst); +"instruction %" PRIu64" has length zero" , (uint64_t ) *ninst);else if (op->length > window->tview_len - tpos)die ("Invalid diff stream: " -"instruction %d overflows the target view" , *ninst); +"instruction %" PRIu64" overflows the target view" , + (uint64_t ) *ninst);switch (op->action_code) {case copyfrom_source:if (op->length > window->sview_len - op->offset || - op->offset > window->sview_len) + op->offset > window->sview_len)die ("Invalid diff stream: " -"[src] instruction %d overflows " -" the source view" , *ninst); +"[src] instruction %" PRIu64" overflows " +" the source view" , (uint64_t ) *ninst);break ;case copyfrom_target:if (op->offset >= tpos)die ("Invalid diff stream: " -"[tgt] instruction %d starts " -"beyond the target view position" , *ninst); +"[tgt] instruction %" PRIu64" starts " +"beyond the target view position" , (uint64_t ) *ninst);break ;case copyfrom_new:if (op->length > window->newdata_len - npos)die ("Invalid diff stream: " -"[new] instruction %d overflows " -"the new data section" , *ninst); +"[new] instruction %" PRIu64" overflows " +"the new data section" , (uint64_t ) *ninst); npos += op->length;break ; }
@@ -163,9 +168,13 @@ size_t read_window_header(struct svndiff_window *window)die ("Svndiff contains corrupt window header" );if (DEBUG ) -fprintf (stderr,"Window header: %d %d %d %d %d\n" , - window->sview_offset, window->sview_len, - window->tview_len, window->ins_len, window->newdata_len); +fprintf (stderr, +"Window header: %" PRIu64" %" PRIu64" %" PRIu64" %" PRIu64" %" PRIu64"\n" , + (uint64_t ) window->sview_offset, + (uint64_t ) window->sview_len, + (uint64_t ) window->tview_len, + (uint64_t ) window->ins_len, + (uint64_t ) window->newdata_len);return bsize; }
Signature · 1 line
1.7.2.2
Re: [PATCH] vcs-svn: Avoid %z in format string
Hi David,
Quoted 2 lines · David Barr
In the spirit of v1.6.4-rc0~124 (MinGW: Fix compiler warning in merge-recursive, 2009-05-23), use a 64-bit integer instead.
Squashed. Thanks much :)
-- Ram