Fossil SCM
Can now import full dump. Still only flat and only format 2
Commit
8d2e67512d585183f3cf3386aa4b7b5efe20ae48
Parent
0edbf144f367563…
1 file changed
+43
-25
+43
-25
| --- src/import.c | ||
| +++ src/import.c | ||
| @@ -977,11 +977,12 @@ | ||
| 977 | 977 | "INSERT INTO xfiles (trev, tpath, trid, tperm) " |
| 978 | 978 | "VALUES(:rev, :path, :rid, :perm)" |
| 979 | 979 | ); |
| 980 | 980 | db_prepare(&delFile, |
| 981 | 981 | "DELETE FROM xfiles " |
| 982 | - "WHERE trev=:rev AND (tpath=:path OR tpath GLOB :path || '/*')" | |
| 982 | + "WHERE trev=:rev " | |
| 983 | + " AND (tpath=:path OR (tpath>:path||'/' AND tpath<:path||'0'))" | |
| 983 | 984 | ); |
| 984 | 985 | while( svn_read_rec(pIn, &rec) ){ |
| 985 | 986 | if( zTemp = svn_find_header(rec, "Revision-number") ){ |
| 986 | 987 | const char *zUser = svn_find_prop(rec, "svn:author"); |
| 987 | 988 | const char *zLog = svn_find_prop(rec, "svn:log"); |
| @@ -1007,52 +1008,69 @@ | ||
| 1007 | 1008 | const char *zKind = svn_find_header(rec, "Node-kind"); |
| 1008 | 1009 | const char *zSrcPath = svn_find_header(rec, "Node-copyfrom-path"); |
| 1009 | 1010 | const char *zPerm = svn_find_prop(rec, "svn:executable") ? "x" : 0; |
| 1010 | 1011 | int srcRev = -1; |
| 1011 | 1012 | int rid = 0; |
| 1012 | - if( zKind && strncmp(zKind, "dir", 3)==0 ){ | |
| 1013 | - svn_free_rec(&rec); | |
| 1014 | - continue; | |
| 1015 | - } | |
| 1016 | 1013 | if( zSrcPath ){ |
| 1017 | 1014 | zTemp = svn_find_header(rec, "Node-copyfrom-rev"); |
| 1018 | 1015 | if( zTemp ){ |
| 1019 | 1016 | srcRev = atoi(zTemp); |
| 1020 | 1017 | }else{ |
| 1021 | 1018 | fossil_fatal("Missing copyfrom-rev"); |
| 1022 | 1019 | } |
| 1023 | 1020 | } |
| 1024 | - rid = content_put(&rec.content); | |
| 1025 | - if( strncmp(zAction, "add", 3)==0 ){ | |
| 1026 | - if( blob_size(&rec.content)>0 && zSrcPath!=0 ){ | |
| 1027 | - rid = db_int(rid, | |
| 1028 | - "SELECT trid FROM xfiles WHERE trev=%d AND tpath=%Q", | |
| 1029 | - srcRev, zSrcPath); | |
| 1030 | - } | |
| 1031 | - db_bind_int(&insFile, ":rev", rev); | |
| 1032 | - db_bind_int(&insFile, ":rid", rid); | |
| 1033 | - db_bind_text(&insFile, ":path", zPath); | |
| 1034 | - db_bind_text(&insFile, ":perm", zPerm); | |
| 1035 | - db_step(&insFile); | |
| 1036 | - db_reset(&insFile); | |
| 1021 | + if( strncmp(zAction, "delete", 6)==0 | |
| 1022 | + || strncmp(zAction, "replace", 7)==0 ) | |
| 1023 | + { | |
| 1024 | + db_bind_int(&delFile, ":rev", rev); | |
| 1025 | + db_bind_text(&delFile, ":path", zPath); | |
| 1026 | + db_step(&delFile); | |
| 1027 | + db_reset(&delFile); | |
| 1028 | + } /* no 'else' here since 'replace' does both a 'delete' and an 'add' */ | |
| 1029 | + if( strncmp(zAction, "add", 3)==0 | |
| 1030 | + || strncmp(zAction, "replace", 7)==0 ) | |
| 1031 | + { | |
| 1032 | + if( zKind==0 ){ | |
| 1033 | + fossil_fatal("Missing Node-kind"); | |
| 1034 | + }else if( strncmp(zKind, "dir", 3)==0 ){ | |
| 1035 | + if( zSrcPath ){ | |
| 1036 | + db_multi_exec( | |
| 1037 | + "INSERT INTO xfiles (trev, tpath, trid, tperm) " | |
| 1038 | + " SELECT %d, %Q||substr(tpath, length(%Q)+1), trid, tperm " | |
| 1039 | + " FROM xfiles " | |
| 1040 | + " WHERE trev=%d AND tpath GLOB '%q/*'", | |
| 1041 | + rev, zPath, zSrcPath, srcRev, zSrcPath | |
| 1042 | + ); | |
| 1043 | + } | |
| 1044 | + }else{ | |
| 1045 | + if( blob_size(&rec.content)==0 && zSrcPath ){ | |
| 1046 | + rid = db_int(rid, | |
| 1047 | + "SELECT trid FROM xfiles WHERE trev=%d AND tpath=%Q", | |
| 1048 | + srcRev, zSrcPath); | |
| 1049 | + }else{ | |
| 1050 | + rid = content_put(&rec.content); | |
| 1051 | + } | |
| 1052 | + db_bind_int(&insFile, ":rev", rev); | |
| 1053 | + db_bind_int(&insFile, ":rid", rid); | |
| 1054 | + db_bind_text(&insFile, ":path", zPath); | |
| 1055 | + db_bind_text(&insFile, ":perm", zPerm); | |
| 1056 | + db_step(&insFile); | |
| 1057 | + db_reset(&insFile); | |
| 1058 | + } | |
| 1037 | 1059 | }else |
| 1038 | 1060 | if( strncmp(zAction, "change", 6)==0 ){ |
| 1061 | + rid = content_put(&rec.content); | |
| 1039 | 1062 | db_bind_int(&insFile, ":rev", rev); |
| 1040 | 1063 | db_bind_int(&insFile, ":rid", rid); |
| 1041 | 1064 | db_bind_text(&insFile, ":path", zPath); |
| 1042 | 1065 | db_bind_text(&insFile, ":perm", zPerm); |
| 1043 | 1066 | db_step(&insFile); |
| 1044 | 1067 | db_reset(&insFile); |
| 1045 | 1068 | }else |
| 1046 | - if( strncmp(zAction, "delete", 6)==0 ){ | |
| 1047 | - db_bind_int(&delFile, ":rev", rev); | |
| 1048 | - db_bind_text(&delFile, ":path", zPath); | |
| 1049 | - db_step(&delFile); | |
| 1050 | - db_reset(&delFile); | |
| 1051 | - }else | |
| 1052 | - if( strncmp(zAction, "replace", 7)==0 ){ | |
| 1069 | + if( strncmp(zAction, "delete", 6)==0){ /* already did this above */ | |
| 1053 | 1070 | }else{ |
| 1071 | + fossil_fatal("Unknown Node-action"); | |
| 1054 | 1072 | } |
| 1055 | 1073 | }else{ |
| 1056 | 1074 | fossil_fatal("Unknown record type"); |
| 1057 | 1075 | } |
| 1058 | 1076 | svn_free_rec(&rec); |
| 1059 | 1077 |
| --- src/import.c | |
| +++ src/import.c | |
| @@ -977,11 +977,12 @@ | |
| 977 | "INSERT INTO xfiles (trev, tpath, trid, tperm) " |
| 978 | "VALUES(:rev, :path, :rid, :perm)" |
| 979 | ); |
| 980 | db_prepare(&delFile, |
| 981 | "DELETE FROM xfiles " |
| 982 | "WHERE trev=:rev AND (tpath=:path OR tpath GLOB :path || '/*')" |
| 983 | ); |
| 984 | while( svn_read_rec(pIn, &rec) ){ |
| 985 | if( zTemp = svn_find_header(rec, "Revision-number") ){ |
| 986 | const char *zUser = svn_find_prop(rec, "svn:author"); |
| 987 | const char *zLog = svn_find_prop(rec, "svn:log"); |
| @@ -1007,52 +1008,69 @@ | |
| 1007 | const char *zKind = svn_find_header(rec, "Node-kind"); |
| 1008 | const char *zSrcPath = svn_find_header(rec, "Node-copyfrom-path"); |
| 1009 | const char *zPerm = svn_find_prop(rec, "svn:executable") ? "x" : 0; |
| 1010 | int srcRev = -1; |
| 1011 | int rid = 0; |
| 1012 | if( zKind && strncmp(zKind, "dir", 3)==0 ){ |
| 1013 | svn_free_rec(&rec); |
| 1014 | continue; |
| 1015 | } |
| 1016 | if( zSrcPath ){ |
| 1017 | zTemp = svn_find_header(rec, "Node-copyfrom-rev"); |
| 1018 | if( zTemp ){ |
| 1019 | srcRev = atoi(zTemp); |
| 1020 | }else{ |
| 1021 | fossil_fatal("Missing copyfrom-rev"); |
| 1022 | } |
| 1023 | } |
| 1024 | rid = content_put(&rec.content); |
| 1025 | if( strncmp(zAction, "add", 3)==0 ){ |
| 1026 | if( blob_size(&rec.content)>0 && zSrcPath!=0 ){ |
| 1027 | rid = db_int(rid, |
| 1028 | "SELECT trid FROM xfiles WHERE trev=%d AND tpath=%Q", |
| 1029 | srcRev, zSrcPath); |
| 1030 | } |
| 1031 | db_bind_int(&insFile, ":rev", rev); |
| 1032 | db_bind_int(&insFile, ":rid", rid); |
| 1033 | db_bind_text(&insFile, ":path", zPath); |
| 1034 | db_bind_text(&insFile, ":perm", zPerm); |
| 1035 | db_step(&insFile); |
| 1036 | db_reset(&insFile); |
| 1037 | }else |
| 1038 | if( strncmp(zAction, "change", 6)==0 ){ |
| 1039 | db_bind_int(&insFile, ":rev", rev); |
| 1040 | db_bind_int(&insFile, ":rid", rid); |
| 1041 | db_bind_text(&insFile, ":path", zPath); |
| 1042 | db_bind_text(&insFile, ":perm", zPerm); |
| 1043 | db_step(&insFile); |
| 1044 | db_reset(&insFile); |
| 1045 | }else |
| 1046 | if( strncmp(zAction, "delete", 6)==0 ){ |
| 1047 | db_bind_int(&delFile, ":rev", rev); |
| 1048 | db_bind_text(&delFile, ":path", zPath); |
| 1049 | db_step(&delFile); |
| 1050 | db_reset(&delFile); |
| 1051 | }else |
| 1052 | if( strncmp(zAction, "replace", 7)==0 ){ |
| 1053 | }else{ |
| 1054 | } |
| 1055 | }else{ |
| 1056 | fossil_fatal("Unknown record type"); |
| 1057 | } |
| 1058 | svn_free_rec(&rec); |
| 1059 |
| --- src/import.c | |
| +++ src/import.c | |
| @@ -977,11 +977,12 @@ | |
| 977 | "INSERT INTO xfiles (trev, tpath, trid, tperm) " |
| 978 | "VALUES(:rev, :path, :rid, :perm)" |
| 979 | ); |
| 980 | db_prepare(&delFile, |
| 981 | "DELETE FROM xfiles " |
| 982 | "WHERE trev=:rev " |
| 983 | " AND (tpath=:path OR (tpath>:path||'/' AND tpath<:path||'0'))" |
| 984 | ); |
| 985 | while( svn_read_rec(pIn, &rec) ){ |
| 986 | if( zTemp = svn_find_header(rec, "Revision-number") ){ |
| 987 | const char *zUser = svn_find_prop(rec, "svn:author"); |
| 988 | const char *zLog = svn_find_prop(rec, "svn:log"); |
| @@ -1007,52 +1008,69 @@ | |
| 1008 | const char *zKind = svn_find_header(rec, "Node-kind"); |
| 1009 | const char *zSrcPath = svn_find_header(rec, "Node-copyfrom-path"); |
| 1010 | const char *zPerm = svn_find_prop(rec, "svn:executable") ? "x" : 0; |
| 1011 | int srcRev = -1; |
| 1012 | int rid = 0; |
| 1013 | if( zSrcPath ){ |
| 1014 | zTemp = svn_find_header(rec, "Node-copyfrom-rev"); |
| 1015 | if( zTemp ){ |
| 1016 | srcRev = atoi(zTemp); |
| 1017 | }else{ |
| 1018 | fossil_fatal("Missing copyfrom-rev"); |
| 1019 | } |
| 1020 | } |
| 1021 | if( strncmp(zAction, "delete", 6)==0 |
| 1022 | || strncmp(zAction, "replace", 7)==0 ) |
| 1023 | { |
| 1024 | db_bind_int(&delFile, ":rev", rev); |
| 1025 | db_bind_text(&delFile, ":path", zPath); |
| 1026 | db_step(&delFile); |
| 1027 | db_reset(&delFile); |
| 1028 | } /* no 'else' here since 'replace' does both a 'delete' and an 'add' */ |
| 1029 | if( strncmp(zAction, "add", 3)==0 |
| 1030 | || strncmp(zAction, "replace", 7)==0 ) |
| 1031 | { |
| 1032 | if( zKind==0 ){ |
| 1033 | fossil_fatal("Missing Node-kind"); |
| 1034 | }else if( strncmp(zKind, "dir", 3)==0 ){ |
| 1035 | if( zSrcPath ){ |
| 1036 | db_multi_exec( |
| 1037 | "INSERT INTO xfiles (trev, tpath, trid, tperm) " |
| 1038 | " SELECT %d, %Q||substr(tpath, length(%Q)+1), trid, tperm " |
| 1039 | " FROM xfiles " |
| 1040 | " WHERE trev=%d AND tpath GLOB '%q/*'", |
| 1041 | rev, zPath, zSrcPath, srcRev, zSrcPath |
| 1042 | ); |
| 1043 | } |
| 1044 | }else{ |
| 1045 | if( blob_size(&rec.content)==0 && zSrcPath ){ |
| 1046 | rid = db_int(rid, |
| 1047 | "SELECT trid FROM xfiles WHERE trev=%d AND tpath=%Q", |
| 1048 | srcRev, zSrcPath); |
| 1049 | }else{ |
| 1050 | rid = content_put(&rec.content); |
| 1051 | } |
| 1052 | db_bind_int(&insFile, ":rev", rev); |
| 1053 | db_bind_int(&insFile, ":rid", rid); |
| 1054 | db_bind_text(&insFile, ":path", zPath); |
| 1055 | db_bind_text(&insFile, ":perm", zPerm); |
| 1056 | db_step(&insFile); |
| 1057 | db_reset(&insFile); |
| 1058 | } |
| 1059 | }else |
| 1060 | if( strncmp(zAction, "change", 6)==0 ){ |
| 1061 | rid = content_put(&rec.content); |
| 1062 | db_bind_int(&insFile, ":rev", rev); |
| 1063 | db_bind_int(&insFile, ":rid", rid); |
| 1064 | db_bind_text(&insFile, ":path", zPath); |
| 1065 | db_bind_text(&insFile, ":perm", zPerm); |
| 1066 | db_step(&insFile); |
| 1067 | db_reset(&insFile); |
| 1068 | }else |
| 1069 | if( strncmp(zAction, "delete", 6)==0){ /* already did this above */ |
| 1070 | }else{ |
| 1071 | fossil_fatal("Unknown Node-action"); |
| 1072 | } |
| 1073 | }else{ |
| 1074 | fossil_fatal("Unknown record type"); |
| 1075 | } |
| 1076 | svn_free_rec(&rec); |
| 1077 |