Fossil SCM

Fixes to SVN import received from Christophe Gouiran (bechris13250 at gmail)

drh 2017-03-22 12:39 trunk
Commit 035bd4f65cb13106f5c31d390713508ea630a4d9bb69a88e1a623a1375ad6347
1 file changed +45 -4
+45 -4
--- src/import.c
+++ src/import.c
@@ -1252,10 +1252,36 @@
12521252
branchId = db_last_insert_rowid();
12531253
}
12541254
}
12551255
return branchId;
12561256
}
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
+}
12571283
12581284
/*
12591285
** Read the svn-dump format from pIn and insert the corresponding
12601286
** content into the database.
12611287
*/
@@ -1351,10 +1377,13 @@
13511377
int branchType;
13521378
int branchId = svn_parse_path(zTemp, &zFile, &branchType);
13531379
char *zAction = svn_find_header(rec, "Node-action");
13541380
char *zKind = svn_find_header(rec, "Node-kind");
13551381
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
+ }
13561385
int deltaFlag = 0;
13571386
int srcRev = 0;
13581387
if( branchId==0 ){
13591388
svn_free_rec(&rec);
13601389
continue;
@@ -1464,13 +1493,19 @@
14641493
content_get(rid, &deltaSrc);
14651494
}else{
14661495
blob_zero(&deltaSrc);
14671496
}
14681497
svn_apply_svndiff(&rec.content, &deltaSrc, &target);
1469
- rid = content_put(&target);
1498
+ rid = svn_handle_symlinks(zPerm, &target);
14701499
}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
+ }
14721507
}
14731508
db_bind_text(&addFile, ":path", zFile);
14741509
db_bind_int(&addFile, ":branch", branchId);
14751510
db_bind_int(&addFile, ":rid", rid);
14761511
db_bind_text(&addFile, ":perm", zPerm);
@@ -1485,22 +1520,28 @@
14851520
int rid = 0;
14861521
if( zKind==0 ){
14871522
fossil_fatal("Missing Node-kind");
14881523
}
14891524
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
+
14901531
if( deltaFlag ){
14911532
Blob deltaSrc;
14921533
Blob target;
14931534
rid = db_int(0, "SELECT rid FROM blob WHERE uuid=("
14941535
" SELECT tuuid FROM xfiles"
14951536
" WHERE tpath=%Q AND tbranch=%d"
14961537
")", zFile, branchId);
14971538
content_get(rid, &deltaSrc);
14981539
svn_apply_svndiff(&rec.content, &deltaSrc, &target);
1499
- rid = content_put(&target);
1540
+ rid = svn_handle_symlinks(zPerm, &target);
15001541
}else{
1501
- rid = content_put(&rec.content);
1542
+ rid = svn_handle_symlinks(zPerm, &rec.content);
15021543
}
15031544
db_bind_text(&addFile, ":path", zFile);
15041545
db_bind_int(&addFile, ":branch", branchId);
15051546
db_bind_int(&addFile, ":rid", rid);
15061547
db_bind_text(&addFile, ":perm", zPerm);
15071548
--- 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

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button