Fossil SCM

Allow using tags as copy-source Move variables to smaller scope, as per coding style guidelines

baruch 2015-01-11 11:30 svn-import
Commit 997da4f0e45fb25098d35aab1868c8643d8a49a1
1 file changed +89 -86
+89 -86
--- src/import.c
+++ src/import.c
@@ -952,13 +952,13 @@
952952
parentRid = db_int(0, "SELECT trid, max(trev) FROM xrevisions"
953953
" WHERE trev<%d AND tbranch=%d",
954954
gsvn.rev, branchId);
955955
}
956956
if( parentRid>0 ){
957
- const char *zParentUuid = rid_to_uuid(parentRid);
957
+ char *zParentUuid = rid_to_uuid(parentRid);
958958
if( parentRid==mergeRid || mergeRid==0){
959
- const char *zParentBranch =
959
+ char *zParentBranch =
960960
db_text(0, "SELECT tname FROM xbranches WHERE tid="
961961
" (SELECT tbranch FROM xrevisions WHERE trid=%d)",
962962
parentRid
963963
);
964964
blob_appendf(&manifest, "P %s\n", zParentUuid);
@@ -966,22 +966,23 @@
966966
blob_appendf(&manifest, "T *sym-%F *\n", zBranch);
967967
blob_appendf(&manifest, "T +sym-svn-rev-%d *\n", gsvn.rev);
968968
blob_appendf(&manifest, "T -sym-%F *\n", zParentBranch);
969969
fossil_free(zParentBranch);
970970
}else{
971
- const char *zMergeUuid = rid_to_uuid(mergeRid);
971
+ char *zMergeUuid = rid_to_uuid(mergeRid);
972972
blob_appendf(&manifest, "P %s %s\n", zParentUuid, zMergeUuid);
973973
blob_appendf(&manifest, "T +sym-svn-rev-%d *\n", gsvn.rev);
974
+ fossil_free(zMergeUuid);
974975
}
975976
fossil_free(zParentUuid);
976977
}else{
977978
blob_appendf(&manifest, "T *branch * %F\n", zBranch);
978979
blob_appendf(&manifest, "T *sym-%F *\n", zBranch);
979980
blob_appendf(&manifest, "T +sym-svn-rev-%d *\n", gsvn.rev);
980981
}
981982
}else{
982
- const char *zParentUuid = rid_to_uuid(parentRid);
983
+ char *zParentUuid = rid_to_uuid(parentRid);
983984
blob_appendf(&manifest, "D %s\n", gsvn.zDate);
984985
blob_appendf(&manifest, "T +sym-%F %s\n", zBranch, zParentUuid);
985986
fossil_free(zParentUuid);
986987
}
987988
if( gsvn.zUser ){
@@ -1056,61 +1057,55 @@
10561057
zDiff += lenData;
10571058
}
10581059
}
10591060
10601061
/*
1061
-** Extract the name of the branch or tag that the given path is on.
1062
-** Returns: 1 - It is on the trunk
1063
-** 2 - It is on a branch
1064
-** 3 - It is a tag
1065
-** 0 - It is none of the above
1066
- */
1067
-static int svn_parse_path(char *zPath, char **zFile){
1068
- int type = 0;
1069
- char *zBranch = 0;
1070
- int branchId = 0;
1071
- *zFile = 0;
1072
- if( gsvn.lenTrunk==0 ){
1073
- zBranch = "trunk";
1074
- *zFile = zPath;
1075
- type = 1;
1076
- }else
1077
- if( strncmp(zPath, gsvn.zTrunk, gsvn.lenTrunk-1)==0 ){
1078
- if( zPath[gsvn.lenTrunk-1]=='/' || zPath[gsvn.lenTrunk-1]==0 ){
1079
- zBranch = "trunk";
1080
- *zFile = zPath+gsvn.lenTrunk;
1081
- type = 1;
1082
- }else{
1083
- zBranch = 0;
1084
- type = 0;
1085
- }
1086
- }else
1087
- if( strncmp(zPath, gsvn.zBranches, gsvn.lenBranches)==0 ){
1088
- *zFile = zBranch = zPath+gsvn.lenBranches;
1089
- while( **zFile && **zFile!='/' ){ (*zFile)++; }
1090
- if( **zFile ){
1091
- **zFile = '\0';
1092
- (*zFile)++;
1093
- }
1094
- type = 2;
1095
- }else
1096
- if( strncmp(zPath, gsvn.zTags, gsvn.lenTags)==0 ){
1097
- *zFile = zBranch = zPath+gsvn.lenTags;
1098
- while( **zFile && **zFile!='/' ){ (*zFile)++; }
1099
- if( **zFile ){
1100
- **zFile = '\0';
1101
- (*zFile)++;
1102
- }
1103
- type = 3;
1104
- }
1105
- if( type>0 ){
1106
- branchId = db_int(0,
1107
- "SELECT tid FROM xbranches WHERE tname=%Q AND ttype=%d",
1108
- zBranch, type);
1109
- if( branchId==0 ){
1110
- db_multi_exec("INSERT INTO xbranches (tname, ttype) VALUES(%Q, %d)",
1111
- zBranch, type);
1062
+** Extract the branch or tag that the given path is on. Return the branch ID.
1063
+ */
1064
+static int svn_parse_path(char *zPath, char **zFile, int *type){
1065
+ char *zBranch = 0;
1066
+ int branchId = 0;
1067
+ *type = 0;
1068
+ *zFile = 0;
1069
+ if( gsvn.lenTrunk==0 ){
1070
+ zBranch = "trunk";
1071
+ *zFile = zPath;
1072
+ *type = 1;
1073
+ }else
1074
+ if( strncmp(zPath, gsvn.zTrunk, gsvn.lenTrunk-1)==0 ){
1075
+ if( zPath[gsvn.lenTrunk-1]=='/' || zPath[gsvn.lenTrunk-1]==0 ){
1076
+ zBranch = "trunk";
1077
+ *zFile = zPath+gsvn.lenTrunk;
1078
+ *type = 1;
1079
+ }else{
1080
+ zBranch = 0;
1081
+ *type = 0;
1082
+ }
1083
+ }else{
1084
+ if( strncmp(zPath, gsvn.zBranches, gsvn.lenBranches)==0 ){
1085
+ *zFile = zBranch = zPath+gsvn.lenBranches;
1086
+ *type = 2;
1087
+ }else
1088
+ if( strncmp(zPath, gsvn.zTags, gsvn.lenTags)==0 ){
1089
+ *zFile = zBranch = zPath+gsvn.lenTags;
1090
+ *type = 3;
1091
+ }else{ /* Not a branch, tag or trunk */
1092
+ return 0;
1093
+ }
1094
+ while( **zFile && **zFile!='/' ){ (*zFile)++; }
1095
+ if( **zFile ){
1096
+ **zFile = '\0';
1097
+ (*zFile)++;
1098
+ }
1099
+ }
1100
+ if( *type>0 ){
1101
+ branchId = db_int(0,
1102
+ "SELECT tid FROM xbranches WHERE tname=%Q AND ttype=%d",
1103
+ zBranch, *type);
1104
+ if( branchId==0 ){
1105
+ db_multi_exec("INSERT INTO xbranches (tname, ttype) VALUES(%Q, %d)",
1106
+ zBranch, *type);
11121107
branchId = db_last_insert_rowid();
11131108
}
11141109
}
11151110
return branchId;
11161111
}
@@ -1142,11 +1137,12 @@
11421137
fossil_fatal("Input is not an svn-dump!");
11431138
}
11441139
svn_free_rec(&rec);
11451140
/* UUID */
11461141
if( !svn_read_rec(pIn, &rec) || !(zUuid = svn_find_header(rec, "UUID")) ){
1147
- fossil_fatal("Missing UUID!");
1142
+ /* Removed the following line since UUID is not actually used
1143
+ fossil_fatal("Missing UUID!"); */
11481144
}
11491145
svn_free_rec(&rec);
11501146
11511147
/* content */
11521148
db_prepare(&addFile,
@@ -1204,39 +1200,25 @@
12041200
}
12051201
db_bind_int(&addRev, ":rev", gsvn.rev);
12061202
fossil_print("\rImporting SVN revision: %d", gsvn.rev);
12071203
}else
12081204
if( (zTemp = svn_find_header(rec, "Node-path")) ){ /* file/dir node */
1205
+ char *zFile;
1206
+ int branchType;
1207
+ int branchId = svn_parse_path(zTemp, &zFile, &branchType);
12091208
char *zAction = svn_find_header(rec, "Node-action");
12101209
char *zKind = svn_find_header(rec, "Node-kind");
1211
- char *zSrcPath = svn_find_header(rec, "Node-copyfrom-path");
12121210
char *zPerm = svn_find_prop(rec, "svn:executable") ? "x" : 0;
1213
- char *zFile;
1214
- int srcBranch;
1215
- char *zSrcFile;
12161211
int deltaFlag = 0;
12171212
int srcRev = 0;
1218
- int branchId = svn_parse_path(zTemp, &zFile);
12191213
if( branchId==0 ){
12201214
svn_free_rec(&rec);
12211215
continue;
12221216
}
12231217
if( (zTemp = svn_find_header(rec, "Text-delta")) ){
12241218
deltaFlag = strncmp(zTemp, "true", 4)==0;
12251219
}
1226
- if( zSrcPath ){
1227
- zTemp = svn_find_header(rec, "Node-copyfrom-rev");
1228
- if( zTemp ){
1229
- srcRev = atoi(zTemp);
1230
- }else{
1231
- fossil_fatal("Missing copyfrom-rev");
1232
- }
1233
- srcBranch = svn_parse_path(zSrcPath, &zSrcFile);
1234
- if( srcBranch==0 ){
1235
- fossil_fatal("Copy from path outside the import paths");
1236
- }
1237
- }
12381220
if( zFile[0]==0 ){
12391221
bag_insert(&gsvn.newBranches, branchId);
12401222
}
12411223
if( strncmp(zAction, "delete", 6)==0
12421224
|| strncmp(zAction, "replace", 7)==0 )
@@ -1251,18 +1233,49 @@
12511233
db_reset(&addRev);
12521234
} /* no 'else' here since 'replace' does both a 'delete' and an 'add' */
12531235
if( strncmp(zAction, "add", 3)==0
12541236
|| strncmp(zAction, "replace", 7)==0 )
12551237
{
1238
+ char *zSrcPath = svn_find_header(rec, "Node-copyfrom-path");
1239
+ char *zSrcFile;
12561240
int srcRid = 0;
1241
+ if( zSrcPath ){
1242
+ int srcBranch;
1243
+ zTemp = svn_find_header(rec, "Node-copyfrom-rev");
1244
+ if( zTemp ){
1245
+ srcRev = atoi(zTemp);
1246
+ }else{
1247
+ fossil_fatal("Missing copyfrom-rev");
1248
+ }
1249
+ srcBranch = svn_parse_path(zSrcPath, &zSrcFile, &branchType);
1250
+ if( srcBranch==0 ){
1251
+ fossil_fatal("Copy from path outside the import paths");
1252
+ }
1253
+ if( branchType!=3 ){
1254
+ srcRid = db_int(0, "SELECT trid, max(trev) FROM xrevisions"
1255
+ " WHERE trev<=%d AND tbranch=%d",
1256
+ srcRev, srcBranch);
1257
+ }else{
1258
+ srcRid = db_int(0, "SELECT tparent, max(trev) FROM xrevisions"
1259
+ " WHERE trev<=%d AND tbranch=%d",
1260
+ srcRev, srcBranch);
1261
+ }
1262
+ if( srcRid>0 && srcBranch!=branchId ){
1263
+ db_bind_int(&addRev, ":branch", branchId);
1264
+ db_step(&addRev);
1265
+ db_reset(&addRev);
1266
+ db_bind_int(&revSrc, ":parent", srcRid);
1267
+ db_bind_int(&revSrc, ":rev", gsvn.rev);
1268
+ db_bind_int(&revSrc, ":branch", branchId);
1269
+ db_step(&revSrc);
1270
+ db_reset(&revSrc);
1271
+ }
1272
+ }
12571273
if( zKind==0 ){
12581274
fossil_fatal("Missing Node-kind");
12591275
}else if( strncmp(zKind, "dir", 3)==0 ){
12601276
if( zSrcPath ){
1261
- srcRid = db_int(0, "SELECT trid, max(trev) FROM xrevisions"
1262
- " WHERE trev<=%d AND tbranch=%d",
1263
- srcRev, srcBranch);
12641277
if( srcRid>0 ){
12651278
if( zFile[0]==0 ){
12661279
db_bind_text(&cpyRoot, ":path", zFile);
12671280
db_bind_int(&cpyRoot, ":branch", branchId);
12681281
db_bind_int(&cpyRoot, ":rid", srcRid);
@@ -1282,13 +1295,10 @@
12821295
}
12831296
}
12841297
}else{
12851298
int rid = 0;
12861299
if( zSrcPath ){
1287
- srcRid = db_int(0, "SELECT trid, max(trev) FROM xrevisions"
1288
- " WHERE trev<=%d AND tbranch=%d",
1289
- srcRev, srcBranch);
12901300
rid = db_int(0, "SELECT rid FROM blob WHERE uuid=("
12911301
" SELECT uuid FROM xfoci"
12921302
" WHERE checkinID=%d AND filename=%Q"
12931303
")",
12941304
srcRid, zSrcFile);
@@ -1314,17 +1324,10 @@
13141324
db_reset(&addFile);
13151325
db_bind_int(&addRev, ":branch", branchId);
13161326
db_step(&addRev);
13171327
db_reset(&addRev);
13181328
}
1319
- if( zSrcPath && srcRid>0 && srcBranch!=branchId ){
1320
- db_bind_int(&revSrc, ":parent", srcRid);
1321
- db_bind_int(&revSrc, ":rev", gsvn.rev);
1322
- db_bind_int(&revSrc, ":branch", branchId);
1323
- db_step(&revSrc);
1324
- db_reset(&revSrc);
1325
- }
13261329
}else
13271330
if( strncmp(zAction, "change", 6)==0 ){
13281331
int rid = 0;
13291332
if( zKind==0 ){
13301333
fossil_fatal("Missing Node-kind");
13311334
--- src/import.c
+++ src/import.c
@@ -952,13 +952,13 @@
952 parentRid = db_int(0, "SELECT trid, max(trev) FROM xrevisions"
953 " WHERE trev<%d AND tbranch=%d",
954 gsvn.rev, branchId);
955 }
956 if( parentRid>0 ){
957 const char *zParentUuid = rid_to_uuid(parentRid);
958 if( parentRid==mergeRid || mergeRid==0){
959 const char *zParentBranch =
960 db_text(0, "SELECT tname FROM xbranches WHERE tid="
961 " (SELECT tbranch FROM xrevisions WHERE trid=%d)",
962 parentRid
963 );
964 blob_appendf(&manifest, "P %s\n", zParentUuid);
@@ -966,22 +966,23 @@
966 blob_appendf(&manifest, "T *sym-%F *\n", zBranch);
967 blob_appendf(&manifest, "T +sym-svn-rev-%d *\n", gsvn.rev);
968 blob_appendf(&manifest, "T -sym-%F *\n", zParentBranch);
969 fossil_free(zParentBranch);
970 }else{
971 const char *zMergeUuid = rid_to_uuid(mergeRid);
972 blob_appendf(&manifest, "P %s %s\n", zParentUuid, zMergeUuid);
973 blob_appendf(&manifest, "T +sym-svn-rev-%d *\n", gsvn.rev);
 
974 }
975 fossil_free(zParentUuid);
976 }else{
977 blob_appendf(&manifest, "T *branch * %F\n", zBranch);
978 blob_appendf(&manifest, "T *sym-%F *\n", zBranch);
979 blob_appendf(&manifest, "T +sym-svn-rev-%d *\n", gsvn.rev);
980 }
981 }else{
982 const char *zParentUuid = rid_to_uuid(parentRid);
983 blob_appendf(&manifest, "D %s\n", gsvn.zDate);
984 blob_appendf(&manifest, "T +sym-%F %s\n", zBranch, zParentUuid);
985 fossil_free(zParentUuid);
986 }
987 if( gsvn.zUser ){
@@ -1056,61 +1057,55 @@
1056 zDiff += lenData;
1057 }
1058 }
1059
1060 /*
1061 ** Extract the name of the branch or tag that the given path is on.
1062 ** Returns: 1 - It is on the trunk
1063 ** 2 - It is on a branch
1064 ** 3 - It is a tag
1065 ** 0 - It is none of the above
1066 */
1067 static int svn_parse_path(char *zPath, char **zFile){
1068 int type = 0;
1069 char *zBranch = 0;
1070 int branchId = 0;
1071 *zFile = 0;
1072 if( gsvn.lenTrunk==0 ){
1073 zBranch = "trunk";
1074 *zFile = zPath;
1075 type = 1;
1076 }else
1077 if( strncmp(zPath, gsvn.zTrunk, gsvn.lenTrunk-1)==0 ){
1078 if( zPath[gsvn.lenTrunk-1]=='/' || zPath[gsvn.lenTrunk-1]==0 ){
1079 zBranch = "trunk";
1080 *zFile = zPath+gsvn.lenTrunk;
1081 type = 1;
1082 }else{
1083 zBranch = 0;
1084 type = 0;
1085 }
1086 }else
1087 if( strncmp(zPath, gsvn.zBranches, gsvn.lenBranches)==0 ){
1088 *zFile = zBranch = zPath+gsvn.lenBranches;
1089 while( **zFile && **zFile!='/' ){ (*zFile)++; }
1090 if( **zFile ){
1091 **zFile = '\0';
1092 (*zFile)++;
1093 }
1094 type = 2;
1095 }else
1096 if( strncmp(zPath, gsvn.zTags, gsvn.lenTags)==0 ){
1097 *zFile = zBranch = zPath+gsvn.lenTags;
1098 while( **zFile && **zFile!='/' ){ (*zFile)++; }
1099 if( **zFile ){
1100 **zFile = '\0';
1101 (*zFile)++;
1102 }
1103 type = 3;
1104 }
1105 if( type>0 ){
1106 branchId = db_int(0,
1107 "SELECT tid FROM xbranches WHERE tname=%Q AND ttype=%d",
1108 zBranch, type);
1109 if( branchId==0 ){
1110 db_multi_exec("INSERT INTO xbranches (tname, ttype) VALUES(%Q, %d)",
1111 zBranch, type);
1112 branchId = db_last_insert_rowid();
1113 }
1114 }
1115 return branchId;
1116 }
@@ -1142,11 +1137,12 @@
1142 fossil_fatal("Input is not an svn-dump!");
1143 }
1144 svn_free_rec(&rec);
1145 /* UUID */
1146 if( !svn_read_rec(pIn, &rec) || !(zUuid = svn_find_header(rec, "UUID")) ){
1147 fossil_fatal("Missing UUID!");
 
1148 }
1149 svn_free_rec(&rec);
1150
1151 /* content */
1152 db_prepare(&addFile,
@@ -1204,39 +1200,25 @@
1204 }
1205 db_bind_int(&addRev, ":rev", gsvn.rev);
1206 fossil_print("\rImporting SVN revision: %d", gsvn.rev);
1207 }else
1208 if( (zTemp = svn_find_header(rec, "Node-path")) ){ /* file/dir node */
 
 
 
1209 char *zAction = svn_find_header(rec, "Node-action");
1210 char *zKind = svn_find_header(rec, "Node-kind");
1211 char *zSrcPath = svn_find_header(rec, "Node-copyfrom-path");
1212 char *zPerm = svn_find_prop(rec, "svn:executable") ? "x" : 0;
1213 char *zFile;
1214 int srcBranch;
1215 char *zSrcFile;
1216 int deltaFlag = 0;
1217 int srcRev = 0;
1218 int branchId = svn_parse_path(zTemp, &zFile);
1219 if( branchId==0 ){
1220 svn_free_rec(&rec);
1221 continue;
1222 }
1223 if( (zTemp = svn_find_header(rec, "Text-delta")) ){
1224 deltaFlag = strncmp(zTemp, "true", 4)==0;
1225 }
1226 if( zSrcPath ){
1227 zTemp = svn_find_header(rec, "Node-copyfrom-rev");
1228 if( zTemp ){
1229 srcRev = atoi(zTemp);
1230 }else{
1231 fossil_fatal("Missing copyfrom-rev");
1232 }
1233 srcBranch = svn_parse_path(zSrcPath, &zSrcFile);
1234 if( srcBranch==0 ){
1235 fossil_fatal("Copy from path outside the import paths");
1236 }
1237 }
1238 if( zFile[0]==0 ){
1239 bag_insert(&gsvn.newBranches, branchId);
1240 }
1241 if( strncmp(zAction, "delete", 6)==0
1242 || strncmp(zAction, "replace", 7)==0 )
@@ -1251,18 +1233,49 @@
1251 db_reset(&addRev);
1252 } /* no 'else' here since 'replace' does both a 'delete' and an 'add' */
1253 if( strncmp(zAction, "add", 3)==0
1254 || strncmp(zAction, "replace", 7)==0 )
1255 {
 
 
1256 int srcRid = 0;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1257 if( zKind==0 ){
1258 fossil_fatal("Missing Node-kind");
1259 }else if( strncmp(zKind, "dir", 3)==0 ){
1260 if( zSrcPath ){
1261 srcRid = db_int(0, "SELECT trid, max(trev) FROM xrevisions"
1262 " WHERE trev<=%d AND tbranch=%d",
1263 srcRev, srcBranch);
1264 if( srcRid>0 ){
1265 if( zFile[0]==0 ){
1266 db_bind_text(&cpyRoot, ":path", zFile);
1267 db_bind_int(&cpyRoot, ":branch", branchId);
1268 db_bind_int(&cpyRoot, ":rid", srcRid);
@@ -1282,13 +1295,10 @@
1282 }
1283 }
1284 }else{
1285 int rid = 0;
1286 if( zSrcPath ){
1287 srcRid = db_int(0, "SELECT trid, max(trev) FROM xrevisions"
1288 " WHERE trev<=%d AND tbranch=%d",
1289 srcRev, srcBranch);
1290 rid = db_int(0, "SELECT rid FROM blob WHERE uuid=("
1291 " SELECT uuid FROM xfoci"
1292 " WHERE checkinID=%d AND filename=%Q"
1293 ")",
1294 srcRid, zSrcFile);
@@ -1314,17 +1324,10 @@
1314 db_reset(&addFile);
1315 db_bind_int(&addRev, ":branch", branchId);
1316 db_step(&addRev);
1317 db_reset(&addRev);
1318 }
1319 if( zSrcPath && srcRid>0 && srcBranch!=branchId ){
1320 db_bind_int(&revSrc, ":parent", srcRid);
1321 db_bind_int(&revSrc, ":rev", gsvn.rev);
1322 db_bind_int(&revSrc, ":branch", branchId);
1323 db_step(&revSrc);
1324 db_reset(&revSrc);
1325 }
1326 }else
1327 if( strncmp(zAction, "change", 6)==0 ){
1328 int rid = 0;
1329 if( zKind==0 ){
1330 fossil_fatal("Missing Node-kind");
1331
--- src/import.c
+++ src/import.c
@@ -952,13 +952,13 @@
952 parentRid = db_int(0, "SELECT trid, max(trev) FROM xrevisions"
953 " WHERE trev<%d AND tbranch=%d",
954 gsvn.rev, branchId);
955 }
956 if( parentRid>0 ){
957 char *zParentUuid = rid_to_uuid(parentRid);
958 if( parentRid==mergeRid || mergeRid==0){
959 char *zParentBranch =
960 db_text(0, "SELECT tname FROM xbranches WHERE tid="
961 " (SELECT tbranch FROM xrevisions WHERE trid=%d)",
962 parentRid
963 );
964 blob_appendf(&manifest, "P %s\n", zParentUuid);
@@ -966,22 +966,23 @@
966 blob_appendf(&manifest, "T *sym-%F *\n", zBranch);
967 blob_appendf(&manifest, "T +sym-svn-rev-%d *\n", gsvn.rev);
968 blob_appendf(&manifest, "T -sym-%F *\n", zParentBranch);
969 fossil_free(zParentBranch);
970 }else{
971 char *zMergeUuid = rid_to_uuid(mergeRid);
972 blob_appendf(&manifest, "P %s %s\n", zParentUuid, zMergeUuid);
973 blob_appendf(&manifest, "T +sym-svn-rev-%d *\n", gsvn.rev);
974 fossil_free(zMergeUuid);
975 }
976 fossil_free(zParentUuid);
977 }else{
978 blob_appendf(&manifest, "T *branch * %F\n", zBranch);
979 blob_appendf(&manifest, "T *sym-%F *\n", zBranch);
980 blob_appendf(&manifest, "T +sym-svn-rev-%d *\n", gsvn.rev);
981 }
982 }else{
983 char *zParentUuid = rid_to_uuid(parentRid);
984 blob_appendf(&manifest, "D %s\n", gsvn.zDate);
985 blob_appendf(&manifest, "T +sym-%F %s\n", zBranch, zParentUuid);
986 fossil_free(zParentUuid);
987 }
988 if( gsvn.zUser ){
@@ -1056,61 +1057,55 @@
1057 zDiff += lenData;
1058 }
1059 }
1060
1061 /*
1062 ** Extract the branch or tag that the given path is on. Return the branch ID.
1063 */
1064 static int svn_parse_path(char *zPath, char **zFile, int *type){
1065 char *zBranch = 0;
1066 int branchId = 0;
1067 *type = 0;
1068 *zFile = 0;
1069 if( gsvn.lenTrunk==0 ){
1070 zBranch = "trunk";
1071 *zFile = zPath;
1072 *type = 1;
1073 }else
1074 if( strncmp(zPath, gsvn.zTrunk, gsvn.lenTrunk-1)==0 ){
1075 if( zPath[gsvn.lenTrunk-1]=='/' || zPath[gsvn.lenTrunk-1]==0 ){
1076 zBranch = "trunk";
1077 *zFile = zPath+gsvn.lenTrunk;
1078 *type = 1;
1079 }else{
1080 zBranch = 0;
1081 *type = 0;
1082 }
1083 }else{
1084 if( strncmp(zPath, gsvn.zBranches, gsvn.lenBranches)==0 ){
1085 *zFile = zBranch = zPath+gsvn.lenBranches;
1086 *type = 2;
1087 }else
1088 if( strncmp(zPath, gsvn.zTags, gsvn.lenTags)==0 ){
1089 *zFile = zBranch = zPath+gsvn.lenTags;
1090 *type = 3;
1091 }else{ /* Not a branch, tag or trunk */
1092 return 0;
1093 }
1094 while( **zFile && **zFile!='/' ){ (*zFile)++; }
1095 if( **zFile ){
1096 **zFile = '\0';
1097 (*zFile)++;
1098 }
1099 }
1100 if( *type>0 ){
1101 branchId = db_int(0,
1102 "SELECT tid FROM xbranches WHERE tname=%Q AND ttype=%d",
1103 zBranch, *type);
1104 if( branchId==0 ){
1105 db_multi_exec("INSERT INTO xbranches (tname, ttype) VALUES(%Q, %d)",
1106 zBranch, *type);
 
 
 
 
 
 
1107 branchId = db_last_insert_rowid();
1108 }
1109 }
1110 return branchId;
1111 }
@@ -1142,11 +1137,12 @@
1137 fossil_fatal("Input is not an svn-dump!");
1138 }
1139 svn_free_rec(&rec);
1140 /* UUID */
1141 if( !svn_read_rec(pIn, &rec) || !(zUuid = svn_find_header(rec, "UUID")) ){
1142 /* Removed the following line since UUID is not actually used
1143 fossil_fatal("Missing UUID!"); */
1144 }
1145 svn_free_rec(&rec);
1146
1147 /* content */
1148 db_prepare(&addFile,
@@ -1204,39 +1200,25 @@
1200 }
1201 db_bind_int(&addRev, ":rev", gsvn.rev);
1202 fossil_print("\rImporting SVN revision: %d", gsvn.rev);
1203 }else
1204 if( (zTemp = svn_find_header(rec, "Node-path")) ){ /* file/dir node */
1205 char *zFile;
1206 int branchType;
1207 int branchId = svn_parse_path(zTemp, &zFile, &branchType);
1208 char *zAction = svn_find_header(rec, "Node-action");
1209 char *zKind = svn_find_header(rec, "Node-kind");
 
1210 char *zPerm = svn_find_prop(rec, "svn:executable") ? "x" : 0;
 
 
 
1211 int deltaFlag = 0;
1212 int srcRev = 0;
 
1213 if( branchId==0 ){
1214 svn_free_rec(&rec);
1215 continue;
1216 }
1217 if( (zTemp = svn_find_header(rec, "Text-delta")) ){
1218 deltaFlag = strncmp(zTemp, "true", 4)==0;
1219 }
 
 
 
 
 
 
 
 
 
 
 
 
1220 if( zFile[0]==0 ){
1221 bag_insert(&gsvn.newBranches, branchId);
1222 }
1223 if( strncmp(zAction, "delete", 6)==0
1224 || strncmp(zAction, "replace", 7)==0 )
@@ -1251,18 +1233,49 @@
1233 db_reset(&addRev);
1234 } /* no 'else' here since 'replace' does both a 'delete' and an 'add' */
1235 if( strncmp(zAction, "add", 3)==0
1236 || strncmp(zAction, "replace", 7)==0 )
1237 {
1238 char *zSrcPath = svn_find_header(rec, "Node-copyfrom-path");
1239 char *zSrcFile;
1240 int srcRid = 0;
1241 if( zSrcPath ){
1242 int srcBranch;
1243 zTemp = svn_find_header(rec, "Node-copyfrom-rev");
1244 if( zTemp ){
1245 srcRev = atoi(zTemp);
1246 }else{
1247 fossil_fatal("Missing copyfrom-rev");
1248 }
1249 srcBranch = svn_parse_path(zSrcPath, &zSrcFile, &branchType);
1250 if( srcBranch==0 ){
1251 fossil_fatal("Copy from path outside the import paths");
1252 }
1253 if( branchType!=3 ){
1254 srcRid = db_int(0, "SELECT trid, max(trev) FROM xrevisions"
1255 " WHERE trev<=%d AND tbranch=%d",
1256 srcRev, srcBranch);
1257 }else{
1258 srcRid = db_int(0, "SELECT tparent, max(trev) FROM xrevisions"
1259 " WHERE trev<=%d AND tbranch=%d",
1260 srcRev, srcBranch);
1261 }
1262 if( srcRid>0 && srcBranch!=branchId ){
1263 db_bind_int(&addRev, ":branch", branchId);
1264 db_step(&addRev);
1265 db_reset(&addRev);
1266 db_bind_int(&revSrc, ":parent", srcRid);
1267 db_bind_int(&revSrc, ":rev", gsvn.rev);
1268 db_bind_int(&revSrc, ":branch", branchId);
1269 db_step(&revSrc);
1270 db_reset(&revSrc);
1271 }
1272 }
1273 if( zKind==0 ){
1274 fossil_fatal("Missing Node-kind");
1275 }else if( strncmp(zKind, "dir", 3)==0 ){
1276 if( zSrcPath ){
 
 
 
1277 if( srcRid>0 ){
1278 if( zFile[0]==0 ){
1279 db_bind_text(&cpyRoot, ":path", zFile);
1280 db_bind_int(&cpyRoot, ":branch", branchId);
1281 db_bind_int(&cpyRoot, ":rid", srcRid);
@@ -1282,13 +1295,10 @@
1295 }
1296 }
1297 }else{
1298 int rid = 0;
1299 if( zSrcPath ){
 
 
 
1300 rid = db_int(0, "SELECT rid FROM blob WHERE uuid=("
1301 " SELECT uuid FROM xfoci"
1302 " WHERE checkinID=%d AND filename=%Q"
1303 ")",
1304 srcRid, zSrcFile);
@@ -1314,17 +1324,10 @@
1324 db_reset(&addFile);
1325 db_bind_int(&addRev, ":branch", branchId);
1326 db_step(&addRev);
1327 db_reset(&addRev);
1328 }
 
 
 
 
 
 
 
1329 }else
1330 if( strncmp(zAction, "change", 6)==0 ){
1331 int rid = 0;
1332 if( zKind==0 ){
1333 fossil_fatal("Missing Node-kind");
1334

Keyboard Shortcuts

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