Fossil SCM

Fix issue with branching from a branch

baruch 2015-01-11 08:02 svn-import
Commit 93134dda26e295ac6ec1e56c9024c82b9fd71b92
1 file changed +29 -18
+29 -18
--- src/import.c
+++ src/import.c
@@ -1073,40 +1073,34 @@
10731073
zBranch = "trunk";
10741074
*zFile = zPath;
10751075
type = 1;
10761076
}else
10771077
if( strncmp(zPath, gsvn.zTrunk, gsvn.lenTrunk-1)==0 ){
1078
- zBranch = "trunk";
1079
- if( zPath[gsvn.lenTrunk-1]=='/' ){
1080
- *zFile = zPath+gsvn.lenTrunk;;
1081
- }else if( zPath[gsvn.lenTrunk-1]==0 ){
1082
- *zFile = 0;
1078
+ if( zPath[gsvn.lenTrunk-1]=='/' || zPath[gsvn.lenTrunk-1]==0 ){
1079
+ zBranch = "trunk";
1080
+ *zFile = zPath+gsvn.lenTrunk;
1081
+ type = 1;
10831082
}else{
1084
- *zFile = zBranch = 0;
1083
+ zBranch = 0;
10851084
type = 0;
10861085
}
1087
- type = 1;
10881086
}else
10891087
if( strncmp(zPath, gsvn.zBranches, gsvn.lenBranches)==0 ){
10901088
*zFile = zBranch = zPath+gsvn.lenBranches;
10911089
while( **zFile && **zFile!='/' ){ (*zFile)++; }
10921090
if( **zFile ){
10931091
**zFile = '\0';
10941092
(*zFile)++;
1095
- }else{
1096
- *zFile = 0;
10971093
}
10981094
type = 2;
10991095
}else
11001096
if( strncmp(zPath, gsvn.zTags, gsvn.lenTags)==0 ){
11011097
*zFile = zBranch = zPath+gsvn.lenTags;
11021098
while( **zFile && **zFile!='/' ){ (*zFile)++; }
11031099
if( **zFile ){
11041100
**zFile = '\0';
11051101
(*zFile)++;
1106
- }else{
1107
- *zFile = 0;
11081102
}
11091103
type = 3;
11101104
}
11111105
if( type>0 ){
11121106
branchId = db_int(0,
@@ -1132,10 +1126,11 @@
11321126
const char *zUuid;
11331127
Stmt addFile;
11341128
Stmt delPath;
11351129
Stmt addRev;
11361130
Stmt cpyPath;
1131
+ Stmt cpyRoot;
11371132
Stmt revSrc;
11381133
11391134
/* version */
11401135
if( svn_read_rec(pIn, &rec)
11411136
&& (zTemp = svn_find_header(rec, "SVN-fs-dump-format-version")) ){
@@ -1172,10 +1167,16 @@
11721167
" FROM xfoci"
11731168
" WHERE checkinID=:rid"
11741169
" AND filename>:srcpath||'/'"
11751170
" AND filename<:srcpath||'0'"
11761171
);
1172
+ db_prepare(&cpyRoot,
1173
+ "INSERT INTO xfiles (tpath, tbranch, tuuid, tperm)"
1174
+ " SELECT :path||filename, :branch, uuid, perm"
1175
+ " FROM xfoci"
1176
+ " WHERE checkinID=:rid"
1177
+ );
11771178
db_prepare(&revSrc,
11781179
"UPDATE xrevisions SET tparent=:parent"
11791180
" WHERE trev=:rev AND tbranch=:branch AND tparent<:parent"
11801181
);
11811182
gsvn.rev = -1;
@@ -1232,16 +1233,17 @@
12321233
srcBranch = svn_parse_path(zSrcPath, &zSrcFile);
12331234
if( srcBranch==0 ){
12341235
fossil_fatal("Copy from path outside the import paths");
12351236
}
12361237
}
1237
- if( zFile==0 ){
1238
+ if( zFile[0]==0 ){
12381239
bag_insert(&gsvn.newBranches, branchId);
12391240
}
12401241
if( strncmp(zAction, "delete", 6)==0
12411242
|| strncmp(zAction, "replace", 7)==0 )
12421243
{
1244
+ //TODO delete root
12431245
db_bind_text(&delPath, ":path", zFile);
12441246
db_bind_int(&delPath, ":branch", branchId);
12451247
db_step(&delPath);
12461248
db_reset(&delPath);
12471249
db_bind_int(&addRev, ":branch", branchId);
@@ -1258,16 +1260,24 @@
12581260
if( zSrcPath ){
12591261
srcRid = db_int(0, "SELECT trid, max(trev) FROM xrevisions"
12601262
" WHERE trev<=%d AND tbranch=%d",
12611263
srcRev, srcBranch);
12621264
if( srcRid>0 ){
1263
- db_bind_text(&cpyPath, ":path", zFile);
1264
- db_bind_int(&cpyPath, ":branch", branchId);
1265
- db_bind_text(&cpyPath, ":srcpath", zSrcFile);
1266
- db_bind_int(&cpyPath, ":rid", srcRid);
1267
- db_step(&cpyPath);
1268
- db_reset(&cpyPath);
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);
1269
+ db_step(&cpyRoot);
1270
+ db_reset(&cpyRoot);
1271
+ }else{
1272
+ db_bind_text(&cpyPath, ":path", zFile);
1273
+ db_bind_int(&cpyPath, ":branch", branchId);
1274
+ db_bind_text(&cpyPath, ":srcpath", zSrcFile);
1275
+ db_bind_int(&cpyPath, ":rid", srcRid);
1276
+ db_step(&cpyPath);
1277
+ db_reset(&cpyPath);
1278
+ }
12691279
db_bind_int(&addRev, ":branch", branchId);
12701280
db_step(&addRev);
12711281
db_reset(&addRev);
12721282
}
12731283
}
@@ -1358,10 +1368,11 @@
13581368
fossil_free(gsvn.zDate);
13591369
db_finalize(&addFile);
13601370
db_finalize(&delPath);
13611371
db_finalize(&addRev);
13621372
db_finalize(&cpyPath);
1373
+ db_finalize(&cpyRoot);
13631374
db_finalize(&revSrc);
13641375
fossil_print(" Done!\n");
13651376
}
13661377
13671378
/*
13681379
--- src/import.c
+++ src/import.c
@@ -1073,40 +1073,34 @@
1073 zBranch = "trunk";
1074 *zFile = zPath;
1075 type = 1;
1076 }else
1077 if( strncmp(zPath, gsvn.zTrunk, gsvn.lenTrunk-1)==0 ){
1078 zBranch = "trunk";
1079 if( zPath[gsvn.lenTrunk-1]=='/' ){
1080 *zFile = zPath+gsvn.lenTrunk;;
1081 }else if( zPath[gsvn.lenTrunk-1]==0 ){
1082 *zFile = 0;
1083 }else{
1084 *zFile = zBranch = 0;
1085 type = 0;
1086 }
1087 type = 1;
1088 }else
1089 if( strncmp(zPath, gsvn.zBranches, gsvn.lenBranches)==0 ){
1090 *zFile = zBranch = zPath+gsvn.lenBranches;
1091 while( **zFile && **zFile!='/' ){ (*zFile)++; }
1092 if( **zFile ){
1093 **zFile = '\0';
1094 (*zFile)++;
1095 }else{
1096 *zFile = 0;
1097 }
1098 type = 2;
1099 }else
1100 if( strncmp(zPath, gsvn.zTags, gsvn.lenTags)==0 ){
1101 *zFile = zBranch = zPath+gsvn.lenTags;
1102 while( **zFile && **zFile!='/' ){ (*zFile)++; }
1103 if( **zFile ){
1104 **zFile = '\0';
1105 (*zFile)++;
1106 }else{
1107 *zFile = 0;
1108 }
1109 type = 3;
1110 }
1111 if( type>0 ){
1112 branchId = db_int(0,
@@ -1132,10 +1126,11 @@
1132 const char *zUuid;
1133 Stmt addFile;
1134 Stmt delPath;
1135 Stmt addRev;
1136 Stmt cpyPath;
 
1137 Stmt revSrc;
1138
1139 /* version */
1140 if( svn_read_rec(pIn, &rec)
1141 && (zTemp = svn_find_header(rec, "SVN-fs-dump-format-version")) ){
@@ -1172,10 +1167,16 @@
1172 " FROM xfoci"
1173 " WHERE checkinID=:rid"
1174 " AND filename>:srcpath||'/'"
1175 " AND filename<:srcpath||'0'"
1176 );
 
 
 
 
 
 
1177 db_prepare(&revSrc,
1178 "UPDATE xrevisions SET tparent=:parent"
1179 " WHERE trev=:rev AND tbranch=:branch AND tparent<:parent"
1180 );
1181 gsvn.rev = -1;
@@ -1232,16 +1233,17 @@
1232 srcBranch = svn_parse_path(zSrcPath, &zSrcFile);
1233 if( srcBranch==0 ){
1234 fossil_fatal("Copy from path outside the import paths");
1235 }
1236 }
1237 if( zFile==0 ){
1238 bag_insert(&gsvn.newBranches, branchId);
1239 }
1240 if( strncmp(zAction, "delete", 6)==0
1241 || strncmp(zAction, "replace", 7)==0 )
1242 {
 
1243 db_bind_text(&delPath, ":path", zFile);
1244 db_bind_int(&delPath, ":branch", branchId);
1245 db_step(&delPath);
1246 db_reset(&delPath);
1247 db_bind_int(&addRev, ":branch", branchId);
@@ -1258,16 +1260,24 @@
1258 if( zSrcPath ){
1259 srcRid = db_int(0, "SELECT trid, max(trev) FROM xrevisions"
1260 " WHERE trev<=%d AND tbranch=%d",
1261 srcRev, srcBranch);
1262 if( srcRid>0 ){
1263 db_bind_text(&cpyPath, ":path", zFile);
1264 db_bind_int(&cpyPath, ":branch", branchId);
1265 db_bind_text(&cpyPath, ":srcpath", zSrcFile);
1266 db_bind_int(&cpyPath, ":rid", srcRid);
1267 db_step(&cpyPath);
1268 db_reset(&cpyPath);
 
 
 
 
 
 
 
 
1269 db_bind_int(&addRev, ":branch", branchId);
1270 db_step(&addRev);
1271 db_reset(&addRev);
1272 }
1273 }
@@ -1358,10 +1368,11 @@
1358 fossil_free(gsvn.zDate);
1359 db_finalize(&addFile);
1360 db_finalize(&delPath);
1361 db_finalize(&addRev);
1362 db_finalize(&cpyPath);
 
1363 db_finalize(&revSrc);
1364 fossil_print(" Done!\n");
1365 }
1366
1367 /*
1368
--- src/import.c
+++ src/import.c
@@ -1073,40 +1073,34 @@
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,
@@ -1132,10 +1126,11 @@
1126 const char *zUuid;
1127 Stmt addFile;
1128 Stmt delPath;
1129 Stmt addRev;
1130 Stmt cpyPath;
1131 Stmt cpyRoot;
1132 Stmt revSrc;
1133
1134 /* version */
1135 if( svn_read_rec(pIn, &rec)
1136 && (zTemp = svn_find_header(rec, "SVN-fs-dump-format-version")) ){
@@ -1172,10 +1167,16 @@
1167 " FROM xfoci"
1168 " WHERE checkinID=:rid"
1169 " AND filename>:srcpath||'/'"
1170 " AND filename<:srcpath||'0'"
1171 );
1172 db_prepare(&cpyRoot,
1173 "INSERT INTO xfiles (tpath, tbranch, tuuid, tperm)"
1174 " SELECT :path||filename, :branch, uuid, perm"
1175 " FROM xfoci"
1176 " WHERE checkinID=:rid"
1177 );
1178 db_prepare(&revSrc,
1179 "UPDATE xrevisions SET tparent=:parent"
1180 " WHERE trev=:rev AND tbranch=:branch AND tparent<:parent"
1181 );
1182 gsvn.rev = -1;
@@ -1232,16 +1233,17 @@
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 )
1243 {
1244 //TODO delete root
1245 db_bind_text(&delPath, ":path", zFile);
1246 db_bind_int(&delPath, ":branch", branchId);
1247 db_step(&delPath);
1248 db_reset(&delPath);
1249 db_bind_int(&addRev, ":branch", branchId);
@@ -1258,16 +1260,24 @@
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);
1269 db_step(&cpyRoot);
1270 db_reset(&cpyRoot);
1271 }else{
1272 db_bind_text(&cpyPath, ":path", zFile);
1273 db_bind_int(&cpyPath, ":branch", branchId);
1274 db_bind_text(&cpyPath, ":srcpath", zSrcFile);
1275 db_bind_int(&cpyPath, ":rid", srcRid);
1276 db_step(&cpyPath);
1277 db_reset(&cpyPath);
1278 }
1279 db_bind_int(&addRev, ":branch", branchId);
1280 db_step(&addRev);
1281 db_reset(&addRev);
1282 }
1283 }
@@ -1358,10 +1368,11 @@
1368 fossil_free(gsvn.zDate);
1369 db_finalize(&addFile);
1370 db_finalize(&delPath);
1371 db_finalize(&addRev);
1372 db_finalize(&cpyPath);
1373 db_finalize(&cpyRoot);
1374 db_finalize(&revSrc);
1375 fossil_print(" Done!\n");
1376 }
1377
1378 /*
1379

Keyboard Shortcuts

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