vcs-svn: allow 64-bit Prop-Content-Length
Currently the vcs-svn/ library only pays attention to the presence of the Prop-Content-Length field and doesn't care about its value, but some day we might care about the value. Parse it as an off_t instead of arbitrarily limiting to 32 bits for intuitiveness. So now you can import from a dump with more than 2 GiB of properties for a node. In practice that isn't likely to happen often, and this is mostly meant as a cleanup. Based-on-patch-by: David Barr <davidbarr@google.com> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Jonathan Nieder committed
Jul 5, 2012 at 22:47 UTC
e32b79cb3211992505d68c421a3f66b29590d72c
1 file changed
+18
-15
vcs-svn/svndump.c
+18
-15
@@ -34,14 +34,13 @@
34
#define NODE_CTX 2 /* node metadata */
35
#define INTERNODE_CTX 3 /* between nodes */
36
37
-#define LENGTH_UNKNOWN (~0)
37
#define DATE_RFC2822_LEN 31
38
39
static struct line_buffer input = LINE_BUFFER_INIT;
40
41
static struct {
43
- uint32_t action, propLength, srcRev, type;
44
- off_t text_length;
42
+ uint32_t action, srcRev, type;
43
+ off_t prop_length, text_length;
44
struct strbuf src, dst;
45
uint32_t text_delta, prop_delta;
46
} node_ctx;
@@ -61,7 +60,7 @@ static void reset_node_ctx(char *fname)
60
{
61
node_ctx.type = 0;
62
node_ctx.action = NODEACT_UNKNOWN;
64
- node_ctx.propLength = LENGTH_UNKNOWN;
63
+ node_ctx.prop_length = -1;
64
node_ctx.text_length = -1;
65
strbuf_reset(&node_ctx.src);
66
node_ctx.srcRev = 0;
@@ -209,7 +208,7 @@ static void read_props(void)
208
static void handle_node(void)
209
{
210
const uint32_t type = node_ctx.type;
212
- const int have_props = node_ctx.propLength != LENGTH_UNKNOWN;
211
+ const int have_props = node_ctx.prop_length != -1;
212
const int have_text = node_ctx.text_length != -1;
213
/*
214
* Old text for this node:
@@ -273,7 +272,7 @@ static void handle_node(void)
272
if (have_props) {
273
if (!node_ctx.prop_delta)
274
node_ctx.type = type;
276
- if (node_ctx.propLength)
275
+ if (node_ctx.prop_length)
276
read_props();
277
}
278
@@ -409,22 +408,26 @@ void svndump_read(const char *url)
408
node_ctx.srcRev = atoi(val);
409
break;
410
case sizeof("Text-content-length"):
412
- if (!constcmp(t, "Text-content-length")) {
411
+ if (constcmp(t, "Text") && constcmp(t, "Prop"))
412
+ continue;
413
+ if (constcmp(t + 4, "-content-length"))
414
+ continue;
415
+ {
416
char *end;
414
- uintmax_t textlen;
417
+ uintmax_t len;
418
416
- textlen = strtoumax(val, &end, 10);
419
+ len = strtoumax(val, &end, 10);
420
if (!isdigit(*val) || *end)
421
die("invalid dump: non-numeric length %s", val);
419
- if (textlen > maximum_signed_value_of_type(off_t))
422
+ if (len > maximum_signed_value_of_type(off_t))
423
die("unrepresentable length in dump: %s", val);
421
- node_ctx.text_length = (off_t) textlen;
424
+
425
+ if (*t == 'T')
426
+ node_ctx.text_length = (off_t) len;
427
+ else
428
+ node_ctx.prop_length = (off_t) len;
429
break;
430
}
424
- if (constcmp(t, "Prop-content-length"))
425
- continue;
426
- node_ctx.propLength = atoi(val);
427
- break;
431
case sizeof("Text-delta"):
432
if (!constcmp(t, "Text-delta")) {
433
node_ctx.text_delta = !strcmp(val, "true");