Fossil SCM
Another unfinished revision
Commit
65f9525be50929df48a084d25b3ef64c48325291
Parent
2ea79975b60e7af…
1 file changed
+52
-51
+52
-51
| --- src/import.c | ||
| +++ src/import.c | ||
| @@ -1084,52 +1084,65 @@ | ||
| 1084 | 1084 | ** Returns: 1 - It is on the trunk |
| 1085 | 1085 | ** 2 - It is on a branch |
| 1086 | 1086 | ** 3 - It is a tag |
| 1087 | 1087 | ** 0 - It is none of the above |
| 1088 | 1088 | */ |
| 1089 | -static int svn_parse_path(char *zPath, char **zBranch, char **zFile){ | |
| 1089 | +static int svn_parse_path(char *zPath, char **zFile){ | |
| 1090 | + int type = 0; | |
| 1091 | + char *zBranch = 0; | |
| 1092 | + int branchId = 0; | |
| 1093 | + *zFile = 0; | |
| 1090 | 1094 | if( gsvn.lenTrunk==0 ){ |
| 1091 | - *zBranch = "trunk"; | |
| 1095 | + zBranch = "trunk"; | |
| 1092 | 1096 | *zFile = zPath; |
| 1093 | - return 1; | |
| 1097 | + type = 1; | |
| 1094 | 1098 | }else |
| 1095 | 1099 | if( strncmp(zPath, gsvn.zTrunk, gsvn.lenTrunk-1)==0 ){ |
| 1096 | - *zBranch = "trunk"; | |
| 1100 | + zBranch = "trunk"; | |
| 1097 | 1101 | if( zPath[gsvn.lenTrunk-1]=='/' ){ |
| 1098 | 1102 | *zFile = zPath+gsvn.lenTrunk;; |
| 1099 | 1103 | }else if( zPath[gsvn.lenTrunk-1]==0 ){ |
| 1100 | 1104 | *zFile = 0; |
| 1101 | 1105 | }else{ |
| 1102 | - *zFile = *zBranch = 0; | |
| 1103 | - return 0; | |
| 1106 | + *zFile = zBranch = 0; | |
| 1107 | + type = 0; | |
| 1104 | 1108 | } |
| 1105 | - return 1; | |
| 1109 | + type = 1; | |
| 1106 | 1110 | }else |
| 1107 | 1111 | if( strncmp(zPath, gsvn.zBranches, gsvn.lenBranches)==0 ){ |
| 1108 | - *zFile = *zBranch = zPath+gsvn.lenBranches; | |
| 1112 | + *zFile = zBranch = zPath+gsvn.lenBranches; | |
| 1113 | + while( **zFile && **zFile!='/' ){ (*zFile)++; } | |
| 1114 | + if( *zFile ){ | |
| 1115 | + **zFile = '\0'; | |
| 1116 | + (*zFile)++; | |
| 1117 | + }else{ | |
| 1118 | + *zFile = 0; | |
| 1119 | + } | |
| 1120 | + type = 2; | |
| 1121 | + }else | |
| 1122 | + if( strncmp(zPath, gsvn.zTags, gsvn.lenTags)==0 ){ | |
| 1123 | + *zFile = zBranch = zPath+gsvn.lenTags; | |
| 1109 | 1124 | while( **zFile && **zFile!='/' ){ (*zFile)++; } |
| 1110 | 1125 | if( *zFile ){ |
| 1111 | 1126 | **zFile = '\0'; |
| 1112 | 1127 | (*zFile)++; |
| 1113 | 1128 | }else{ |
| 1114 | 1129 | *zFile = 0; |
| 1115 | 1130 | } |
| 1116 | - return 2; | |
| 1117 | - }else | |
| 1118 | - if( strncmp(zPath, gsvn.zTags, gsvn.lenTags)==0 ){ | |
| 1119 | - *zFile = *zBranch = zPath+gsvn.lenTags; | |
| 1120 | - while( **zFile && **zFile!='/' ){ (*zFile)++; } | |
| 1121 | - if( *zFile ){ | |
| 1122 | - **zFile = '\0'; | |
| 1123 | - (*zFile)++; | |
| 1124 | - }else{ | |
| 1125 | - *zFile = 0; | |
| 1126 | - } | |
| 1127 | - return 3; | |
| 1128 | - } | |
| 1129 | - *zFile = *zBranch = 0; | |
| 1130 | - return 0; | |
| 1131 | + type = 3; | |
| 1132 | + } | |
| 1133 | + if( type>0 ){ | |
| 1134 | + branchId = db_int(0, | |
| 1135 | + "SELECT tid FROM xbranches WHERE tbranch=%Q AND ttype=%d", | |
| 1136 | + zBranch, branchType); | |
| 1137 | + if( branchId==0 ){ | |
| 1138 | + db_multi_exec("INSERT INTO xbranches (tbranch, ttype) VALUES(%Q, %d)", | |
| 1139 | + zBranch, branchType); | |
| 1140 | + branchId = db_last_insert_rowid(); | |
| 1141 | + } | |
| 1142 | + } | |
| 1143 | + return branchId; | |
| 1131 | 1144 | } |
| 1132 | 1145 | |
| 1133 | 1146 | /* |
| 1134 | 1147 | ** Read the svn-dump format from pIn and insert the corresponding |
| 1135 | 1148 | ** content into the database. |
| @@ -1170,16 +1183,13 @@ | ||
| 1170 | 1183 | db_prepare(&delPath, |
| 1171 | 1184 | "DELETE FROM xfiles" |
| 1172 | 1185 | " WHERE (tpath=:path OR (tpath>:path||'/' AND tpath<:path||'0'))" |
| 1173 | 1186 | " AND tbranch=:branch" |
| 1174 | 1187 | ); |
| 1175 | - db_prepare(&addSrc, | |
| 1176 | - "INSERT INTO xsrc (tpath, tbranch, tsrc, tsrcbranch, tsrcrev)" | |
| 1177 | - " VALUES(:path, :branch, :srcpath, :srcbranch, :srcrev)" | |
| 1178 | - ); | |
| 1179 | - db_prepare(&addBranch, | |
| 1180 | - "INSERT INTO xchanges (tbranch, ttype) VALUES(:branch, :type)" | |
| 1188 | + db_prepare(&addRev, | |
| 1189 | + "INSERT OR IGNORE INTO xrevisions (trev, tbranch, tparent)" | |
| 1190 | + " VALUES(:rev, :branch, :parent)" | |
| 1181 | 1191 | ); |
| 1182 | 1192 | db_prepare(&cpyPath, |
| 1183 | 1193 | "INSERT INTO xfiles (tpath, tbranch, tuuid, tperm)" |
| 1184 | 1194 | " SELECT :path||substr(filename, length(:srcpath)+1), :branch, uuid, perm" |
| 1185 | 1195 | " FROM xfoci" |
| @@ -1203,32 +1213,28 @@ | ||
| 1203 | 1213 | zDate = svn_find_prop(rec, "svn:date"); |
| 1204 | 1214 | if( zDate ){ |
| 1205 | 1215 | zDate = date_in_standard_format(zDate); |
| 1206 | 1216 | } |
| 1207 | 1217 | gsvn.zDate = zDate; |
| 1218 | + db_bind_int(&addRev, ":rev", gsvn.rev); | |
| 1208 | 1219 | fossil_print("\rImporting SVN revision: %d", gsvn.rev); |
| 1209 | 1220 | }else |
| 1210 | 1221 | if( (zTemp = svn_find_header(rec, "Node-path")) ){ /* file/dir node */ |
| 1211 | 1222 | char *zAction = svn_find_header(rec, "Node-action"); |
| 1212 | 1223 | char *zKind = svn_find_header(rec, "Node-kind"); |
| 1213 | 1224 | char *zSrcPath = svn_find_header(rec, "Node-copyfrom-path"); |
| 1214 | 1225 | char *zPerm = svn_find_prop(rec, "svn:executable") ? "x" : 0; |
| 1215 | - char *zBranch; | |
| 1216 | 1226 | char *zFile; |
| 1217 | - char *zSrcBranch; | |
| 1227 | + int srcBranch; | |
| 1218 | 1228 | char *zSrcFile; |
| 1219 | 1229 | int deltaFlag = 0; |
| 1220 | 1230 | int srcRev = 0; |
| 1221 | - int branchType = svn_parse_path(zTemp, &zBranch, &zFile); | |
| 1222 | - if( branchType==0 ){ | |
| 1231 | + int branchId = svn_parse_path(zTemp, &zFile); | |
| 1232 | + if( branchId==0 ){ | |
| 1223 | 1233 | svn_free_rec(&rec); |
| 1224 | 1234 | continue; |
| 1225 | 1235 | } |
| 1226 | - db_bind_text(&addBranch, ":branch", zBranch); | |
| 1227 | - db_bind_int(&addBranch, ":type", branchType); | |
| 1228 | - db_step(&addBranch); | |
| 1229 | - db_reset(&addBranch); | |
| 1230 | 1236 | if( (zTemp = svn_find_header(rec, "Text-delta")) ){ |
| 1231 | 1237 | deltaFlag = strncmp(zTemp, "true", 4)==0; |
| 1232 | 1238 | } |
| 1233 | 1239 | if( zSrcPath ){ |
| 1234 | 1240 | zTemp = svn_find_header(rec, "Node-copyfrom-rev"); |
| @@ -1235,26 +1241,20 @@ | ||
| 1235 | 1241 | if( zTemp ){ |
| 1236 | 1242 | srcRev = atoi(zTemp); |
| 1237 | 1243 | }else{ |
| 1238 | 1244 | fossil_fatal("Missing copyfrom-rev"); |
| 1239 | 1245 | } |
| 1240 | - if( svn_parse_path(zSrcPath, &zSrcBranch, &zSrcFile)==0 ){ | |
| 1246 | + srcBranch = svn_parse_path(zSrcPath, &zSrcFile); | |
| 1247 | + if( srcBranch==0 ){ | |
| 1241 | 1248 | fossil_fatal("Copy from path outside the import paths"); |
| 1242 | 1249 | } |
| 1243 | - db_bind_text(&addSrc, ":path", zFile); | |
| 1244 | - db_bind_text(&addSrc, ":branch", zBranch); | |
| 1245 | - db_bind_text(&addSrc, ":srcpath", zSrcFile); | |
| 1246 | - db_bind_text(&addSrc, ":srcbranch", zSrcBranch); | |
| 1247 | - db_bind_int(&addSrc, ":srcrev", srcRev); | |
| 1248 | - db_step(&addSrc); | |
| 1249 | - db_reset(&addSrc); | |
| 1250 | 1250 | } |
| 1251 | 1251 | if( strncmp(zAction, "delete", 6)==0 |
| 1252 | 1252 | || strncmp(zAction, "replace", 7)==0 ) |
| 1253 | 1253 | { |
| 1254 | 1254 | db_bind_text(&delPath, ":path", zFile); |
| 1255 | - db_bind_text(&delPath, ":branch", zBranch); | |
| 1255 | + db_bind_text(&delPath, ":branch", branchId); | |
| 1256 | 1256 | db_step(&delPath); |
| 1257 | 1257 | db_reset(&delPath); |
| 1258 | 1258 | } /* no 'else' here since 'replace' does both a 'delete' and an 'add' */ |
| 1259 | 1259 | if( strncmp(zAction, "add", 3)==0 |
| 1260 | 1260 | || strncmp(zAction, "replace", 7)==0 ) |
| @@ -1456,19 +1456,20 @@ | ||
| 1456 | 1456 | db_finalize(&q); |
| 1457 | 1457 | }else |
| 1458 | 1458 | if( strncmp(g.argv[2], "svn", 3)==0 ){ |
| 1459 | 1459 | db_multi_exec( |
| 1460 | 1460 | "CREATE TEMP TABLE xrevisions(" |
| 1461 | - " tid INTEGER PRIMARY KEY, trev INTEGER, tbranch TEXT, ttype INT, trid INT," | |
| 1462 | - " UNIQUE(tbranch, ttype, trev)" | |
| 1461 | + " trev INTEGER, tbranch INT, trid INT, tparent INT," | |
| 1462 | + " UNIQUE(tbranch, trev), UNIQUE(trid)" | |
| 1463 | 1463 | ");" |
| 1464 | 1464 | "CREATE TEMP TABLE xfiles(" |
| 1465 | - " tpath TEXT, tbranch TEXT, tuuid TEXT, tperm TEXT," | |
| 1465 | + " tpath TEXT, tbranch INT, tuuid TEXT, tperm TEXT, tsrcpath TEXT" | |
| 1466 | 1466 | " UNIQUE (tbranch, tpath) ON CONFLICT REPLACE" |
| 1467 | 1467 | ");" |
| 1468 | - "CREATE TEMP TABLE xsrc(" | |
| 1469 | - " tpath TEXT, tbranch TEXT, tsrc TEXT, tsrcbranch TEXT, tsrcrev INT" | |
| 1468 | + "CREATE TEMP TABLE xbranches(" | |
| 1469 | + " tid INTEGER PRIMARY KEY, tbranch TEXT, ttype INT," | |
| 1470 | + " UNIQUE(tbranch, ttype)" | |
| 1470 | 1471 | ");" |
| 1471 | 1472 | "CREATE VIRTUAL TABLE temp.xfoci USING files_of_checkin;" |
| 1472 | 1473 | ); |
| 1473 | 1474 | if( zBase==0 ){ zBase = ""; } |
| 1474 | 1475 | if( strlen(zBase)>0 ){ |
| 1475 | 1476 |
| --- src/import.c | |
| +++ src/import.c | |
| @@ -1084,52 +1084,65 @@ | |
| 1084 | ** Returns: 1 - It is on the trunk |
| 1085 | ** 2 - It is on a branch |
| 1086 | ** 3 - It is a tag |
| 1087 | ** 0 - It is none of the above |
| 1088 | */ |
| 1089 | static int svn_parse_path(char *zPath, char **zBranch, char **zFile){ |
| 1090 | if( gsvn.lenTrunk==0 ){ |
| 1091 | *zBranch = "trunk"; |
| 1092 | *zFile = zPath; |
| 1093 | return 1; |
| 1094 | }else |
| 1095 | if( strncmp(zPath, gsvn.zTrunk, gsvn.lenTrunk-1)==0 ){ |
| 1096 | *zBranch = "trunk"; |
| 1097 | if( zPath[gsvn.lenTrunk-1]=='/' ){ |
| 1098 | *zFile = zPath+gsvn.lenTrunk;; |
| 1099 | }else if( zPath[gsvn.lenTrunk-1]==0 ){ |
| 1100 | *zFile = 0; |
| 1101 | }else{ |
| 1102 | *zFile = *zBranch = 0; |
| 1103 | return 0; |
| 1104 | } |
| 1105 | return 1; |
| 1106 | }else |
| 1107 | if( strncmp(zPath, gsvn.zBranches, gsvn.lenBranches)==0 ){ |
| 1108 | *zFile = *zBranch = zPath+gsvn.lenBranches; |
| 1109 | while( **zFile && **zFile!='/' ){ (*zFile)++; } |
| 1110 | if( *zFile ){ |
| 1111 | **zFile = '\0'; |
| 1112 | (*zFile)++; |
| 1113 | }else{ |
| 1114 | *zFile = 0; |
| 1115 | } |
| 1116 | return 2; |
| 1117 | }else |
| 1118 | if( strncmp(zPath, gsvn.zTags, gsvn.lenTags)==0 ){ |
| 1119 | *zFile = *zBranch = zPath+gsvn.lenTags; |
| 1120 | while( **zFile && **zFile!='/' ){ (*zFile)++; } |
| 1121 | if( *zFile ){ |
| 1122 | **zFile = '\0'; |
| 1123 | (*zFile)++; |
| 1124 | }else{ |
| 1125 | *zFile = 0; |
| 1126 | } |
| 1127 | return 3; |
| 1128 | } |
| 1129 | *zFile = *zBranch = 0; |
| 1130 | return 0; |
| 1131 | } |
| 1132 | |
| 1133 | /* |
| 1134 | ** Read the svn-dump format from pIn and insert the corresponding |
| 1135 | ** content into the database. |
| @@ -1170,16 +1183,13 @@ | |
| 1170 | db_prepare(&delPath, |
| 1171 | "DELETE FROM xfiles" |
| 1172 | " WHERE (tpath=:path OR (tpath>:path||'/' AND tpath<:path||'0'))" |
| 1173 | " AND tbranch=:branch" |
| 1174 | ); |
| 1175 | db_prepare(&addSrc, |
| 1176 | "INSERT INTO xsrc (tpath, tbranch, tsrc, tsrcbranch, tsrcrev)" |
| 1177 | " VALUES(:path, :branch, :srcpath, :srcbranch, :srcrev)" |
| 1178 | ); |
| 1179 | db_prepare(&addBranch, |
| 1180 | "INSERT INTO xchanges (tbranch, ttype) VALUES(:branch, :type)" |
| 1181 | ); |
| 1182 | db_prepare(&cpyPath, |
| 1183 | "INSERT INTO xfiles (tpath, tbranch, tuuid, tperm)" |
| 1184 | " SELECT :path||substr(filename, length(:srcpath)+1), :branch, uuid, perm" |
| 1185 | " FROM xfoci" |
| @@ -1203,32 +1213,28 @@ | |
| 1203 | zDate = svn_find_prop(rec, "svn:date"); |
| 1204 | if( zDate ){ |
| 1205 | zDate = date_in_standard_format(zDate); |
| 1206 | } |
| 1207 | gsvn.zDate = zDate; |
| 1208 | fossil_print("\rImporting SVN revision: %d", gsvn.rev); |
| 1209 | }else |
| 1210 | if( (zTemp = svn_find_header(rec, "Node-path")) ){ /* file/dir node */ |
| 1211 | char *zAction = svn_find_header(rec, "Node-action"); |
| 1212 | char *zKind = svn_find_header(rec, "Node-kind"); |
| 1213 | char *zSrcPath = svn_find_header(rec, "Node-copyfrom-path"); |
| 1214 | char *zPerm = svn_find_prop(rec, "svn:executable") ? "x" : 0; |
| 1215 | char *zBranch; |
| 1216 | char *zFile; |
| 1217 | char *zSrcBranch; |
| 1218 | char *zSrcFile; |
| 1219 | int deltaFlag = 0; |
| 1220 | int srcRev = 0; |
| 1221 | int branchType = svn_parse_path(zTemp, &zBranch, &zFile); |
| 1222 | if( branchType==0 ){ |
| 1223 | svn_free_rec(&rec); |
| 1224 | continue; |
| 1225 | } |
| 1226 | db_bind_text(&addBranch, ":branch", zBranch); |
| 1227 | db_bind_int(&addBranch, ":type", branchType); |
| 1228 | db_step(&addBranch); |
| 1229 | db_reset(&addBranch); |
| 1230 | if( (zTemp = svn_find_header(rec, "Text-delta")) ){ |
| 1231 | deltaFlag = strncmp(zTemp, "true", 4)==0; |
| 1232 | } |
| 1233 | if( zSrcPath ){ |
| 1234 | zTemp = svn_find_header(rec, "Node-copyfrom-rev"); |
| @@ -1235,26 +1241,20 @@ | |
| 1235 | if( zTemp ){ |
| 1236 | srcRev = atoi(zTemp); |
| 1237 | }else{ |
| 1238 | fossil_fatal("Missing copyfrom-rev"); |
| 1239 | } |
| 1240 | if( svn_parse_path(zSrcPath, &zSrcBranch, &zSrcFile)==0 ){ |
| 1241 | fossil_fatal("Copy from path outside the import paths"); |
| 1242 | } |
| 1243 | db_bind_text(&addSrc, ":path", zFile); |
| 1244 | db_bind_text(&addSrc, ":branch", zBranch); |
| 1245 | db_bind_text(&addSrc, ":srcpath", zSrcFile); |
| 1246 | db_bind_text(&addSrc, ":srcbranch", zSrcBranch); |
| 1247 | db_bind_int(&addSrc, ":srcrev", srcRev); |
| 1248 | db_step(&addSrc); |
| 1249 | db_reset(&addSrc); |
| 1250 | } |
| 1251 | if( strncmp(zAction, "delete", 6)==0 |
| 1252 | || strncmp(zAction, "replace", 7)==0 ) |
| 1253 | { |
| 1254 | db_bind_text(&delPath, ":path", zFile); |
| 1255 | db_bind_text(&delPath, ":branch", zBranch); |
| 1256 | db_step(&delPath); |
| 1257 | db_reset(&delPath); |
| 1258 | } /* no 'else' here since 'replace' does both a 'delete' and an 'add' */ |
| 1259 | if( strncmp(zAction, "add", 3)==0 |
| 1260 | || strncmp(zAction, "replace", 7)==0 ) |
| @@ -1456,19 +1456,20 @@ | |
| 1456 | db_finalize(&q); |
| 1457 | }else |
| 1458 | if( strncmp(g.argv[2], "svn", 3)==0 ){ |
| 1459 | db_multi_exec( |
| 1460 | "CREATE TEMP TABLE xrevisions(" |
| 1461 | " tid INTEGER PRIMARY KEY, trev INTEGER, tbranch TEXT, ttype INT, trid INT," |
| 1462 | " UNIQUE(tbranch, ttype, trev)" |
| 1463 | ");" |
| 1464 | "CREATE TEMP TABLE xfiles(" |
| 1465 | " tpath TEXT, tbranch TEXT, tuuid TEXT, tperm TEXT," |
| 1466 | " UNIQUE (tbranch, tpath) ON CONFLICT REPLACE" |
| 1467 | ");" |
| 1468 | "CREATE TEMP TABLE xsrc(" |
| 1469 | " tpath TEXT, tbranch TEXT, tsrc TEXT, tsrcbranch TEXT, tsrcrev INT" |
| 1470 | ");" |
| 1471 | "CREATE VIRTUAL TABLE temp.xfoci USING files_of_checkin;" |
| 1472 | ); |
| 1473 | if( zBase==0 ){ zBase = ""; } |
| 1474 | if( strlen(zBase)>0 ){ |
| 1475 |
| --- src/import.c | |
| +++ src/import.c | |
| @@ -1084,52 +1084,65 @@ | |
| 1084 | ** Returns: 1 - It is on the trunk |
| 1085 | ** 2 - It is on a branch |
| 1086 | ** 3 - It is a tag |
| 1087 | ** 0 - It is none of the above |
| 1088 | */ |
| 1089 | static int svn_parse_path(char *zPath, char **zFile){ |
| 1090 | int type = 0; |
| 1091 | char *zBranch = 0; |
| 1092 | int branchId = 0; |
| 1093 | *zFile = 0; |
| 1094 | if( gsvn.lenTrunk==0 ){ |
| 1095 | zBranch = "trunk"; |
| 1096 | *zFile = zPath; |
| 1097 | type = 1; |
| 1098 | }else |
| 1099 | if( strncmp(zPath, gsvn.zTrunk, gsvn.lenTrunk-1)==0 ){ |
| 1100 | zBranch = "trunk"; |
| 1101 | if( zPath[gsvn.lenTrunk-1]=='/' ){ |
| 1102 | *zFile = zPath+gsvn.lenTrunk;; |
| 1103 | }else if( zPath[gsvn.lenTrunk-1]==0 ){ |
| 1104 | *zFile = 0; |
| 1105 | }else{ |
| 1106 | *zFile = zBranch = 0; |
| 1107 | type = 0; |
| 1108 | } |
| 1109 | type = 1; |
| 1110 | }else |
| 1111 | if( strncmp(zPath, gsvn.zBranches, gsvn.lenBranches)==0 ){ |
| 1112 | *zFile = zBranch = zPath+gsvn.lenBranches; |
| 1113 | while( **zFile && **zFile!='/' ){ (*zFile)++; } |
| 1114 | if( *zFile ){ |
| 1115 | **zFile = '\0'; |
| 1116 | (*zFile)++; |
| 1117 | }else{ |
| 1118 | *zFile = 0; |
| 1119 | } |
| 1120 | type = 2; |
| 1121 | }else |
| 1122 | if( strncmp(zPath, gsvn.zTags, gsvn.lenTags)==0 ){ |
| 1123 | *zFile = zBranch = zPath+gsvn.lenTags; |
| 1124 | while( **zFile && **zFile!='/' ){ (*zFile)++; } |
| 1125 | if( *zFile ){ |
| 1126 | **zFile = '\0'; |
| 1127 | (*zFile)++; |
| 1128 | }else{ |
| 1129 | *zFile = 0; |
| 1130 | } |
| 1131 | type = 3; |
| 1132 | } |
| 1133 | if( type>0 ){ |
| 1134 | branchId = db_int(0, |
| 1135 | "SELECT tid FROM xbranches WHERE tbranch=%Q AND ttype=%d", |
| 1136 | zBranch, branchType); |
| 1137 | if( branchId==0 ){ |
| 1138 | db_multi_exec("INSERT INTO xbranches (tbranch, ttype) VALUES(%Q, %d)", |
| 1139 | zBranch, branchType); |
| 1140 | branchId = db_last_insert_rowid(); |
| 1141 | } |
| 1142 | } |
| 1143 | return branchId; |
| 1144 | } |
| 1145 | |
| 1146 | /* |
| 1147 | ** Read the svn-dump format from pIn and insert the corresponding |
| 1148 | ** content into the database. |
| @@ -1170,16 +1183,13 @@ | |
| 1183 | db_prepare(&delPath, |
| 1184 | "DELETE FROM xfiles" |
| 1185 | " WHERE (tpath=:path OR (tpath>:path||'/' AND tpath<:path||'0'))" |
| 1186 | " AND tbranch=:branch" |
| 1187 | ); |
| 1188 | db_prepare(&addRev, |
| 1189 | "INSERT OR IGNORE INTO xrevisions (trev, tbranch, tparent)" |
| 1190 | " VALUES(:rev, :branch, :parent)" |
| 1191 | ); |
| 1192 | db_prepare(&cpyPath, |
| 1193 | "INSERT INTO xfiles (tpath, tbranch, tuuid, tperm)" |
| 1194 | " SELECT :path||substr(filename, length(:srcpath)+1), :branch, uuid, perm" |
| 1195 | " FROM xfoci" |
| @@ -1203,32 +1213,28 @@ | |
| 1213 | zDate = svn_find_prop(rec, "svn:date"); |
| 1214 | if( zDate ){ |
| 1215 | zDate = date_in_standard_format(zDate); |
| 1216 | } |
| 1217 | gsvn.zDate = zDate; |
| 1218 | db_bind_int(&addRev, ":rev", gsvn.rev); |
| 1219 | fossil_print("\rImporting SVN revision: %d", gsvn.rev); |
| 1220 | }else |
| 1221 | if( (zTemp = svn_find_header(rec, "Node-path")) ){ /* file/dir node */ |
| 1222 | char *zAction = svn_find_header(rec, "Node-action"); |
| 1223 | char *zKind = svn_find_header(rec, "Node-kind"); |
| 1224 | char *zSrcPath = svn_find_header(rec, "Node-copyfrom-path"); |
| 1225 | char *zPerm = svn_find_prop(rec, "svn:executable") ? "x" : 0; |
| 1226 | char *zFile; |
| 1227 | int srcBranch; |
| 1228 | char *zSrcFile; |
| 1229 | int deltaFlag = 0; |
| 1230 | int srcRev = 0; |
| 1231 | int branchId = svn_parse_path(zTemp, &zFile); |
| 1232 | if( branchId==0 ){ |
| 1233 | svn_free_rec(&rec); |
| 1234 | continue; |
| 1235 | } |
| 1236 | if( (zTemp = svn_find_header(rec, "Text-delta")) ){ |
| 1237 | deltaFlag = strncmp(zTemp, "true", 4)==0; |
| 1238 | } |
| 1239 | if( zSrcPath ){ |
| 1240 | zTemp = svn_find_header(rec, "Node-copyfrom-rev"); |
| @@ -1235,26 +1241,20 @@ | |
| 1241 | if( zTemp ){ |
| 1242 | srcRev = atoi(zTemp); |
| 1243 | }else{ |
| 1244 | fossil_fatal("Missing copyfrom-rev"); |
| 1245 | } |
| 1246 | srcBranch = svn_parse_path(zSrcPath, &zSrcFile); |
| 1247 | if( srcBranch==0 ){ |
| 1248 | fossil_fatal("Copy from path outside the import paths"); |
| 1249 | } |
| 1250 | } |
| 1251 | if( strncmp(zAction, "delete", 6)==0 |
| 1252 | || strncmp(zAction, "replace", 7)==0 ) |
| 1253 | { |
| 1254 | db_bind_text(&delPath, ":path", zFile); |
| 1255 | db_bind_text(&delPath, ":branch", branchId); |
| 1256 | db_step(&delPath); |
| 1257 | db_reset(&delPath); |
| 1258 | } /* no 'else' here since 'replace' does both a 'delete' and an 'add' */ |
| 1259 | if( strncmp(zAction, "add", 3)==0 |
| 1260 | || strncmp(zAction, "replace", 7)==0 ) |
| @@ -1456,19 +1456,20 @@ | |
| 1456 | db_finalize(&q); |
| 1457 | }else |
| 1458 | if( strncmp(g.argv[2], "svn", 3)==0 ){ |
| 1459 | db_multi_exec( |
| 1460 | "CREATE TEMP TABLE xrevisions(" |
| 1461 | " trev INTEGER, tbranch INT, trid INT, tparent INT," |
| 1462 | " UNIQUE(tbranch, trev), UNIQUE(trid)" |
| 1463 | ");" |
| 1464 | "CREATE TEMP TABLE xfiles(" |
| 1465 | " tpath TEXT, tbranch INT, tuuid TEXT, tperm TEXT, tsrcpath TEXT" |
| 1466 | " UNIQUE (tbranch, tpath) ON CONFLICT REPLACE" |
| 1467 | ");" |
| 1468 | "CREATE TEMP TABLE xbranches(" |
| 1469 | " tid INTEGER PRIMARY KEY, tbranch TEXT, ttype INT," |
| 1470 | " UNIQUE(tbranch, ttype)" |
| 1471 | ");" |
| 1472 | "CREATE VIRTUAL TABLE temp.xfoci USING files_of_checkin;" |
| 1473 | ); |
| 1474 | if( zBase==0 ){ zBase = ""; } |
| 1475 | if( strlen(zBase)>0 ){ |
| 1476 |