Fossil SCM

Can now import full dump. Still only flat and only format 2

baruch 2014-10-22 11:53 svn-import
Commit 8d2e67512d585183f3cf3386aa4b7b5efe20ae48
1 file changed +43 -25
+43 -25
--- src/import.c
+++ src/import.c
@@ -977,11 +977,12 @@
977977
"INSERT INTO xfiles (trev, tpath, trid, tperm) "
978978
"VALUES(:rev, :path, :rid, :perm)"
979979
);
980980
db_prepare(&delFile,
981981
"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'))"
983984
);
984985
while( svn_read_rec(pIn, &rec) ){
985986
if( zTemp = svn_find_header(rec, "Revision-number") ){
986987
const char *zUser = svn_find_prop(rec, "svn:author");
987988
const char *zLog = svn_find_prop(rec, "svn:log");
@@ -1007,52 +1008,69 @@
10071008
const char *zKind = svn_find_header(rec, "Node-kind");
10081009
const char *zSrcPath = svn_find_header(rec, "Node-copyfrom-path");
10091010
const char *zPerm = svn_find_prop(rec, "svn:executable") ? "x" : 0;
10101011
int srcRev = -1;
10111012
int rid = 0;
1012
- if( zKind && strncmp(zKind, "dir", 3)==0 ){
1013
- svn_free_rec(&rec);
1014
- continue;
1015
- }
10161013
if( zSrcPath ){
10171014
zTemp = svn_find_header(rec, "Node-copyfrom-rev");
10181015
if( zTemp ){
10191016
srcRev = atoi(zTemp);
10201017
}else{
10211018
fossil_fatal("Missing copyfrom-rev");
10221019
}
10231020
}
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
+ }
10371059
}else
10381060
if( strncmp(zAction, "change", 6)==0 ){
1061
+ rid = content_put(&rec.content);
10391062
db_bind_int(&insFile, ":rev", rev);
10401063
db_bind_int(&insFile, ":rid", rid);
10411064
db_bind_text(&insFile, ":path", zPath);
10421065
db_bind_text(&insFile, ":perm", zPerm);
10431066
db_step(&insFile);
10441067
db_reset(&insFile);
10451068
}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 */
10531070
}else{
1071
+ fossil_fatal("Unknown Node-action");
10541072
}
10551073
}else{
10561074
fossil_fatal("Unknown record type");
10571075
}
10581076
svn_free_rec(&rec);
10591077
--- 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

Keyboard Shortcuts

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