Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Allow using tags as copy-source Move variables to smaller scope, as per coding style guidelines |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | svn-import |
Files: | files | file ages | folders |
SHA1: |
997da4f0e45fb25098d35aab1868c864 |
User & Date: | baruch 2015-01-11 11:30:46 |
Context
2015-01-11
| ||
12:44 | Change "magic numbers" to named constants check-in: c8e00eb1f5 user: baruch tags: svn-import | |
11:30 | Allow using tags as copy-source Move variables to smaller scope, as per coding style guidelines check-in: 997da4f0e4 user: baruch tags: svn-import | |
08:02 | Fix issue with branching from a branch check-in: 93134dda26 user: baruch tags: svn-import | |
Changes
Changes to src/import.c.
︙ | ︙ | |||
950 951 952 953 954 955 956 | db_reset(&getFiles); if( !bag_find(&gsvn.newBranches, branchId) ){ parentRid = db_int(0, "SELECT trid, max(trev) FROM xrevisions" " WHERE trev<%d AND tbranch=%d", gsvn.rev, branchId); } if( parentRid>0 ){ | | | | > | | 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 | db_reset(&getFiles); if( !bag_find(&gsvn.newBranches, branchId) ){ parentRid = db_int(0, "SELECT trid, max(trev) FROM xrevisions" " WHERE trev<%d AND tbranch=%d", gsvn.rev, branchId); } if( parentRid>0 ){ char *zParentUuid = rid_to_uuid(parentRid); if( parentRid==mergeRid || mergeRid==0){ char *zParentBranch = db_text(0, "SELECT tname FROM xbranches WHERE tid=" " (SELECT tbranch FROM xrevisions WHERE trid=%d)", parentRid ); blob_appendf(&manifest, "P %s\n", zParentUuid); blob_appendf(&manifest, "T *branch * %F\n", zBranch); blob_appendf(&manifest, "T *sym-%F *\n", zBranch); blob_appendf(&manifest, "T +sym-svn-rev-%d *\n", gsvn.rev); blob_appendf(&manifest, "T -sym-%F *\n", zParentBranch); fossil_free(zParentBranch); }else{ char *zMergeUuid = rid_to_uuid(mergeRid); blob_appendf(&manifest, "P %s %s\n", zParentUuid, zMergeUuid); blob_appendf(&manifest, "T +sym-svn-rev-%d *\n", gsvn.rev); fossil_free(zMergeUuid); } fossil_free(zParentUuid); }else{ blob_appendf(&manifest, "T *branch * %F\n", zBranch); blob_appendf(&manifest, "T *sym-%F *\n", zBranch); blob_appendf(&manifest, "T +sym-svn-rev-%d *\n", gsvn.rev); } }else{ char *zParentUuid = rid_to_uuid(parentRid); blob_appendf(&manifest, "D %s\n", gsvn.zDate); blob_appendf(&manifest, "T +sym-%F %s\n", zBranch, zParentUuid); fossil_free(zParentUuid); } if( gsvn.zUser ){ blob_appendf(&manifest, "U %F\n", gsvn.zUser); }else{ |
︙ | ︙ | |||
1054 1055 1056 1057 1058 1059 1060 | } } zDiff += lenData; } } /* | | < < < < | < > | | | | | | > > > > > > > > < < < < < < < < | < < | | | | 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 | } } zDiff += lenData; } } /* ** Extract the branch or tag that the given path is on. Return the branch ID. */ static int svn_parse_path(char *zPath, char **zFile, int *type){ char *zBranch = 0; int branchId = 0; *type = 0; *zFile = 0; if( gsvn.lenTrunk==0 ){ zBranch = "trunk"; *zFile = zPath; *type = 1; }else if( strncmp(zPath, gsvn.zTrunk, gsvn.lenTrunk-1)==0 ){ if( zPath[gsvn.lenTrunk-1]=='/' || zPath[gsvn.lenTrunk-1]==0 ){ zBranch = "trunk"; *zFile = zPath+gsvn.lenTrunk; *type = 1; }else{ zBranch = 0; *type = 0; } }else{ if( strncmp(zPath, gsvn.zBranches, gsvn.lenBranches)==0 ){ *zFile = zBranch = zPath+gsvn.lenBranches; *type = 2; }else if( strncmp(zPath, gsvn.zTags, gsvn.lenTags)==0 ){ *zFile = zBranch = zPath+gsvn.lenTags; *type = 3; }else{ /* Not a branch, tag or trunk */ return 0; } while( **zFile && **zFile!='/' ){ (*zFile)++; } if( **zFile ){ **zFile = '\0'; (*zFile)++; } } if( *type>0 ){ branchId = db_int(0, "SELECT tid FROM xbranches WHERE tname=%Q AND ttype=%d", zBranch, *type); if( branchId==0 ){ db_multi_exec("INSERT INTO xbranches (tname, ttype) VALUES(%Q, %d)", zBranch, *type); branchId = db_last_insert_rowid(); } } return branchId; } /* |
︙ | ︙ | |||
1140 1141 1142 1143 1144 1145 1146 | } }else{ fossil_fatal("Input is not an svn-dump!"); } svn_free_rec(&rec); /* UUID */ if( !svn_read_rec(pIn, &rec) || !(zUuid = svn_find_header(rec, "UUID")) ){ | > | | 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 | } }else{ fossil_fatal("Input is not an svn-dump!"); } svn_free_rec(&rec); /* UUID */ if( !svn_read_rec(pIn, &rec) || !(zUuid = svn_find_header(rec, "UUID")) ){ /* Removed the following line since UUID is not actually used fossil_fatal("Missing UUID!"); */ } svn_free_rec(&rec); /* content */ db_prepare(&addFile, "INSERT INTO xfiles (tpath, tbranch, tuuid, tperm)" " VALUES(:path, :branch, (SELECT uuid FROM blob WHERE rid=:rid), :perm)" |
︙ | ︙ | |||
1202 1203 1204 1205 1206 1207 1208 1209 1210 | }else{ gsvn.zDate = date_in_standard_format("now"); } db_bind_int(&addRev, ":rev", gsvn.rev); fossil_print("\rImporting SVN revision: %d", gsvn.rev); }else if( (zTemp = svn_find_header(rec, "Node-path")) ){ /* file/dir node */ char *zAction = svn_find_header(rec, "Node-action"); char *zKind = svn_find_header(rec, "Node-kind"); | > > > < < < < < < < < < < < < < < < < < > > > > > | > > | > > | > > | | | > > > > > > > > > > > > > > > > > > > > | 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 | }else{ gsvn.zDate = date_in_standard_format("now"); } db_bind_int(&addRev, ":rev", gsvn.rev); fossil_print("\rImporting SVN revision: %d", gsvn.rev); }else if( (zTemp = svn_find_header(rec, "Node-path")) ){ /* file/dir node */ char *zFile; int branchType; int branchId = svn_parse_path(zTemp, &zFile, &branchType); char *zAction = svn_find_header(rec, "Node-action"); char *zKind = svn_find_header(rec, "Node-kind"); char *zPerm = svn_find_prop(rec, "svn:executable") ? "x" : 0; int deltaFlag = 0; int srcRev = 0; if( branchId==0 ){ svn_free_rec(&rec); continue; } if( (zTemp = svn_find_header(rec, "Text-delta")) ){ deltaFlag = strncmp(zTemp, "true", 4)==0; } if( zFile[0]==0 ){ bag_insert(&gsvn.newBranches, branchId); } if( strncmp(zAction, "delete", 6)==0 || strncmp(zAction, "replace", 7)==0 ) { //TODO delete root db_bind_text(&delPath, ":path", zFile); db_bind_int(&delPath, ":branch", branchId); db_step(&delPath); db_reset(&delPath); db_bind_int(&addRev, ":branch", branchId); db_step(&addRev); db_reset(&addRev); } /* no 'else' here since 'replace' does both a 'delete' and an 'add' */ if( strncmp(zAction, "add", 3)==0 || strncmp(zAction, "replace", 7)==0 ) { char *zSrcPath = svn_find_header(rec, "Node-copyfrom-path"); char *zSrcFile; int srcRid = 0; if( zSrcPath ){ int srcBranch; zTemp = svn_find_header(rec, "Node-copyfrom-rev"); if( zTemp ){ srcRev = atoi(zTemp); }else{ fossil_fatal("Missing copyfrom-rev"); } srcBranch = svn_parse_path(zSrcPath, &zSrcFile, &branchType); if( srcBranch==0 ){ fossil_fatal("Copy from path outside the import paths"); } if( branchType!=3 ){ srcRid = db_int(0, "SELECT trid, max(trev) FROM xrevisions" " WHERE trev<=%d AND tbranch=%d", srcRev, srcBranch); }else{ srcRid = db_int(0, "SELECT tparent, max(trev) FROM xrevisions" " WHERE trev<=%d AND tbranch=%d", srcRev, srcBranch); } if( srcRid>0 && srcBranch!=branchId ){ db_bind_int(&addRev, ":branch", branchId); db_step(&addRev); db_reset(&addRev); db_bind_int(&revSrc, ":parent", srcRid); db_bind_int(&revSrc, ":rev", gsvn.rev); db_bind_int(&revSrc, ":branch", branchId); db_step(&revSrc); db_reset(&revSrc); } } if( zKind==0 ){ fossil_fatal("Missing Node-kind"); }else if( strncmp(zKind, "dir", 3)==0 ){ if( zSrcPath ){ if( srcRid>0 ){ if( zFile[0]==0 ){ db_bind_text(&cpyRoot, ":path", zFile); db_bind_int(&cpyRoot, ":branch", branchId); db_bind_int(&cpyRoot, ":rid", srcRid); db_step(&cpyRoot); db_reset(&cpyRoot); |
︙ | ︙ | |||
1280 1281 1282 1283 1284 1285 1286 | db_step(&addRev); db_reset(&addRev); } } }else{ int rid = 0; if( zSrcPath ){ | < < < | 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 | db_step(&addRev); db_reset(&addRev); } } }else{ int rid = 0; if( zSrcPath ){ rid = db_int(0, "SELECT rid FROM blob WHERE uuid=(" " SELECT uuid FROM xfoci" " WHERE checkinID=%d AND filename=%Q" ")", srcRid, zSrcFile); } if( deltaFlag ){ |
︙ | ︙ | |||
1312 1313 1314 1315 1316 1317 1318 | db_bind_text(&addFile, ":perm", zPerm); db_step(&addFile); db_reset(&addFile); db_bind_int(&addRev, ":branch", branchId); db_step(&addRev); db_reset(&addRev); } | < < < < < < < | 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 | db_bind_text(&addFile, ":perm", zPerm); db_step(&addFile); db_reset(&addFile); db_bind_int(&addRev, ":branch", branchId); db_step(&addRev); db_reset(&addRev); } }else if( strncmp(zAction, "change", 6)==0 ){ int rid = 0; if( zKind==0 ){ fossil_fatal("Missing Node-kind"); } if( strncmp(zKind, "dir", 3)!=0 ){ |
︙ | ︙ |