@matheusbsbs / matheus-bagliano / commits / 2a48afe1c2
Fork 0

vcs-svn: Split off function for handling of individual properties

The handle_property function is the part of read_props that would be interesting for most people: semantics of properties rather than the algorithm for parsing them. Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jonathan Nieder committed Nov 19, 2010 at 18:54 UTC 2a48afe1c256db6273a4ff99eaddc5c18dc46ffd
1 file changed +19 -14
vcs-svn/svndump.c
+19 -14
@@ -30,7 +30,7 @@
30 /* Create memory pool for log messages */
31 obj_pool_gen(log, char, 4096)
32
33 -static char* log_copy(uint32_t length, char *log)
33 +static char *log_copy(uint32_t length, const char *log)
34 {
35 char *buffer;
36 log_free(log_pool.size);
@@ -115,6 +115,23 @@ static void init_keys(void)
115 keys.prop_delta = pool_intern("Prop-delta");
116 }
117
118 +static void handle_property(uint32_t key, const char *val, uint32_t len)
119 +{
120 + if (key == keys.svn_log) {
121 + /* Value length excludes terminating nul. */
122 + rev_ctx.log = log_copy(len + 1, val);
123 + } else if (key == keys.svn_author) {
124 + rev_ctx.author = pool_intern(val);
125 + } else if (key == keys.svn_date) {
126 + if (parse_date_basic(val, &rev_ctx.timestamp, NULL))
127 + fprintf(stderr, "Invalid timestamp: %s\n", val);
128 + } else if (key == keys.svn_executable) {
129 + node_ctx.type = REPO_MODE_EXE;
130 + } else if (key == keys.svn_special) {
131 + node_ctx.type = REPO_MODE_LNK;
132 + }
133 +}
134 +
135 static void read_props(void)
136 {
137 uint32_t len;
@@ -129,19 +146,7 @@ static void read_props(void)
146 } else if (!strncmp(t, "V ", 2)) {
147 len = atoi(&t[2]);
148 val = buffer_read_string(len);
132 - if (key == keys.svn_log) {
133 - /* Value length excludes terminating nul. */
134 - rev_ctx.log = log_copy(len + 1, val);
135 - } else if (key == keys.svn_author) {
136 - rev_ctx.author = pool_intern(val);
137 - } else if (key == keys.svn_date) {
138 - if (parse_date_basic(val, &rev_ctx.timestamp, NULL))
139 - fprintf(stderr, "Invalid timestamp: %s\n", val);
140 - } else if (key == keys.svn_executable) {
141 - node_ctx.type = REPO_MODE_EXE;
142 - } else if (key == keys.svn_special) {
143 - node_ctx.type = REPO_MODE_LNK;
144 - }
149 + handle_property(key, val, len);
150 key = ~0;
151 buffer_read_line();
152 }