Fossil SCM
Fixes to SVN import received from Christophe Gouiran (bechris13250 at gmail)
Commit
035bd4f65cb13106f5c31d390713508ea630a4d9bb69a88e1a623a1375ad6347
Parent
8705a525358dd9b…
1 file changed
+45
-4
+45
-4
| --- src/import.c | ||
| +++ src/import.c | ||
| @@ -1252,10 +1252,36 @@ | ||
| 1252 | 1252 | branchId = db_last_insert_rowid(); |
| 1253 | 1253 | } |
| 1254 | 1254 | } |
| 1255 | 1255 | return branchId; |
| 1256 | 1256 | } |
| 1257 | + | |
| 1258 | +/* | |
| 1259 | +** Insert content of corresponding content blob into the database. | |
| 1260 | +** If content is identified as a symbolic link then: | |
| 1261 | +** 1)Trailing "link " characters are removed from content. | |
| 1262 | +** 2)Repository "allow-symlinks" setting is activated. | |
| 1263 | +** | |
| 1264 | +** content is considered to be a symlink if zPerm contains at least | |
| 1265 | +** one "l" character. | |
| 1266 | +*/ | |
| 1267 | +static int svn_handle_symlinks(const char *perms, Blob *content){ | |
| 1268 | + Blob link_blob; | |
| 1269 | + if( perms && strstr(perms, "l")!=0 ){ | |
| 1270 | + if( blob_size(content)>5 ){ | |
| 1271 | + /* Skip trailing 'link ' characters */ | |
| 1272 | + blob_seek(content, 5, BLOB_SEEK_SET); | |
| 1273 | + blob_tail(content, &link_blob); | |
| 1274 | + db_set_int("allow-symlinks", 1, 0); | |
| 1275 | + return content_put(&link_blob); | |
| 1276 | + }else{ | |
| 1277 | + fossil_fatal("Too short symbolic link path"); | |
| 1278 | + } | |
| 1279 | + }else{ | |
| 1280 | + return content_put(content); | |
| 1281 | + } | |
| 1282 | +} | |
| 1257 | 1283 | |
| 1258 | 1284 | /* |
| 1259 | 1285 | ** Read the svn-dump format from pIn and insert the corresponding |
| 1260 | 1286 | ** content into the database. |
| 1261 | 1287 | */ |
| @@ -1351,10 +1377,13 @@ | ||
| 1351 | 1377 | int branchType; |
| 1352 | 1378 | int branchId = svn_parse_path(zTemp, &zFile, &branchType); |
| 1353 | 1379 | char *zAction = svn_find_header(rec, "Node-action"); |
| 1354 | 1380 | char *zKind = svn_find_header(rec, "Node-kind"); |
| 1355 | 1381 | char *zPerm = svn_find_prop(rec, "svn:executable") ? "x" : 0; |
| 1382 | + if ( zPerm==0 ){ | |
| 1383 | + zPerm = svn_find_prop(rec, "svn:special") ? "l" : 0; | |
| 1384 | + } | |
| 1356 | 1385 | int deltaFlag = 0; |
| 1357 | 1386 | int srcRev = 0; |
| 1358 | 1387 | if( branchId==0 ){ |
| 1359 | 1388 | svn_free_rec(&rec); |
| 1360 | 1389 | continue; |
| @@ -1464,13 +1493,19 @@ | ||
| 1464 | 1493 | content_get(rid, &deltaSrc); |
| 1465 | 1494 | }else{ |
| 1466 | 1495 | blob_zero(&deltaSrc); |
| 1467 | 1496 | } |
| 1468 | 1497 | svn_apply_svndiff(&rec.content, &deltaSrc, &target); |
| 1469 | - rid = content_put(&target); | |
| 1498 | + rid = svn_handle_symlinks(zPerm, &target); | |
| 1470 | 1499 | }else if( rec.contentFlag ){ |
| 1471 | - rid = content_put(&rec.content); | |
| 1500 | + rid = svn_handle_symlinks(zPerm, &rec.content); | |
| 1501 | + }else if( zSrcPath ){ | |
| 1502 | + if ( zPerm==0 ){ | |
| 1503 | + zPerm = db_text(0, "SELECT tperm FROM xfiles" | |
| 1504 | + " WHERE tpath=%Q AND tbranch=%d" | |
| 1505 | + "", zSrcPath, branchId); | |
| 1506 | + } | |
| 1472 | 1507 | } |
| 1473 | 1508 | db_bind_text(&addFile, ":path", zFile); |
| 1474 | 1509 | db_bind_int(&addFile, ":branch", branchId); |
| 1475 | 1510 | db_bind_int(&addFile, ":rid", rid); |
| 1476 | 1511 | db_bind_text(&addFile, ":perm", zPerm); |
| @@ -1485,22 +1520,28 @@ | ||
| 1485 | 1520 | int rid = 0; |
| 1486 | 1521 | if( zKind==0 ){ |
| 1487 | 1522 | fossil_fatal("Missing Node-kind"); |
| 1488 | 1523 | } |
| 1489 | 1524 | if( rec.contentFlag && strncmp(zKind, "dir", 3)!=0 ){ |
| 1525 | + if ( zPerm==0 ){ | |
| 1526 | + zPerm = db_text(0, "SELECT tperm FROM xfiles" | |
| 1527 | + " WHERE tpath=%Q AND tbranch=%d" | |
| 1528 | + "", zFile, branchId); | |
| 1529 | + } | |
| 1530 | + | |
| 1490 | 1531 | if( deltaFlag ){ |
| 1491 | 1532 | Blob deltaSrc; |
| 1492 | 1533 | Blob target; |
| 1493 | 1534 | rid = db_int(0, "SELECT rid FROM blob WHERE uuid=(" |
| 1494 | 1535 | " SELECT tuuid FROM xfiles" |
| 1495 | 1536 | " WHERE tpath=%Q AND tbranch=%d" |
| 1496 | 1537 | ")", zFile, branchId); |
| 1497 | 1538 | content_get(rid, &deltaSrc); |
| 1498 | 1539 | svn_apply_svndiff(&rec.content, &deltaSrc, &target); |
| 1499 | - rid = content_put(&target); | |
| 1540 | + rid = svn_handle_symlinks(zPerm, &target); | |
| 1500 | 1541 | }else{ |
| 1501 | - rid = content_put(&rec.content); | |
| 1542 | + rid = svn_handle_symlinks(zPerm, &rec.content); | |
| 1502 | 1543 | } |
| 1503 | 1544 | db_bind_text(&addFile, ":path", zFile); |
| 1504 | 1545 | db_bind_int(&addFile, ":branch", branchId); |
| 1505 | 1546 | db_bind_int(&addFile, ":rid", rid); |
| 1506 | 1547 | db_bind_text(&addFile, ":perm", zPerm); |
| 1507 | 1548 |
| --- src/import.c | |
| +++ src/import.c | |
| @@ -1252,10 +1252,36 @@ | |
| 1252 | branchId = db_last_insert_rowid(); |
| 1253 | } |
| 1254 | } |
| 1255 | return branchId; |
| 1256 | } |
| 1257 | |
| 1258 | /* |
| 1259 | ** Read the svn-dump format from pIn and insert the corresponding |
| 1260 | ** content into the database. |
| 1261 | */ |
| @@ -1351,10 +1377,13 @@ | |
| 1351 | int branchType; |
| 1352 | int branchId = svn_parse_path(zTemp, &zFile, &branchType); |
| 1353 | char *zAction = svn_find_header(rec, "Node-action"); |
| 1354 | char *zKind = svn_find_header(rec, "Node-kind"); |
| 1355 | char *zPerm = svn_find_prop(rec, "svn:executable") ? "x" : 0; |
| 1356 | int deltaFlag = 0; |
| 1357 | int srcRev = 0; |
| 1358 | if( branchId==0 ){ |
| 1359 | svn_free_rec(&rec); |
| 1360 | continue; |
| @@ -1464,13 +1493,19 @@ | |
| 1464 | content_get(rid, &deltaSrc); |
| 1465 | }else{ |
| 1466 | blob_zero(&deltaSrc); |
| 1467 | } |
| 1468 | svn_apply_svndiff(&rec.content, &deltaSrc, &target); |
| 1469 | rid = content_put(&target); |
| 1470 | }else if( rec.contentFlag ){ |
| 1471 | rid = content_put(&rec.content); |
| 1472 | } |
| 1473 | db_bind_text(&addFile, ":path", zFile); |
| 1474 | db_bind_int(&addFile, ":branch", branchId); |
| 1475 | db_bind_int(&addFile, ":rid", rid); |
| 1476 | db_bind_text(&addFile, ":perm", zPerm); |
| @@ -1485,22 +1520,28 @@ | |
| 1485 | int rid = 0; |
| 1486 | if( zKind==0 ){ |
| 1487 | fossil_fatal("Missing Node-kind"); |
| 1488 | } |
| 1489 | if( rec.contentFlag && strncmp(zKind, "dir", 3)!=0 ){ |
| 1490 | if( deltaFlag ){ |
| 1491 | Blob deltaSrc; |
| 1492 | Blob target; |
| 1493 | rid = db_int(0, "SELECT rid FROM blob WHERE uuid=(" |
| 1494 | " SELECT tuuid FROM xfiles" |
| 1495 | " WHERE tpath=%Q AND tbranch=%d" |
| 1496 | ")", zFile, branchId); |
| 1497 | content_get(rid, &deltaSrc); |
| 1498 | svn_apply_svndiff(&rec.content, &deltaSrc, &target); |
| 1499 | rid = content_put(&target); |
| 1500 | }else{ |
| 1501 | rid = content_put(&rec.content); |
| 1502 | } |
| 1503 | db_bind_text(&addFile, ":path", zFile); |
| 1504 | db_bind_int(&addFile, ":branch", branchId); |
| 1505 | db_bind_int(&addFile, ":rid", rid); |
| 1506 | db_bind_text(&addFile, ":perm", zPerm); |
| 1507 |
| --- src/import.c | |
| +++ src/import.c | |
| @@ -1252,10 +1252,36 @@ | |
| 1252 | branchId = db_last_insert_rowid(); |
| 1253 | } |
| 1254 | } |
| 1255 | return branchId; |
| 1256 | } |
| 1257 | |
| 1258 | /* |
| 1259 | ** Insert content of corresponding content blob into the database. |
| 1260 | ** If content is identified as a symbolic link then: |
| 1261 | ** 1)Trailing "link " characters are removed from content. |
| 1262 | ** 2)Repository "allow-symlinks" setting is activated. |
| 1263 | ** |
| 1264 | ** content is considered to be a symlink if zPerm contains at least |
| 1265 | ** one "l" character. |
| 1266 | */ |
| 1267 | static int svn_handle_symlinks(const char *perms, Blob *content){ |
| 1268 | Blob link_blob; |
| 1269 | if( perms && strstr(perms, "l")!=0 ){ |
| 1270 | if( blob_size(content)>5 ){ |
| 1271 | /* Skip trailing 'link ' characters */ |
| 1272 | blob_seek(content, 5, BLOB_SEEK_SET); |
| 1273 | blob_tail(content, &link_blob); |
| 1274 | db_set_int("allow-symlinks", 1, 0); |
| 1275 | return content_put(&link_blob); |
| 1276 | }else{ |
| 1277 | fossil_fatal("Too short symbolic link path"); |
| 1278 | } |
| 1279 | }else{ |
| 1280 | return content_put(content); |
| 1281 | } |
| 1282 | } |
| 1283 | |
| 1284 | /* |
| 1285 | ** Read the svn-dump format from pIn and insert the corresponding |
| 1286 | ** content into the database. |
| 1287 | */ |
| @@ -1351,10 +1377,13 @@ | |
| 1377 | int branchType; |
| 1378 | int branchId = svn_parse_path(zTemp, &zFile, &branchType); |
| 1379 | char *zAction = svn_find_header(rec, "Node-action"); |
| 1380 | char *zKind = svn_find_header(rec, "Node-kind"); |
| 1381 | char *zPerm = svn_find_prop(rec, "svn:executable") ? "x" : 0; |
| 1382 | if ( zPerm==0 ){ |
| 1383 | zPerm = svn_find_prop(rec, "svn:special") ? "l" : 0; |
| 1384 | } |
| 1385 | int deltaFlag = 0; |
| 1386 | int srcRev = 0; |
| 1387 | if( branchId==0 ){ |
| 1388 | svn_free_rec(&rec); |
| 1389 | continue; |
| @@ -1464,13 +1493,19 @@ | |
| 1493 | content_get(rid, &deltaSrc); |
| 1494 | }else{ |
| 1495 | blob_zero(&deltaSrc); |
| 1496 | } |
| 1497 | svn_apply_svndiff(&rec.content, &deltaSrc, &target); |
| 1498 | rid = svn_handle_symlinks(zPerm, &target); |
| 1499 | }else if( rec.contentFlag ){ |
| 1500 | rid = svn_handle_symlinks(zPerm, &rec.content); |
| 1501 | }else if( zSrcPath ){ |
| 1502 | if ( zPerm==0 ){ |
| 1503 | zPerm = db_text(0, "SELECT tperm FROM xfiles" |
| 1504 | " WHERE tpath=%Q AND tbranch=%d" |
| 1505 | "", zSrcPath, branchId); |
| 1506 | } |
| 1507 | } |
| 1508 | db_bind_text(&addFile, ":path", zFile); |
| 1509 | db_bind_int(&addFile, ":branch", branchId); |
| 1510 | db_bind_int(&addFile, ":rid", rid); |
| 1511 | db_bind_text(&addFile, ":perm", zPerm); |
| @@ -1485,22 +1520,28 @@ | |
| 1520 | int rid = 0; |
| 1521 | if( zKind==0 ){ |
| 1522 | fossil_fatal("Missing Node-kind"); |
| 1523 | } |
| 1524 | if( rec.contentFlag && strncmp(zKind, "dir", 3)!=0 ){ |
| 1525 | if ( zPerm==0 ){ |
| 1526 | zPerm = db_text(0, "SELECT tperm FROM xfiles" |
| 1527 | " WHERE tpath=%Q AND tbranch=%d" |
| 1528 | "", zFile, branchId); |
| 1529 | } |
| 1530 | |
| 1531 | if( deltaFlag ){ |
| 1532 | Blob deltaSrc; |
| 1533 | Blob target; |
| 1534 | rid = db_int(0, "SELECT rid FROM blob WHERE uuid=(" |
| 1535 | " SELECT tuuid FROM xfiles" |
| 1536 | " WHERE tpath=%Q AND tbranch=%d" |
| 1537 | ")", zFile, branchId); |
| 1538 | content_get(rid, &deltaSrc); |
| 1539 | svn_apply_svndiff(&rec.content, &deltaSrc, &target); |
| 1540 | rid = svn_handle_symlinks(zPerm, &target); |
| 1541 | }else{ |
| 1542 | rid = svn_handle_symlinks(zPerm, &rec.content); |
| 1543 | } |
| 1544 | db_bind_text(&addFile, ":path", zFile); |
| 1545 | db_bind_int(&addFile, ":branch", branchId); |
| 1546 | db_bind_int(&addFile, ":rid", rid); |
| 1547 | db_bind_text(&addFile, ":perm", zPerm); |
| 1548 |