Fossil SCM
Fixes for detecting branch cration
Commit
855f233b69884126f4580c159f82f7ccec926f82
Parent
2b6fc1dd2c43d06…
1 file changed
+52
-39
+52
-39
| --- src/import.c | ||
| +++ src/import.c | ||
| @@ -728,10 +728,11 @@ | ||
| 728 | 728 | int lenTrunk; /* String length of zTrunk */ |
| 729 | 729 | const char *zBranches; /* Name of branches folder in repo root */ |
| 730 | 730 | int lenBranches; /* String length of zBranches */ |
| 731 | 731 | const char *zTags; /* Name of tags folder in repo root */ |
| 732 | 732 | int lenTags; /* String length of zTags */ |
| 733 | + Bag newBranches; /* Branches that were created in this revision */ | |
| 733 | 734 | } gsvn; |
| 734 | 735 | typedef struct { |
| 735 | 736 | char *zKey; |
| 736 | 737 | char *zVal; |
| 737 | 738 | } KeyVal; |
| @@ -918,11 +919,11 @@ | ||
| 918 | 919 | while( db_step(&getChanges)==SQLITE_ROW ){ |
| 919 | 920 | int branchId = db_column_int(&getChanges, 0); |
| 920 | 921 | const char *zBranch = db_column_text(&getChanges, 1); |
| 921 | 922 | int branchType = db_column_int(&getChanges, 2); |
| 922 | 923 | int parentRid = db_column_int(&getChanges, 3); |
| 923 | - int onBranch = 0; | |
| 924 | + int mergeRid = parentRid; | |
| 924 | 925 | int rid; |
| 925 | 926 | if( branchType!=3 ){ |
| 926 | 927 | if( gsvn.zComment ){ |
| 927 | 928 | blob_appendf(&manifest, "C %F\n", gsvn.zComment); |
| 928 | 929 | }else{ |
| @@ -935,44 +936,47 @@ | ||
| 935 | 936 | const char *zUuid = db_column_text(&getFiles, 1); |
| 936 | 937 | const char *zPerm = db_column_text(&getFiles, 2); |
| 937 | 938 | blob_appendf(&manifest, "F %F %s %s\n", zFile, zUuid, zPerm); |
| 938 | 939 | } |
| 939 | 940 | db_reset(&getFiles); |
| 940 | - if( parentRid==0 ){ | |
| 941 | + if( !bag_find(&gsvn.newBranches, branchId) ){ | |
| 941 | 942 | parentRid = db_int(0, "SELECT trid, max(trev) FROM xrevisions" |
| 942 | 943 | " WHERE trev<%d AND tbranch=%d", gsvn.rev, branchId); |
| 943 | - onBranch = 1; | |
| 944 | 944 | } |
| 945 | 945 | if( parentRid>0 ){ |
| 946 | 946 | const char *zParentUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", parentRid); |
| 947 | - blob_appendf(&manifest, "P %s\n", zParentUuid); | |
| 948 | - if( onBranch==0 ){ | |
| 947 | + if( parentRid==mergeRid || mergeRid==0){ | |
| 948 | + const char *zParentBranch = db_text(0, "SELECT tname FROM xbranches WHERE tid=(SELECT tbranch FROM xrevisions WHERE trid=%d)", parentRid); | |
| 949 | + blob_appendf(&manifest, "P %s\n", zParentUuid); | |
| 949 | 950 | blob_appendf(&manifest, "T *branch * %F\n", zBranch); |
| 950 | 951 | blob_appendf(&manifest, "T *sym-%F *\n", zBranch); |
| 951 | - } | |
| 952 | - blob_appendf(&manifest, "T +sym-svn-rev-%d *\n", gsvn.rev); | |
| 953 | - if( onBranch==0 ){ | |
| 954 | - const char *zParentBranch = db_text(0, "SELECT tbranch FROM xbranches WHERE tid=(SELECT tbranch FROM xrevisions WHERE trid=%d)", parentRid); | |
| 955 | - blob_appendf(&manifest, "T -sym-%s *\n", zParentBranch); | |
| 952 | + blob_appendf(&manifest, "T +sym-svn-rev-%d *\n", gsvn.rev); | |
| 953 | + blob_appendf(&manifest, "T -sym-%F *\n", zParentBranch); | |
| 954 | + }else{ | |
| 955 | + const char *zMergeUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", mergeRid); | |
| 956 | + blob_appendf(&manifest, "P %s %s\n", zParentUuid, zMergeUuid); | |
| 957 | + blob_appendf(&manifest, "T +sym-svn-rev-%d *\n", gsvn.rev); | |
| 956 | 958 | } |
| 957 | 959 | }else{ |
| 958 | 960 | blob_appendf(&manifest, "T *branch * %F\n", zBranch); |
| 959 | 961 | blob_appendf(&manifest, "T *sym-%F *\n", zBranch); |
| 960 | 962 | blob_appendf(&manifest, "T +sym-svn-rev-%d *\n", gsvn.rev); |
| 961 | 963 | } |
| 962 | - if( gsvn.zUser ){ | |
| 963 | - blob_appendf(&manifest, "U %F\n", gsvn.zUser); | |
| 964 | - }else{ | |
| 965 | - const char *zUserOvrd = find_option("user-override",0,1); | |
| 966 | - blob_appendf(&manifest, "U %F\n", zUserOvrd ? zUserOvrd : login_name()); | |
| 967 | - } | |
| 968 | - md5sum_blob(&manifest, &mcksum); | |
| 969 | - blob_appendf(&manifest, "Z %b\n", &mcksum); | |
| 970 | - blob_reset(&mcksum); | |
| 971 | - }else{ | |
| 972 | -// TODO tag | |
| 973 | - } | |
| 964 | + }else{ | |
| 965 | + const char *zParentUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", parentRid); | |
| 966 | + blob_appendf(&manifest, "D %s\n", gsvn.zDate); | |
| 967 | + blob_appendf(&manifest, "T +sym-%F %s\n", zBranch, zParentUuid); | |
| 968 | + } | |
| 969 | + if( gsvn.zUser ){ | |
| 970 | + blob_appendf(&manifest, "U %F\n", gsvn.zUser); | |
| 971 | + }else{ | |
| 972 | + const char *zUserOvrd = find_option("user-override",0,1); | |
| 973 | + blob_appendf(&manifest, "U %F\n", zUserOvrd ? zUserOvrd : login_name()); | |
| 974 | + } | |
| 975 | + md5sum_blob(&manifest, &mcksum); | |
| 976 | + blob_appendf(&manifest, "Z %b\n", &mcksum); | |
| 977 | + blob_reset(&mcksum); | |
| 974 | 978 | rid = content_put(&manifest); |
| 975 | 979 | db_bind_int(&setRid, ":branch", branchId); |
| 976 | 980 | db_bind_int(&setRid, ":rid", rid); |
| 977 | 981 | db_step(&setRid); |
| 978 | 982 | db_reset(&setRid); |
| @@ -1065,11 +1069,11 @@ | ||
| 1065 | 1069 | type = 1; |
| 1066 | 1070 | }else |
| 1067 | 1071 | if( strncmp(zPath, gsvn.zBranches, gsvn.lenBranches)==0 ){ |
| 1068 | 1072 | *zFile = zBranch = zPath+gsvn.lenBranches; |
| 1069 | 1073 | while( **zFile && **zFile!='/' ){ (*zFile)++; } |
| 1070 | - if( *zFile ){ | |
| 1074 | + if( **zFile ){ | |
| 1071 | 1075 | **zFile = '\0'; |
| 1072 | 1076 | (*zFile)++; |
| 1073 | 1077 | }else{ |
| 1074 | 1078 | *zFile = 0; |
| 1075 | 1079 | } |
| @@ -1076,11 +1080,11 @@ | ||
| 1076 | 1080 | type = 2; |
| 1077 | 1081 | }else |
| 1078 | 1082 | if( strncmp(zPath, gsvn.zTags, gsvn.lenTags)==0 ){ |
| 1079 | 1083 | *zFile = zBranch = zPath+gsvn.lenTags; |
| 1080 | 1084 | while( **zFile && **zFile!='/' ){ (*zFile)++; } |
| 1081 | - if( *zFile ){ | |
| 1085 | + if( **zFile ){ | |
| 1082 | 1086 | **zFile = '\0'; |
| 1083 | 1087 | (*zFile)++; |
| 1084 | 1088 | }else{ |
| 1085 | 1089 | *zFile = 0; |
| 1086 | 1090 | } |
| @@ -1140,32 +1144,33 @@ | ||
| 1140 | 1144 | "DELETE FROM xfiles" |
| 1141 | 1145 | " WHERE (tpath=:path OR (tpath>:path||'/' AND tpath<:path||'0'))" |
| 1142 | 1146 | " AND tbranch=:branch" |
| 1143 | 1147 | ); |
| 1144 | 1148 | db_prepare(&addRev, |
| 1145 | - "INSERT OR IGNORE INTO xrevisions (trev, tbranch)" | |
| 1146 | - " VALUES(:rev, :branch)" | |
| 1149 | + "INSERT OR IGNORE INTO xrevisions (trev, tbranch) VALUES(:rev, :branch)" | |
| 1147 | 1150 | ); |
| 1148 | 1151 | db_prepare(&cpyPath, |
| 1149 | 1152 | "INSERT INTO xfiles (tpath, tbranch, tuuid, tperm)" |
| 1150 | 1153 | " SELECT :path||substr(filename, length(:srcpath)+1), :branch, uuid, perm" |
| 1151 | 1154 | " FROM xfoci" |
| 1152 | 1155 | " WHERE checkinID=:rid AND filename>:srcpath||'/' AND filename<:srcpath||'0'" |
| 1153 | 1156 | ); |
| 1154 | 1157 | db_prepare(&revSrc, |
| 1155 | - "UPDATE xrevisions SET tparent=:parent WHERE trev=:rev AND tbranch=:branch" | |
| 1158 | + "UPDATE xrevisions SET tparent=:parent WHERE trev=:rev AND tbranch=:branch AND tparent<:parent" | |
| 1156 | 1159 | ); |
| 1157 | 1160 | gsvn.rev = -1; |
| 1161 | + bag_init(&gsvn.newBranches); | |
| 1158 | 1162 | while( svn_read_rec(pIn, &rec) ){ |
| 1159 | 1163 | if( (zTemp = svn_find_header(rec, "Revision-number")) ){ /* revision node */ |
| 1160 | 1164 | /* finish previous revision */ |
| 1161 | 1165 | char *zDate = NULL; |
| 1162 | 1166 | if( gsvn.rev>=0 ){ |
| 1163 | 1167 | svn_finish_revision(); |
| 1164 | 1168 | fossil_free(gsvn.zUser); |
| 1165 | 1169 | fossil_free(gsvn.zComment); |
| 1166 | 1170 | fossil_free(gsvn.zDate); |
| 1171 | + bag_clear(&gsvn.newBranches); | |
| 1167 | 1172 | } |
| 1168 | 1173 | /* start new revision */ |
| 1169 | 1174 | gsvn.rev = atoi(zTemp); |
| 1170 | 1175 | gsvn.zUser = mprintf("%s", svn_find_prop(rec, "svn:author")); |
| 1171 | 1176 | gsvn.zComment = mprintf("%s", svn_find_prop(rec, "svn:log")); |
| @@ -1206,10 +1211,13 @@ | ||
| 1206 | 1211 | srcBranch = svn_parse_path(zSrcPath, &zSrcFile); |
| 1207 | 1212 | if( srcBranch==0 ){ |
| 1208 | 1213 | fossil_fatal("Copy from path outside the import paths"); |
| 1209 | 1214 | } |
| 1210 | 1215 | } |
| 1216 | + if( zFile==0 ){ | |
| 1217 | + bag_insert(&gsvn.newBranches, branchId); | |
| 1218 | + } | |
| 1211 | 1219 | if( strncmp(zAction, "delete", 6)==0 |
| 1212 | 1220 | || strncmp(zAction, "replace", 7)==0 ) |
| 1213 | 1221 | { |
| 1214 | 1222 | db_bind_text(&delPath, ":path", zFile); |
| 1215 | 1223 | db_bind_int(&delPath, ":branch", branchId); |
| @@ -1227,22 +1235,22 @@ | ||
| 1227 | 1235 | }else if( strncmp(zKind, "dir", 3)==0 ){ |
| 1228 | 1236 | if( zSrcPath ){ |
| 1229 | 1237 | int srcRid = db_int(0, "SELECT trid, max(trev) FROM xrevisions" |
| 1230 | 1238 | " WHERE trev<=%d AND tbranch=%d", |
| 1231 | 1239 | srcRev, srcBranch); |
| 1232 | - db_bind_text(&cpyPath, ":path", zFile); | |
| 1233 | - db_bind_int(&cpyPath, ":branch", branchId); | |
| 1234 | - db_bind_text(&cpyPath, ":srcpath", zSrcFile); | |
| 1235 | - db_bind_int(&cpyPath, ":rid", srcRid); | |
| 1236 | - db_step(&cpyPath); | |
| 1237 | - db_reset(&cpyPath); | |
| 1238 | - db_bind_int(&addRev, ":branch", branchId); | |
| 1239 | - db_step(&addRev); | |
| 1240 | - db_reset(&addRev); | |
| 1241 | - if( zFile==0 ){ | |
| 1240 | + if( srcRid>0 ){ | |
| 1241 | + db_bind_text(&cpyPath, ":path", zFile); | |
| 1242 | + db_bind_int(&cpyPath, ":branch", branchId); | |
| 1243 | + db_bind_text(&cpyPath, ":srcpath", zSrcFile); | |
| 1244 | + db_bind_int(&cpyPath, ":rid", srcRid); | |
| 1245 | + db_step(&cpyPath); | |
| 1246 | + db_reset(&cpyPath); | |
| 1247 | + db_bind_int(&addRev, ":branch", branchId); | |
| 1248 | + db_step(&addRev); | |
| 1249 | + db_reset(&addRev); | |
| 1242 | 1250 | db_bind_int(&revSrc, ":parent", srcRid); |
| 1243 | - db_bind_int(&revSrc, ":rev", srcRev); | |
| 1251 | + db_bind_int(&revSrc, ":rev", gsvn.rev); | |
| 1244 | 1252 | db_bind_int(&revSrc, ":branch", branchId); |
| 1245 | 1253 | db_step(&revSrc); |
| 1246 | 1254 | db_reset(&revSrc); |
| 1247 | 1255 | } |
| 1248 | 1256 | } |
| @@ -1255,10 +1263,15 @@ | ||
| 1255 | 1263 | rid = db_int(0, "SELECT rid FROM blob WHERE uuid=(" |
| 1256 | 1264 | " SELECT uuid FROM xfoci" |
| 1257 | 1265 | " WHERE checkinID=%d AND filename=%Q" |
| 1258 | 1266 | ")", |
| 1259 | 1267 | srcRid, zSrcFile); |
| 1268 | + db_bind_int(&revSrc, ":parent", srcRid); | |
| 1269 | + db_bind_int(&revSrc, ":rev", gsvn.rev); | |
| 1270 | + db_bind_int(&revSrc, ":branch", branchId); | |
| 1271 | + db_step(&revSrc); | |
| 1272 | + db_reset(&revSrc); | |
| 1260 | 1273 | } |
| 1261 | 1274 | if( deltaFlag ){ |
| 1262 | 1275 | Blob deltaSrc; |
| 1263 | 1276 | Blob target; |
| 1264 | 1277 | if( rid!=0 ){ |
| @@ -1435,11 +1448,11 @@ | ||
| 1435 | 1448 | db_finalize(&q); |
| 1436 | 1449 | }else |
| 1437 | 1450 | if( strncmp(g.argv[2], "svn", 3)==0 ){ |
| 1438 | 1451 | db_multi_exec( |
| 1439 | 1452 | "CREATE TEMP TABLE xrevisions(" |
| 1440 | - " trev INTEGER, tbranch INT, trid INT, tparent INT," | |
| 1453 | + " trev INTEGER, tbranch INT, trid INT, tparent INT DEFAULT 0," | |
| 1441 | 1454 | " UNIQUE(tbranch, trev), UNIQUE(trid)" |
| 1442 | 1455 | ");" |
| 1443 | 1456 | "CREATE TEMP TABLE xfiles(" |
| 1444 | 1457 | " tpath TEXT, tbranch INT, tuuid TEXT, tperm TEXT," |
| 1445 | 1458 | " UNIQUE (tbranch, tpath) ON CONFLICT REPLACE" |
| 1446 | 1459 |
| --- src/import.c | |
| +++ src/import.c | |
| @@ -728,10 +728,11 @@ | |
| 728 | int lenTrunk; /* String length of zTrunk */ |
| 729 | const char *zBranches; /* Name of branches folder in repo root */ |
| 730 | int lenBranches; /* String length of zBranches */ |
| 731 | const char *zTags; /* Name of tags folder in repo root */ |
| 732 | int lenTags; /* String length of zTags */ |
| 733 | } gsvn; |
| 734 | typedef struct { |
| 735 | char *zKey; |
| 736 | char *zVal; |
| 737 | } KeyVal; |
| @@ -918,11 +919,11 @@ | |
| 918 | while( db_step(&getChanges)==SQLITE_ROW ){ |
| 919 | int branchId = db_column_int(&getChanges, 0); |
| 920 | const char *zBranch = db_column_text(&getChanges, 1); |
| 921 | int branchType = db_column_int(&getChanges, 2); |
| 922 | int parentRid = db_column_int(&getChanges, 3); |
| 923 | int onBranch = 0; |
| 924 | int rid; |
| 925 | if( branchType!=3 ){ |
| 926 | if( gsvn.zComment ){ |
| 927 | blob_appendf(&manifest, "C %F\n", gsvn.zComment); |
| 928 | }else{ |
| @@ -935,44 +936,47 @@ | |
| 935 | const char *zUuid = db_column_text(&getFiles, 1); |
| 936 | const char *zPerm = db_column_text(&getFiles, 2); |
| 937 | blob_appendf(&manifest, "F %F %s %s\n", zFile, zUuid, zPerm); |
| 938 | } |
| 939 | db_reset(&getFiles); |
| 940 | if( parentRid==0 ){ |
| 941 | parentRid = db_int(0, "SELECT trid, max(trev) FROM xrevisions" |
| 942 | " WHERE trev<%d AND tbranch=%d", gsvn.rev, branchId); |
| 943 | onBranch = 1; |
| 944 | } |
| 945 | if( parentRid>0 ){ |
| 946 | const char *zParentUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", parentRid); |
| 947 | blob_appendf(&manifest, "P %s\n", zParentUuid); |
| 948 | if( onBranch==0 ){ |
| 949 | blob_appendf(&manifest, "T *branch * %F\n", zBranch); |
| 950 | blob_appendf(&manifest, "T *sym-%F *\n", zBranch); |
| 951 | } |
| 952 | blob_appendf(&manifest, "T +sym-svn-rev-%d *\n", gsvn.rev); |
| 953 | if( onBranch==0 ){ |
| 954 | const char *zParentBranch = db_text(0, "SELECT tbranch FROM xbranches WHERE tid=(SELECT tbranch FROM xrevisions WHERE trid=%d)", parentRid); |
| 955 | blob_appendf(&manifest, "T -sym-%s *\n", zParentBranch); |
| 956 | } |
| 957 | }else{ |
| 958 | blob_appendf(&manifest, "T *branch * %F\n", zBranch); |
| 959 | blob_appendf(&manifest, "T *sym-%F *\n", zBranch); |
| 960 | blob_appendf(&manifest, "T +sym-svn-rev-%d *\n", gsvn.rev); |
| 961 | } |
| 962 | if( gsvn.zUser ){ |
| 963 | blob_appendf(&manifest, "U %F\n", gsvn.zUser); |
| 964 | }else{ |
| 965 | const char *zUserOvrd = find_option("user-override",0,1); |
| 966 | blob_appendf(&manifest, "U %F\n", zUserOvrd ? zUserOvrd : login_name()); |
| 967 | } |
| 968 | md5sum_blob(&manifest, &mcksum); |
| 969 | blob_appendf(&manifest, "Z %b\n", &mcksum); |
| 970 | blob_reset(&mcksum); |
| 971 | }else{ |
| 972 | // TODO tag |
| 973 | } |
| 974 | rid = content_put(&manifest); |
| 975 | db_bind_int(&setRid, ":branch", branchId); |
| 976 | db_bind_int(&setRid, ":rid", rid); |
| 977 | db_step(&setRid); |
| 978 | db_reset(&setRid); |
| @@ -1065,11 +1069,11 @@ | |
| 1065 | type = 1; |
| 1066 | }else |
| 1067 | if( strncmp(zPath, gsvn.zBranches, gsvn.lenBranches)==0 ){ |
| 1068 | *zFile = zBranch = zPath+gsvn.lenBranches; |
| 1069 | while( **zFile && **zFile!='/' ){ (*zFile)++; } |
| 1070 | if( *zFile ){ |
| 1071 | **zFile = '\0'; |
| 1072 | (*zFile)++; |
| 1073 | }else{ |
| 1074 | *zFile = 0; |
| 1075 | } |
| @@ -1076,11 +1080,11 @@ | |
| 1076 | type = 2; |
| 1077 | }else |
| 1078 | if( strncmp(zPath, gsvn.zTags, gsvn.lenTags)==0 ){ |
| 1079 | *zFile = zBranch = zPath+gsvn.lenTags; |
| 1080 | while( **zFile && **zFile!='/' ){ (*zFile)++; } |
| 1081 | if( *zFile ){ |
| 1082 | **zFile = '\0'; |
| 1083 | (*zFile)++; |
| 1084 | }else{ |
| 1085 | *zFile = 0; |
| 1086 | } |
| @@ -1140,32 +1144,33 @@ | |
| 1140 | "DELETE FROM xfiles" |
| 1141 | " WHERE (tpath=:path OR (tpath>:path||'/' AND tpath<:path||'0'))" |
| 1142 | " AND tbranch=:branch" |
| 1143 | ); |
| 1144 | db_prepare(&addRev, |
| 1145 | "INSERT OR IGNORE INTO xrevisions (trev, tbranch)" |
| 1146 | " VALUES(:rev, :branch)" |
| 1147 | ); |
| 1148 | db_prepare(&cpyPath, |
| 1149 | "INSERT INTO xfiles (tpath, tbranch, tuuid, tperm)" |
| 1150 | " SELECT :path||substr(filename, length(:srcpath)+1), :branch, uuid, perm" |
| 1151 | " FROM xfoci" |
| 1152 | " WHERE checkinID=:rid AND filename>:srcpath||'/' AND filename<:srcpath||'0'" |
| 1153 | ); |
| 1154 | db_prepare(&revSrc, |
| 1155 | "UPDATE xrevisions SET tparent=:parent WHERE trev=:rev AND tbranch=:branch" |
| 1156 | ); |
| 1157 | gsvn.rev = -1; |
| 1158 | while( svn_read_rec(pIn, &rec) ){ |
| 1159 | if( (zTemp = svn_find_header(rec, "Revision-number")) ){ /* revision node */ |
| 1160 | /* finish previous revision */ |
| 1161 | char *zDate = NULL; |
| 1162 | if( gsvn.rev>=0 ){ |
| 1163 | svn_finish_revision(); |
| 1164 | fossil_free(gsvn.zUser); |
| 1165 | fossil_free(gsvn.zComment); |
| 1166 | fossil_free(gsvn.zDate); |
| 1167 | } |
| 1168 | /* start new revision */ |
| 1169 | gsvn.rev = atoi(zTemp); |
| 1170 | gsvn.zUser = mprintf("%s", svn_find_prop(rec, "svn:author")); |
| 1171 | gsvn.zComment = mprintf("%s", svn_find_prop(rec, "svn:log")); |
| @@ -1206,10 +1211,13 @@ | |
| 1206 | srcBranch = svn_parse_path(zSrcPath, &zSrcFile); |
| 1207 | if( srcBranch==0 ){ |
| 1208 | fossil_fatal("Copy from path outside the import paths"); |
| 1209 | } |
| 1210 | } |
| 1211 | if( strncmp(zAction, "delete", 6)==0 |
| 1212 | || strncmp(zAction, "replace", 7)==0 ) |
| 1213 | { |
| 1214 | db_bind_text(&delPath, ":path", zFile); |
| 1215 | db_bind_int(&delPath, ":branch", branchId); |
| @@ -1227,22 +1235,22 @@ | |
| 1227 | }else if( strncmp(zKind, "dir", 3)==0 ){ |
| 1228 | if( zSrcPath ){ |
| 1229 | int srcRid = db_int(0, "SELECT trid, max(trev) FROM xrevisions" |
| 1230 | " WHERE trev<=%d AND tbranch=%d", |
| 1231 | srcRev, srcBranch); |
| 1232 | db_bind_text(&cpyPath, ":path", zFile); |
| 1233 | db_bind_int(&cpyPath, ":branch", branchId); |
| 1234 | db_bind_text(&cpyPath, ":srcpath", zSrcFile); |
| 1235 | db_bind_int(&cpyPath, ":rid", srcRid); |
| 1236 | db_step(&cpyPath); |
| 1237 | db_reset(&cpyPath); |
| 1238 | db_bind_int(&addRev, ":branch", branchId); |
| 1239 | db_step(&addRev); |
| 1240 | db_reset(&addRev); |
| 1241 | if( zFile==0 ){ |
| 1242 | db_bind_int(&revSrc, ":parent", srcRid); |
| 1243 | db_bind_int(&revSrc, ":rev", srcRev); |
| 1244 | db_bind_int(&revSrc, ":branch", branchId); |
| 1245 | db_step(&revSrc); |
| 1246 | db_reset(&revSrc); |
| 1247 | } |
| 1248 | } |
| @@ -1255,10 +1263,15 @@ | |
| 1255 | rid = db_int(0, "SELECT rid FROM blob WHERE uuid=(" |
| 1256 | " SELECT uuid FROM xfoci" |
| 1257 | " WHERE checkinID=%d AND filename=%Q" |
| 1258 | ")", |
| 1259 | srcRid, zSrcFile); |
| 1260 | } |
| 1261 | if( deltaFlag ){ |
| 1262 | Blob deltaSrc; |
| 1263 | Blob target; |
| 1264 | if( rid!=0 ){ |
| @@ -1435,11 +1448,11 @@ | |
| 1435 | db_finalize(&q); |
| 1436 | }else |
| 1437 | if( strncmp(g.argv[2], "svn", 3)==0 ){ |
| 1438 | db_multi_exec( |
| 1439 | "CREATE TEMP TABLE xrevisions(" |
| 1440 | " trev INTEGER, tbranch INT, trid INT, tparent INT," |
| 1441 | " UNIQUE(tbranch, trev), UNIQUE(trid)" |
| 1442 | ");" |
| 1443 | "CREATE TEMP TABLE xfiles(" |
| 1444 | " tpath TEXT, tbranch INT, tuuid TEXT, tperm TEXT," |
| 1445 | " UNIQUE (tbranch, tpath) ON CONFLICT REPLACE" |
| 1446 |
| --- src/import.c | |
| +++ src/import.c | |
| @@ -728,10 +728,11 @@ | |
| 728 | int lenTrunk; /* String length of zTrunk */ |
| 729 | const char *zBranches; /* Name of branches folder in repo root */ |
| 730 | int lenBranches; /* String length of zBranches */ |
| 731 | const char *zTags; /* Name of tags folder in repo root */ |
| 732 | int lenTags; /* String length of zTags */ |
| 733 | Bag newBranches; /* Branches that were created in this revision */ |
| 734 | } gsvn; |
| 735 | typedef struct { |
| 736 | char *zKey; |
| 737 | char *zVal; |
| 738 | } KeyVal; |
| @@ -918,11 +919,11 @@ | |
| 919 | while( db_step(&getChanges)==SQLITE_ROW ){ |
| 920 | int branchId = db_column_int(&getChanges, 0); |
| 921 | const char *zBranch = db_column_text(&getChanges, 1); |
| 922 | int branchType = db_column_int(&getChanges, 2); |
| 923 | int parentRid = db_column_int(&getChanges, 3); |
| 924 | int mergeRid = parentRid; |
| 925 | int rid; |
| 926 | if( branchType!=3 ){ |
| 927 | if( gsvn.zComment ){ |
| 928 | blob_appendf(&manifest, "C %F\n", gsvn.zComment); |
| 929 | }else{ |
| @@ -935,44 +936,47 @@ | |
| 936 | const char *zUuid = db_column_text(&getFiles, 1); |
| 937 | const char *zPerm = db_column_text(&getFiles, 2); |
| 938 | blob_appendf(&manifest, "F %F %s %s\n", zFile, zUuid, zPerm); |
| 939 | } |
| 940 | db_reset(&getFiles); |
| 941 | if( !bag_find(&gsvn.newBranches, branchId) ){ |
| 942 | parentRid = db_int(0, "SELECT trid, max(trev) FROM xrevisions" |
| 943 | " WHERE trev<%d AND tbranch=%d", gsvn.rev, branchId); |
| 944 | } |
| 945 | if( parentRid>0 ){ |
| 946 | const char *zParentUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", parentRid); |
| 947 | if( parentRid==mergeRid || mergeRid==0){ |
| 948 | const char *zParentBranch = db_text(0, "SELECT tname FROM xbranches WHERE tid=(SELECT tbranch FROM xrevisions WHERE trid=%d)", parentRid); |
| 949 | blob_appendf(&manifest, "P %s\n", zParentUuid); |
| 950 | blob_appendf(&manifest, "T *branch * %F\n", zBranch); |
| 951 | blob_appendf(&manifest, "T *sym-%F *\n", zBranch); |
| 952 | blob_appendf(&manifest, "T +sym-svn-rev-%d *\n", gsvn.rev); |
| 953 | blob_appendf(&manifest, "T -sym-%F *\n", zParentBranch); |
| 954 | }else{ |
| 955 | const char *zMergeUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", mergeRid); |
| 956 | blob_appendf(&manifest, "P %s %s\n", zParentUuid, zMergeUuid); |
| 957 | blob_appendf(&manifest, "T +sym-svn-rev-%d *\n", gsvn.rev); |
| 958 | } |
| 959 | }else{ |
| 960 | blob_appendf(&manifest, "T *branch * %F\n", zBranch); |
| 961 | blob_appendf(&manifest, "T *sym-%F *\n", zBranch); |
| 962 | blob_appendf(&manifest, "T +sym-svn-rev-%d *\n", gsvn.rev); |
| 963 | } |
| 964 | }else{ |
| 965 | const char *zParentUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", parentRid); |
| 966 | blob_appendf(&manifest, "D %s\n", gsvn.zDate); |
| 967 | blob_appendf(&manifest, "T +sym-%F %s\n", zBranch, zParentUuid); |
| 968 | } |
| 969 | if( gsvn.zUser ){ |
| 970 | blob_appendf(&manifest, "U %F\n", gsvn.zUser); |
| 971 | }else{ |
| 972 | const char *zUserOvrd = find_option("user-override",0,1); |
| 973 | blob_appendf(&manifest, "U %F\n", zUserOvrd ? zUserOvrd : login_name()); |
| 974 | } |
| 975 | md5sum_blob(&manifest, &mcksum); |
| 976 | blob_appendf(&manifest, "Z %b\n", &mcksum); |
| 977 | blob_reset(&mcksum); |
| 978 | rid = content_put(&manifest); |
| 979 | db_bind_int(&setRid, ":branch", branchId); |
| 980 | db_bind_int(&setRid, ":rid", rid); |
| 981 | db_step(&setRid); |
| 982 | db_reset(&setRid); |
| @@ -1065,11 +1069,11 @@ | |
| 1069 | type = 1; |
| 1070 | }else |
| 1071 | if( strncmp(zPath, gsvn.zBranches, gsvn.lenBranches)==0 ){ |
| 1072 | *zFile = zBranch = zPath+gsvn.lenBranches; |
| 1073 | while( **zFile && **zFile!='/' ){ (*zFile)++; } |
| 1074 | if( **zFile ){ |
| 1075 | **zFile = '\0'; |
| 1076 | (*zFile)++; |
| 1077 | }else{ |
| 1078 | *zFile = 0; |
| 1079 | } |
| @@ -1076,11 +1080,11 @@ | |
| 1080 | type = 2; |
| 1081 | }else |
| 1082 | if( strncmp(zPath, gsvn.zTags, gsvn.lenTags)==0 ){ |
| 1083 | *zFile = zBranch = zPath+gsvn.lenTags; |
| 1084 | while( **zFile && **zFile!='/' ){ (*zFile)++; } |
| 1085 | if( **zFile ){ |
| 1086 | **zFile = '\0'; |
| 1087 | (*zFile)++; |
| 1088 | }else{ |
| 1089 | *zFile = 0; |
| 1090 | } |
| @@ -1140,32 +1144,33 @@ | |
| 1144 | "DELETE FROM xfiles" |
| 1145 | " WHERE (tpath=:path OR (tpath>:path||'/' AND tpath<:path||'0'))" |
| 1146 | " AND tbranch=:branch" |
| 1147 | ); |
| 1148 | db_prepare(&addRev, |
| 1149 | "INSERT OR IGNORE INTO xrevisions (trev, tbranch) VALUES(:rev, :branch)" |
| 1150 | ); |
| 1151 | db_prepare(&cpyPath, |
| 1152 | "INSERT INTO xfiles (tpath, tbranch, tuuid, tperm)" |
| 1153 | " SELECT :path||substr(filename, length(:srcpath)+1), :branch, uuid, perm" |
| 1154 | " FROM xfoci" |
| 1155 | " WHERE checkinID=:rid AND filename>:srcpath||'/' AND filename<:srcpath||'0'" |
| 1156 | ); |
| 1157 | db_prepare(&revSrc, |
| 1158 | "UPDATE xrevisions SET tparent=:parent WHERE trev=:rev AND tbranch=:branch AND tparent<:parent" |
| 1159 | ); |
| 1160 | gsvn.rev = -1; |
| 1161 | bag_init(&gsvn.newBranches); |
| 1162 | while( svn_read_rec(pIn, &rec) ){ |
| 1163 | if( (zTemp = svn_find_header(rec, "Revision-number")) ){ /* revision node */ |
| 1164 | /* finish previous revision */ |
| 1165 | char *zDate = NULL; |
| 1166 | if( gsvn.rev>=0 ){ |
| 1167 | svn_finish_revision(); |
| 1168 | fossil_free(gsvn.zUser); |
| 1169 | fossil_free(gsvn.zComment); |
| 1170 | fossil_free(gsvn.zDate); |
| 1171 | bag_clear(&gsvn.newBranches); |
| 1172 | } |
| 1173 | /* start new revision */ |
| 1174 | gsvn.rev = atoi(zTemp); |
| 1175 | gsvn.zUser = mprintf("%s", svn_find_prop(rec, "svn:author")); |
| 1176 | gsvn.zComment = mprintf("%s", svn_find_prop(rec, "svn:log")); |
| @@ -1206,10 +1211,13 @@ | |
| 1211 | srcBranch = svn_parse_path(zSrcPath, &zSrcFile); |
| 1212 | if( srcBranch==0 ){ |
| 1213 | fossil_fatal("Copy from path outside the import paths"); |
| 1214 | } |
| 1215 | } |
| 1216 | if( zFile==0 ){ |
| 1217 | bag_insert(&gsvn.newBranches, branchId); |
| 1218 | } |
| 1219 | if( strncmp(zAction, "delete", 6)==0 |
| 1220 | || strncmp(zAction, "replace", 7)==0 ) |
| 1221 | { |
| 1222 | db_bind_text(&delPath, ":path", zFile); |
| 1223 | db_bind_int(&delPath, ":branch", branchId); |
| @@ -1227,22 +1235,22 @@ | |
| 1235 | }else if( strncmp(zKind, "dir", 3)==0 ){ |
| 1236 | if( zSrcPath ){ |
| 1237 | int srcRid = db_int(0, "SELECT trid, max(trev) FROM xrevisions" |
| 1238 | " WHERE trev<=%d AND tbranch=%d", |
| 1239 | srcRev, srcBranch); |
| 1240 | if( srcRid>0 ){ |
| 1241 | db_bind_text(&cpyPath, ":path", zFile); |
| 1242 | db_bind_int(&cpyPath, ":branch", branchId); |
| 1243 | db_bind_text(&cpyPath, ":srcpath", zSrcFile); |
| 1244 | db_bind_int(&cpyPath, ":rid", srcRid); |
| 1245 | db_step(&cpyPath); |
| 1246 | db_reset(&cpyPath); |
| 1247 | db_bind_int(&addRev, ":branch", branchId); |
| 1248 | db_step(&addRev); |
| 1249 | db_reset(&addRev); |
| 1250 | db_bind_int(&revSrc, ":parent", srcRid); |
| 1251 | db_bind_int(&revSrc, ":rev", gsvn.rev); |
| 1252 | db_bind_int(&revSrc, ":branch", branchId); |
| 1253 | db_step(&revSrc); |
| 1254 | db_reset(&revSrc); |
| 1255 | } |
| 1256 | } |
| @@ -1255,10 +1263,15 @@ | |
| 1263 | rid = db_int(0, "SELECT rid FROM blob WHERE uuid=(" |
| 1264 | " SELECT uuid FROM xfoci" |
| 1265 | " WHERE checkinID=%d AND filename=%Q" |
| 1266 | ")", |
| 1267 | srcRid, zSrcFile); |
| 1268 | db_bind_int(&revSrc, ":parent", srcRid); |
| 1269 | db_bind_int(&revSrc, ":rev", gsvn.rev); |
| 1270 | db_bind_int(&revSrc, ":branch", branchId); |
| 1271 | db_step(&revSrc); |
| 1272 | db_reset(&revSrc); |
| 1273 | } |
| 1274 | if( deltaFlag ){ |
| 1275 | Blob deltaSrc; |
| 1276 | Blob target; |
| 1277 | if( rid!=0 ){ |
| @@ -1435,11 +1448,11 @@ | |
| 1448 | db_finalize(&q); |
| 1449 | }else |
| 1450 | if( strncmp(g.argv[2], "svn", 3)==0 ){ |
| 1451 | db_multi_exec( |
| 1452 | "CREATE TEMP TABLE xrevisions(" |
| 1453 | " trev INTEGER, tbranch INT, trid INT, tparent INT DEFAULT 0," |
| 1454 | " UNIQUE(tbranch, trev), UNIQUE(trid)" |
| 1455 | ");" |
| 1456 | "CREATE TEMP TABLE xfiles(" |
| 1457 | " tpath TEXT, tbranch INT, tuuid TEXT, tperm TEXT," |
| 1458 | " UNIQUE (tbranch, tpath) ON CONFLICT REPLACE" |
| 1459 |