Fossil SCM
Cherrypick 1.31 schema-change.
Commit
73069449f045d30b7964d63ab90b113d037d714b
Parent
6a7f73d16d29938…
11 files changed
+16
-1
+16
-1
+16
-1
+64
-53
+64
-53
+30
-7
+30
-7
+30
-7
+2
-2
+2
-2
+2
-2
M
src/db.c
+16
-1
| --- src/db.c | ||
| +++ src/db.c | ||
| @@ -1170,10 +1170,26 @@ | ||
| 1170 | 1170 | g.zRepositoryName = mprintf("%s", zDbName); |
| 1171 | 1171 | db_open_or_attach(g.zRepositoryName, "repository", 0); |
| 1172 | 1172 | g.repositoryOpen = 1; |
| 1173 | 1173 | /* Cache "allow-symlinks" option, because we'll need it on every stat call */ |
| 1174 | 1174 | g.allowSymlinks = db_get_boolean("allow-symlinks", 0); |
| 1175 | + g.zAuxSchema = db_get("aux-schema",""); | |
| 1176 | + | |
| 1177 | + /* Verify that the MLINK table has the newer columns added by the | |
| 1178 | + ** 2015-01-24 schema change. Create them if necessary. This code | |
| 1179 | + ** can be removed in the future, once all users have upgraded to the | |
| 1180 | + ** 2015-01-24 schema. | |
| 1181 | + */ | |
| 1182 | + if( !db_table_has_column("repository","mlink","isaux") ){ | |
| 1183 | + db_begin_transaction(); | |
| 1184 | + db_multi_exec( | |
| 1185 | + "ALTER TABLE %s.mlink ADD COLUMN pmid INTEGER DEFAULT 0;" | |
| 1186 | + "ALTER TABLE %s.mlink ADD COLUMN isaux INTEGER DEFAULT 0;", | |
| 1187 | + db_name("repository"), db_name("repository") | |
| 1188 | + ); | |
| 1189 | + db_end_transaction(0); | |
| 1190 | + } | |
| 1175 | 1191 | } |
| 1176 | 1192 | |
| 1177 | 1193 | /* |
| 1178 | 1194 | ** Flags for the db_find_and_open_repository() function. |
| 1179 | 1195 | */ |
| @@ -1237,11 +1253,10 @@ | ||
| 1237 | 1253 | |
| 1238 | 1254 | /* |
| 1239 | 1255 | ** Return TRUE if the schema is out-of-date |
| 1240 | 1256 | */ |
| 1241 | 1257 | int db_schema_is_outofdate(void){ |
| 1242 | - if( g.zAuxSchema==0 ) g.zAuxSchema = db_get("aux-schema",""); | |
| 1243 | 1258 | return strcmp(g.zAuxSchema,AUX_SCHEMA_MIN)<0 |
| 1244 | 1259 | || strcmp(g.zAuxSchema,AUX_SCHEMA_MAX)>0; |
| 1245 | 1260 | } |
| 1246 | 1261 | |
| 1247 | 1262 | /* |
| 1248 | 1263 |
| --- src/db.c | |
| +++ src/db.c | |
| @@ -1170,10 +1170,26 @@ | |
| 1170 | g.zRepositoryName = mprintf("%s", zDbName); |
| 1171 | db_open_or_attach(g.zRepositoryName, "repository", 0); |
| 1172 | g.repositoryOpen = 1; |
| 1173 | /* Cache "allow-symlinks" option, because we'll need it on every stat call */ |
| 1174 | g.allowSymlinks = db_get_boolean("allow-symlinks", 0); |
| 1175 | } |
| 1176 | |
| 1177 | /* |
| 1178 | ** Flags for the db_find_and_open_repository() function. |
| 1179 | */ |
| @@ -1237,11 +1253,10 @@ | |
| 1237 | |
| 1238 | /* |
| 1239 | ** Return TRUE if the schema is out-of-date |
| 1240 | */ |
| 1241 | int db_schema_is_outofdate(void){ |
| 1242 | if( g.zAuxSchema==0 ) g.zAuxSchema = db_get("aux-schema",""); |
| 1243 | return strcmp(g.zAuxSchema,AUX_SCHEMA_MIN)<0 |
| 1244 | || strcmp(g.zAuxSchema,AUX_SCHEMA_MAX)>0; |
| 1245 | } |
| 1246 | |
| 1247 | /* |
| 1248 |
| --- src/db.c | |
| +++ src/db.c | |
| @@ -1170,10 +1170,26 @@ | |
| 1170 | g.zRepositoryName = mprintf("%s", zDbName); |
| 1171 | db_open_or_attach(g.zRepositoryName, "repository", 0); |
| 1172 | g.repositoryOpen = 1; |
| 1173 | /* Cache "allow-symlinks" option, because we'll need it on every stat call */ |
| 1174 | g.allowSymlinks = db_get_boolean("allow-symlinks", 0); |
| 1175 | g.zAuxSchema = db_get("aux-schema",""); |
| 1176 | |
| 1177 | /* Verify that the MLINK table has the newer columns added by the |
| 1178 | ** 2015-01-24 schema change. Create them if necessary. This code |
| 1179 | ** can be removed in the future, once all users have upgraded to the |
| 1180 | ** 2015-01-24 schema. |
| 1181 | */ |
| 1182 | if( !db_table_has_column("repository","mlink","isaux") ){ |
| 1183 | db_begin_transaction(); |
| 1184 | db_multi_exec( |
| 1185 | "ALTER TABLE %s.mlink ADD COLUMN pmid INTEGER DEFAULT 0;" |
| 1186 | "ALTER TABLE %s.mlink ADD COLUMN isaux INTEGER DEFAULT 0;", |
| 1187 | db_name("repository"), db_name("repository") |
| 1188 | ); |
| 1189 | db_end_transaction(0); |
| 1190 | } |
| 1191 | } |
| 1192 | |
| 1193 | /* |
| 1194 | ** Flags for the db_find_and_open_repository() function. |
| 1195 | */ |
| @@ -1237,11 +1253,10 @@ | |
| 1253 | |
| 1254 | /* |
| 1255 | ** Return TRUE if the schema is out-of-date |
| 1256 | */ |
| 1257 | int db_schema_is_outofdate(void){ |
| 1258 | return strcmp(g.zAuxSchema,AUX_SCHEMA_MIN)<0 |
| 1259 | || strcmp(g.zAuxSchema,AUX_SCHEMA_MAX)>0; |
| 1260 | } |
| 1261 | |
| 1262 | /* |
| 1263 |
M
src/db.c
+16
-1
| --- src/db.c | ||
| +++ src/db.c | ||
| @@ -1170,10 +1170,26 @@ | ||
| 1170 | 1170 | g.zRepositoryName = mprintf("%s", zDbName); |
| 1171 | 1171 | db_open_or_attach(g.zRepositoryName, "repository", 0); |
| 1172 | 1172 | g.repositoryOpen = 1; |
| 1173 | 1173 | /* Cache "allow-symlinks" option, because we'll need it on every stat call */ |
| 1174 | 1174 | g.allowSymlinks = db_get_boolean("allow-symlinks", 0); |
| 1175 | + g.zAuxSchema = db_get("aux-schema",""); | |
| 1176 | + | |
| 1177 | + /* Verify that the MLINK table has the newer columns added by the | |
| 1178 | + ** 2015-01-24 schema change. Create them if necessary. This code | |
| 1179 | + ** can be removed in the future, once all users have upgraded to the | |
| 1180 | + ** 2015-01-24 schema. | |
| 1181 | + */ | |
| 1182 | + if( !db_table_has_column("repository","mlink","isaux") ){ | |
| 1183 | + db_begin_transaction(); | |
| 1184 | + db_multi_exec( | |
| 1185 | + "ALTER TABLE %s.mlink ADD COLUMN pmid INTEGER DEFAULT 0;" | |
| 1186 | + "ALTER TABLE %s.mlink ADD COLUMN isaux INTEGER DEFAULT 0;", | |
| 1187 | + db_name("repository"), db_name("repository") | |
| 1188 | + ); | |
| 1189 | + db_end_transaction(0); | |
| 1190 | + } | |
| 1175 | 1191 | } |
| 1176 | 1192 | |
| 1177 | 1193 | /* |
| 1178 | 1194 | ** Flags for the db_find_and_open_repository() function. |
| 1179 | 1195 | */ |
| @@ -1237,11 +1253,10 @@ | ||
| 1237 | 1253 | |
| 1238 | 1254 | /* |
| 1239 | 1255 | ** Return TRUE if the schema is out-of-date |
| 1240 | 1256 | */ |
| 1241 | 1257 | int db_schema_is_outofdate(void){ |
| 1242 | - if( g.zAuxSchema==0 ) g.zAuxSchema = db_get("aux-schema",""); | |
| 1243 | 1258 | return strcmp(g.zAuxSchema,AUX_SCHEMA_MIN)<0 |
| 1244 | 1259 | || strcmp(g.zAuxSchema,AUX_SCHEMA_MAX)>0; |
| 1245 | 1260 | } |
| 1246 | 1261 | |
| 1247 | 1262 | /* |
| 1248 | 1263 |
| --- src/db.c | |
| +++ src/db.c | |
| @@ -1170,10 +1170,26 @@ | |
| 1170 | g.zRepositoryName = mprintf("%s", zDbName); |
| 1171 | db_open_or_attach(g.zRepositoryName, "repository", 0); |
| 1172 | g.repositoryOpen = 1; |
| 1173 | /* Cache "allow-symlinks" option, because we'll need it on every stat call */ |
| 1174 | g.allowSymlinks = db_get_boolean("allow-symlinks", 0); |
| 1175 | } |
| 1176 | |
| 1177 | /* |
| 1178 | ** Flags for the db_find_and_open_repository() function. |
| 1179 | */ |
| @@ -1237,11 +1253,10 @@ | |
| 1237 | |
| 1238 | /* |
| 1239 | ** Return TRUE if the schema is out-of-date |
| 1240 | */ |
| 1241 | int db_schema_is_outofdate(void){ |
| 1242 | if( g.zAuxSchema==0 ) g.zAuxSchema = db_get("aux-schema",""); |
| 1243 | return strcmp(g.zAuxSchema,AUX_SCHEMA_MIN)<0 |
| 1244 | || strcmp(g.zAuxSchema,AUX_SCHEMA_MAX)>0; |
| 1245 | } |
| 1246 | |
| 1247 | /* |
| 1248 |
| --- src/db.c | |
| +++ src/db.c | |
| @@ -1170,10 +1170,26 @@ | |
| 1170 | g.zRepositoryName = mprintf("%s", zDbName); |
| 1171 | db_open_or_attach(g.zRepositoryName, "repository", 0); |
| 1172 | g.repositoryOpen = 1; |
| 1173 | /* Cache "allow-symlinks" option, because we'll need it on every stat call */ |
| 1174 | g.allowSymlinks = db_get_boolean("allow-symlinks", 0); |
| 1175 | g.zAuxSchema = db_get("aux-schema",""); |
| 1176 | |
| 1177 | /* Verify that the MLINK table has the newer columns added by the |
| 1178 | ** 2015-01-24 schema change. Create them if necessary. This code |
| 1179 | ** can be removed in the future, once all users have upgraded to the |
| 1180 | ** 2015-01-24 schema. |
| 1181 | */ |
| 1182 | if( !db_table_has_column("repository","mlink","isaux") ){ |
| 1183 | db_begin_transaction(); |
| 1184 | db_multi_exec( |
| 1185 | "ALTER TABLE %s.mlink ADD COLUMN pmid INTEGER DEFAULT 0;" |
| 1186 | "ALTER TABLE %s.mlink ADD COLUMN isaux INTEGER DEFAULT 0;", |
| 1187 | db_name("repository"), db_name("repository") |
| 1188 | ); |
| 1189 | db_end_transaction(0); |
| 1190 | } |
| 1191 | } |
| 1192 | |
| 1193 | /* |
| 1194 | ** Flags for the db_find_and_open_repository() function. |
| 1195 | */ |
| @@ -1237,11 +1253,10 @@ | |
| 1253 | |
| 1254 | /* |
| 1255 | ** Return TRUE if the schema is out-of-date |
| 1256 | */ |
| 1257 | int db_schema_is_outofdate(void){ |
| 1258 | return strcmp(g.zAuxSchema,AUX_SCHEMA_MIN)<0 |
| 1259 | || strcmp(g.zAuxSchema,AUX_SCHEMA_MAX)>0; |
| 1260 | } |
| 1261 | |
| 1262 | /* |
| 1263 |
M
src/db.c
+16
-1
| --- src/db.c | ||
| +++ src/db.c | ||
| @@ -1170,10 +1170,26 @@ | ||
| 1170 | 1170 | g.zRepositoryName = mprintf("%s", zDbName); |
| 1171 | 1171 | db_open_or_attach(g.zRepositoryName, "repository", 0); |
| 1172 | 1172 | g.repositoryOpen = 1; |
| 1173 | 1173 | /* Cache "allow-symlinks" option, because we'll need it on every stat call */ |
| 1174 | 1174 | g.allowSymlinks = db_get_boolean("allow-symlinks", 0); |
| 1175 | + g.zAuxSchema = db_get("aux-schema",""); | |
| 1176 | + | |
| 1177 | + /* Verify that the MLINK table has the newer columns added by the | |
| 1178 | + ** 2015-01-24 schema change. Create them if necessary. This code | |
| 1179 | + ** can be removed in the future, once all users have upgraded to the | |
| 1180 | + ** 2015-01-24 schema. | |
| 1181 | + */ | |
| 1182 | + if( !db_table_has_column("repository","mlink","isaux") ){ | |
| 1183 | + db_begin_transaction(); | |
| 1184 | + db_multi_exec( | |
| 1185 | + "ALTER TABLE %s.mlink ADD COLUMN pmid INTEGER DEFAULT 0;" | |
| 1186 | + "ALTER TABLE %s.mlink ADD COLUMN isaux INTEGER DEFAULT 0;", | |
| 1187 | + db_name("repository"), db_name("repository") | |
| 1188 | + ); | |
| 1189 | + db_end_transaction(0); | |
| 1190 | + } | |
| 1175 | 1191 | } |
| 1176 | 1192 | |
| 1177 | 1193 | /* |
| 1178 | 1194 | ** Flags for the db_find_and_open_repository() function. |
| 1179 | 1195 | */ |
| @@ -1237,11 +1253,10 @@ | ||
| 1237 | 1253 | |
| 1238 | 1254 | /* |
| 1239 | 1255 | ** Return TRUE if the schema is out-of-date |
| 1240 | 1256 | */ |
| 1241 | 1257 | int db_schema_is_outofdate(void){ |
| 1242 | - if( g.zAuxSchema==0 ) g.zAuxSchema = db_get("aux-schema",""); | |
| 1243 | 1258 | return strcmp(g.zAuxSchema,AUX_SCHEMA_MIN)<0 |
| 1244 | 1259 | || strcmp(g.zAuxSchema,AUX_SCHEMA_MAX)>0; |
| 1245 | 1260 | } |
| 1246 | 1261 | |
| 1247 | 1262 | /* |
| 1248 | 1263 |
| --- src/db.c | |
| +++ src/db.c | |
| @@ -1170,10 +1170,26 @@ | |
| 1170 | g.zRepositoryName = mprintf("%s", zDbName); |
| 1171 | db_open_or_attach(g.zRepositoryName, "repository", 0); |
| 1172 | g.repositoryOpen = 1; |
| 1173 | /* Cache "allow-symlinks" option, because we'll need it on every stat call */ |
| 1174 | g.allowSymlinks = db_get_boolean("allow-symlinks", 0); |
| 1175 | } |
| 1176 | |
| 1177 | /* |
| 1178 | ** Flags for the db_find_and_open_repository() function. |
| 1179 | */ |
| @@ -1237,11 +1253,10 @@ | |
| 1237 | |
| 1238 | /* |
| 1239 | ** Return TRUE if the schema is out-of-date |
| 1240 | */ |
| 1241 | int db_schema_is_outofdate(void){ |
| 1242 | if( g.zAuxSchema==0 ) g.zAuxSchema = db_get("aux-schema",""); |
| 1243 | return strcmp(g.zAuxSchema,AUX_SCHEMA_MIN)<0 |
| 1244 | || strcmp(g.zAuxSchema,AUX_SCHEMA_MAX)>0; |
| 1245 | } |
| 1246 | |
| 1247 | /* |
| 1248 |
| --- src/db.c | |
| +++ src/db.c | |
| @@ -1170,10 +1170,26 @@ | |
| 1170 | g.zRepositoryName = mprintf("%s", zDbName); |
| 1171 | db_open_or_attach(g.zRepositoryName, "repository", 0); |
| 1172 | g.repositoryOpen = 1; |
| 1173 | /* Cache "allow-symlinks" option, because we'll need it on every stat call */ |
| 1174 | g.allowSymlinks = db_get_boolean("allow-symlinks", 0); |
| 1175 | g.zAuxSchema = db_get("aux-schema",""); |
| 1176 | |
| 1177 | /* Verify that the MLINK table has the newer columns added by the |
| 1178 | ** 2015-01-24 schema change. Create them if necessary. This code |
| 1179 | ** can be removed in the future, once all users have upgraded to the |
| 1180 | ** 2015-01-24 schema. |
| 1181 | */ |
| 1182 | if( !db_table_has_column("repository","mlink","isaux") ){ |
| 1183 | db_begin_transaction(); |
| 1184 | db_multi_exec( |
| 1185 | "ALTER TABLE %s.mlink ADD COLUMN pmid INTEGER DEFAULT 0;" |
| 1186 | "ALTER TABLE %s.mlink ADD COLUMN isaux INTEGER DEFAULT 0;", |
| 1187 | db_name("repository"), db_name("repository") |
| 1188 | ); |
| 1189 | db_end_transaction(0); |
| 1190 | } |
| 1191 | } |
| 1192 | |
| 1193 | /* |
| 1194 | ** Flags for the db_find_and_open_repository() function. |
| 1195 | */ |
| @@ -1237,11 +1253,10 @@ | |
| 1253 | |
| 1254 | /* |
| 1255 | ** Return TRUE if the schema is out-of-date |
| 1256 | */ |
| 1257 | int db_schema_is_outofdate(void){ |
| 1258 | return strcmp(g.zAuxSchema,AUX_SCHEMA_MIN)<0 |
| 1259 | || strcmp(g.zAuxSchema,AUX_SCHEMA_MAX)>0; |
| 1260 | } |
| 1261 | |
| 1262 | /* |
| 1263 |
+64
-53
| --- src/manifest.c | ||
| +++ src/manifest.c | ||
| @@ -1187,16 +1187,18 @@ | ||
| 1187 | 1187 | /* |
| 1188 | 1188 | ** Add a single entry to the mlink table. Also add the filename to |
| 1189 | 1189 | ** the filename table if it is not there already. |
| 1190 | 1190 | */ |
| 1191 | 1191 | static void add_one_mlink( |
| 1192 | + int pmid, /* The parent manifest */ | |
| 1193 | + const char *zFromUuid, /* UUID for content in parent */ | |
| 1192 | 1194 | int mid, /* The record ID of the manifest */ |
| 1193 | - const char *zFromUuid, /* UUID for the mlink.pid. "" to add file */ | |
| 1194 | - const char *zToUuid, /* UUID for the mlink.fid. "" to delete */ | |
| 1195 | + const char *zToUuid, /* UUID for content in child */ | |
| 1195 | 1196 | const char *zFilename, /* Filename */ |
| 1196 | 1197 | const char *zPrior, /* Previous filename. NULL if unchanged */ |
| 1197 | 1198 | int isPublic, /* True if mid is not a private manifest */ |
| 1199 | + int isPrimary, /* pmid is the primary parent of mid */ | |
| 1198 | 1200 | int mperm /* 1: exec, 2: symlink */ |
| 1199 | 1201 | ){ |
| 1200 | 1202 | int fnid, pfnid, pid, fid; |
| 1201 | 1203 | static Stmt s1; |
| 1202 | 1204 | |
| @@ -1216,19 +1218,21 @@ | ||
| 1216 | 1218 | }else{ |
| 1217 | 1219 | fid = uuid_to_rid(zToUuid, 1); |
| 1218 | 1220 | if( isPublic ) content_make_public(fid); |
| 1219 | 1221 | } |
| 1220 | 1222 | db_static_prepare(&s1, |
| 1221 | - "INSERT INTO mlink(mid,pid,fid,fnid,pfnid,mperm)" | |
| 1222 | - "VALUES(:m,:p,:f,:n,:pfn,:mp)" | |
| 1223 | + "INSERT INTO mlink(mid,fid,pmid,pid,fnid,pfnid,mperm,isaux)" | |
| 1224 | + "VALUES(:m,:f,:pm,:p,:n,:pfn,:mp,:isaux)" | |
| 1223 | 1225 | ); |
| 1224 | 1226 | db_bind_int(&s1, ":m", mid); |
| 1225 | - db_bind_int(&s1, ":p", pid); | |
| 1226 | 1227 | db_bind_int(&s1, ":f", fid); |
| 1228 | + db_bind_int(&s1, ":pm", pmid); | |
| 1229 | + db_bind_int(&s1, ":p", pid); | |
| 1227 | 1230 | db_bind_int(&s1, ":n", fnid); |
| 1228 | 1231 | db_bind_int(&s1, ":pfn", pfnid); |
| 1229 | 1232 | db_bind_int(&s1, ":mp", mperm); |
| 1233 | + db_bind_int(&s1, ":isaux", isPrimary==0); | |
| 1230 | 1234 | db_exec(&s1); |
| 1231 | 1235 | if( pid && fid ){ |
| 1232 | 1236 | content_deltify(pid, fid, 0); |
| 1233 | 1237 | } |
| 1234 | 1238 | } |
| @@ -1342,24 +1346,29 @@ | ||
| 1342 | 1346 | ** |
| 1343 | 1347 | ** Deleted files have mlink.fid=0. |
| 1344 | 1348 | ** Added files have mlink.pid=0. |
| 1345 | 1349 | ** Edited files have both mlink.pid!=0 and mlink.fid!=0 |
| 1346 | 1350 | */ |
| 1347 | -static void add_mlink(int pid, Manifest *pParent, int cid, Manifest *pChild){ | |
| 1351 | +static void add_mlink( | |
| 1352 | + int pmid, Manifest *pParent, /* Parent check-in */ | |
| 1353 | + int mid, Manifest *pChild, /* The child check-in */ | |
| 1354 | + int isPrim /* TRUE if pmid is the primary parent of mid */ | |
| 1355 | +){ | |
| 1348 | 1356 | Blob otherContent; |
| 1349 | 1357 | int otherRid; |
| 1350 | 1358 | int i, rc; |
| 1351 | 1359 | ManifestFile *pChildFile, *pParentFile; |
| 1352 | 1360 | Manifest **ppOther; |
| 1353 | 1361 | static Stmt eq; |
| 1354 | 1362 | int isPublic; /* True if pChild is non-private */ |
| 1355 | 1363 | |
| 1356 | - /* If mlink table entires are already set for cid, then abort early | |
| 1357 | - ** doing no work. | |
| 1364 | + /* If mlink table entires are already exist for the pmid-to-mid transition, | |
| 1365 | + ** then abort early doing no work. | |
| 1358 | 1366 | */ |
| 1359 | - db_static_prepare(&eq, "SELECT 1 FROM mlink WHERE mid=:mid"); | |
| 1360 | - db_bind_int(&eq, ":mid", cid); | |
| 1367 | + db_static_prepare(&eq, "SELECT 1 FROM mlink WHERE mid=:mid AND pmid=:pmid"); | |
| 1368 | + db_bind_int(&eq, ":mid", mid); | |
| 1369 | + db_bind_int(&eq, ":pmid", pmid); | |
| 1361 | 1370 | rc = db_step(&eq); |
| 1362 | 1371 | db_reset(&eq); |
| 1363 | 1372 | if( rc==SQLITE_ROW ) return; |
| 1364 | 1373 | |
| 1365 | 1374 | /* Compute the value of the missing pParent or pChild parameter. |
| @@ -1366,14 +1375,14 @@ | ||
| 1366 | 1375 | ** Fetch the baseline checkins for both. |
| 1367 | 1376 | */ |
| 1368 | 1377 | assert( pParent==0 || pChild==0 ); |
| 1369 | 1378 | if( pParent==0 ){ |
| 1370 | 1379 | ppOther = &pParent; |
| 1371 | - otherRid = pid; | |
| 1380 | + otherRid = pmid; | |
| 1372 | 1381 | }else{ |
| 1373 | 1382 | ppOther = &pChild; |
| 1374 | - otherRid = cid; | |
| 1383 | + otherRid = mid; | |
| 1375 | 1384 | } |
| 1376 | 1385 | if( (*ppOther = manifest_cache_find(otherRid))==0 ){ |
| 1377 | 1386 | content_get(otherRid, &otherContent); |
| 1378 | 1387 | if( blob_size(&otherContent)==0 ) return; |
| 1379 | 1388 | *ppOther = manifest_parse(&otherContent, otherRid, 0); |
| @@ -1381,20 +1390,20 @@ | ||
| 1381 | 1390 | } |
| 1382 | 1391 | if( fetch_baseline(pParent, 0) || fetch_baseline(pChild, 0) ){ |
| 1383 | 1392 | manifest_destroy(*ppOther); |
| 1384 | 1393 | return; |
| 1385 | 1394 | } |
| 1386 | - isPublic = !content_is_private(cid); | |
| 1395 | + isPublic = !content_is_private(mid); | |
| 1387 | 1396 | |
| 1388 | 1397 | /* Try to make the parent manifest a delta from the child, if that |
| 1389 | 1398 | ** is an appropriate thing to do. For a new baseline, make the |
| 1390 | 1399 | ** previous baseline a delta from the current baseline. |
| 1391 | 1400 | */ |
| 1392 | 1401 | if( (pParent->zBaseline==0)==(pChild->zBaseline==0) ){ |
| 1393 | - content_deltify(pid, cid, 0); | |
| 1402 | + content_deltify(pmid, mid, 0); | |
| 1394 | 1403 | }else if( pChild->zBaseline==0 && pParent->zBaseline!=0 ){ |
| 1395 | - content_deltify(pParent->pBaseline->rid, cid, 0); | |
| 1404 | + content_deltify(pParent->pBaseline->rid, mid, 0); | |
| 1396 | 1405 | } |
| 1397 | 1406 | |
| 1398 | 1407 | /* Remember all children less than a few seconds younger than their parent, |
| 1399 | 1408 | ** as we might want to fudge the times for those children. |
| 1400 | 1409 | */ |
| @@ -1414,31 +1423,32 @@ | ||
| 1414 | 1423 | int mperm = manifest_file_mperm(pChildFile); |
| 1415 | 1424 | if( pChildFile->zPrior ){ |
| 1416 | 1425 | pParentFile = manifest_file_seek(pParent, pChildFile->zPrior, 0); |
| 1417 | 1426 | if( pParentFile ){ |
| 1418 | 1427 | /* File with name change */ |
| 1419 | - add_one_mlink(cid, pParentFile->zUuid, pChildFile->zUuid, | |
| 1420 | - pChildFile->zName, pChildFile->zPrior, isPublic, mperm); | |
| 1428 | + add_one_mlink(pmid, pParentFile->zUuid, mid, pChildFile->zUuid, | |
| 1429 | + pChildFile->zName, pChildFile->zPrior, | |
| 1430 | + isPublic, isPrim, mperm); | |
| 1421 | 1431 | }else{ |
| 1422 | 1432 | /* File name changed, but the old name is not found in the parent! |
| 1423 | 1433 | ** Treat this like a new file. */ |
| 1424 | - add_one_mlink(cid, 0, pChildFile->zUuid, pChildFile->zName, 0, | |
| 1425 | - isPublic, mperm); | |
| 1434 | + add_one_mlink(pmid, 0, mid, pChildFile->zUuid, pChildFile->zName, 0, | |
| 1435 | + isPublic, isPrim, mperm); | |
| 1426 | 1436 | } |
| 1427 | 1437 | }else{ |
| 1428 | 1438 | pParentFile = manifest_file_seek(pParent, pChildFile->zName, 0); |
| 1429 | 1439 | if( pParentFile==0 ){ |
| 1430 | 1440 | if( pChildFile->zUuid ){ |
| 1431 | 1441 | /* A new file */ |
| 1432 | - add_one_mlink(cid, 0, pChildFile->zUuid, pChildFile->zName, 0, | |
| 1433 | - isPublic, mperm); | |
| 1442 | + add_one_mlink(pmid, 0, mid, pChildFile->zUuid, pChildFile->zName, 0, | |
| 1443 | + isPublic, isPrim, mperm); | |
| 1434 | 1444 | } |
| 1435 | 1445 | }else if( fossil_strcmp(pChildFile->zUuid, pParentFile->zUuid)!=0 |
| 1436 | 1446 | || manifest_file_mperm(pParentFile)!=mperm ){ |
| 1437 | 1447 | /* Changes in file content or permissions */ |
| 1438 | - add_one_mlink(cid, pParentFile->zUuid, pChildFile->zUuid, | |
| 1439 | - pChildFile->zName, 0, isPublic, mperm); | |
| 1448 | + add_one_mlink(pmid, pParentFile->zUuid, mid, pChildFile->zUuid, | |
| 1449 | + pChildFile->zName, 0, isPublic, isPrim, mperm); | |
| 1440 | 1450 | } |
| 1441 | 1451 | } |
| 1442 | 1452 | } |
| 1443 | 1453 | if( pParent->zBaseline && pChild->zBaseline ){ |
| 1444 | 1454 | /* Both parent and child are delta manifests. Look for files that |
| @@ -1450,22 +1460,22 @@ | ||
| 1450 | 1460 | pChildFile = manifest_file_seek_base(pChild, pParentFile->zName, 0); |
| 1451 | 1461 | if( pChildFile==0 ){ |
| 1452 | 1462 | /* The child file reverts to baseline. Show this as a change */ |
| 1453 | 1463 | pChildFile = manifest_file_seek(pChild, pParentFile->zName, 0); |
| 1454 | 1464 | if( pChildFile ){ |
| 1455 | - add_one_mlink(cid, pParentFile->zUuid, pChildFile->zUuid, | |
| 1456 | - pChildFile->zName, 0, isPublic, | |
| 1465 | + add_one_mlink(pmid, pParentFile->zUuid, mid, pChildFile->zUuid, | |
| 1466 | + pChildFile->zName, 0, isPublic, isPrim, | |
| 1457 | 1467 | manifest_file_mperm(pChildFile)); |
| 1458 | 1468 | } |
| 1459 | 1469 | } |
| 1460 | 1470 | }else{ |
| 1461 | 1471 | pChildFile = manifest_file_seek(pChild, pParentFile->zName, 0); |
| 1462 | 1472 | if( pChildFile ){ |
| 1463 | 1473 | /* File resurrected in the child after having been deleted in |
| 1464 | 1474 | ** the parent. Show this as an added file. */ |
| 1465 | - add_one_mlink(cid, 0, pChildFile->zUuid, pChildFile->zName, 0, | |
| 1466 | - isPublic, manifest_file_mperm(pChildFile)); | |
| 1475 | + add_one_mlink(pmid, 0, mid, pChildFile->zUuid, pChildFile->zName, 0, | |
| 1476 | + isPublic, isPrim, manifest_file_mperm(pChildFile)); | |
| 1467 | 1477 | } |
| 1468 | 1478 | } |
| 1469 | 1479 | } |
| 1470 | 1480 | }else if( pChild->zBaseline==0 ){ |
| 1471 | 1481 | /* pChild is a baseline. Look for files that are present in pParent |
| @@ -1472,12 +1482,12 @@ | ||
| 1472 | 1482 | ** but are missing from pChild and mark them as having been deleted. */ |
| 1473 | 1483 | manifest_file_rewind(pParent); |
| 1474 | 1484 | while( (pParentFile = manifest_file_next(pParent,0))!=0 ){ |
| 1475 | 1485 | pChildFile = manifest_file_seek(pChild, pParentFile->zName, 0); |
| 1476 | 1486 | if( pChildFile==0 && pParentFile->zUuid!=0 ){ |
| 1477 | - add_one_mlink(cid, pParentFile->zUuid, 0, pParentFile->zName, 0, | |
| 1478 | - isPublic, 0); | |
| 1487 | + add_one_mlink(pmid, pParentFile->zUuid, mid, 0, pParentFile->zName, 0, | |
| 1488 | + isPublic, isPrim, 0); | |
| 1479 | 1489 | } |
| 1480 | 1490 | } |
| 1481 | 1491 | } |
| 1482 | 1492 | manifest_cache_insert(*ppOther); |
| 1483 | 1493 | } |
| @@ -1781,45 +1791,46 @@ | ||
| 1781 | 1791 | sqlite3_snprintf(sizeof(zBaseId), zBaseId, "%d", |
| 1782 | 1792 | uuid_to_rid(p->zBaseline,1)); |
| 1783 | 1793 | }else{ |
| 1784 | 1794 | sqlite3_snprintf(sizeof(zBaseId), zBaseId, "NULL"); |
| 1785 | 1795 | } |
| 1786 | - (void)db_schema_is_outofdate(); /* Make sure g.zAuxSchema is initialized */ | |
| 1787 | 1796 | for(i=0; i<p->nParent; i++){ |
| 1788 | 1797 | int pid = uuid_to_rid(p->azParent[i], 1); |
| 1789 | - if( strcmp(g.zAuxSchema,"2014-11-24 20:35")>=0 ){ | |
| 1790 | - /* Support for PLINK.BASEID added on 2014-11-24 */ | |
| 1791 | - db_multi_exec( | |
| 1792 | - "INSERT OR IGNORE INTO plink(pid, cid, isprim, mtime, baseid)" | |
| 1793 | - "VALUES(%d, %d, %d, %.17g, %s)", | |
| 1794 | - pid, rid, i==0, p->rDate, zBaseId/*safe-for-%s*/); | |
| 1795 | - }else{ | |
| 1796 | - /* Continue to work with older schema to avoid an unnecessary | |
| 1797 | - ** rebuild */ | |
| 1798 | - db_multi_exec( | |
| 1799 | - "INSERT OR IGNORE INTO plink(pid, cid, isprim, mtime)" | |
| 1800 | - "VALUES(%d, %d, %d, %.17g)", | |
| 1801 | - pid, rid, i==0, p->rDate); | |
| 1802 | - } | |
| 1803 | - if( i==0 ){ | |
| 1804 | - add_mlink(pid, 0, rid, p); | |
| 1805 | - parentid = pid; | |
| 1806 | - } | |
| 1807 | - } | |
| 1808 | - db_prepare(&q, "SELECT cid FROM plink WHERE pid=%d AND isprim", rid); | |
| 1798 | + db_multi_exec( | |
| 1799 | + "INSERT OR IGNORE INTO plink(pid, cid, isprim, mtime, baseid)" | |
| 1800 | + "VALUES(%d, %d, %d, %.17g, %s)", | |
| 1801 | + pid, rid, i==0, p->rDate, zBaseId/*safe-for-%s*/); | |
| 1802 | + add_mlink(pid, 0, rid, p, i==0); | |
| 1803 | + if( i==0 ) parentid = pid; | |
| 1804 | + } | |
| 1805 | + if( p->nParent>1 ){ | |
| 1806 | + /* Remove incorrect MLINK create-file entries that arise when a | |
| 1807 | + ** file is added by merge. */ | |
| 1808 | + db_multi_exec( | |
| 1809 | + "DELETE FROM mlink" | |
| 1810 | + " WHERE mid=%d" | |
| 1811 | + " AND pid=0" | |
| 1812 | + " AND fnid IN " | |
| 1813 | + " (SELECT fnid FROM mlink WHERE mid=%d GROUP BY fnid" | |
| 1814 | + " HAVING count(*)<%d)", | |
| 1815 | + rid, rid, p->nParent | |
| 1816 | + ); | |
| 1817 | + } | |
| 1818 | + db_prepare(&q, "SELECT cid, isprim FROM plink WHERE pid=%d", rid); | |
| 1809 | 1819 | while( db_step(&q)==SQLITE_ROW ){ |
| 1810 | 1820 | int cid = db_column_int(&q, 0); |
| 1811 | - add_mlink(rid, p, cid, 0); | |
| 1821 | + int isprim = db_column_int(&q, 1); | |
| 1822 | + add_mlink(rid, p, cid, 0, isprim); | |
| 1812 | 1823 | } |
| 1813 | 1824 | db_finalize(&q); |
| 1814 | 1825 | if( p->nParent==0 ){ |
| 1815 | 1826 | /* For root files (files without parents) add mlink entries |
| 1816 | 1827 | ** showing all content as new. */ |
| 1817 | 1828 | int isPublic = !content_is_private(rid); |
| 1818 | 1829 | for(i=0; i<p->nFile; i++){ |
| 1819 | - add_one_mlink(rid, 0, p->aFile[i].zUuid, p->aFile[i].zName, 0, | |
| 1820 | - isPublic, manifest_file_mperm(&p->aFile[i])); | |
| 1830 | + add_one_mlink(0, 0, rid, p->aFile[i].zUuid, p->aFile[i].zName, 0, | |
| 1831 | + isPublic, 1, manifest_file_mperm(&p->aFile[i])); | |
| 1821 | 1832 | } |
| 1822 | 1833 | } |
| 1823 | 1834 | db_multi_exec( |
| 1824 | 1835 | "REPLACE INTO event(type,mtime,objid,user,comment," |
| 1825 | 1836 | "bgcolor,euser,ecomment,omtime)" |
| 1826 | 1837 |
| --- src/manifest.c | |
| +++ src/manifest.c | |
| @@ -1187,16 +1187,18 @@ | |
| 1187 | /* |
| 1188 | ** Add a single entry to the mlink table. Also add the filename to |
| 1189 | ** the filename table if it is not there already. |
| 1190 | */ |
| 1191 | static void add_one_mlink( |
| 1192 | int mid, /* The record ID of the manifest */ |
| 1193 | const char *zFromUuid, /* UUID for the mlink.pid. "" to add file */ |
| 1194 | const char *zToUuid, /* UUID for the mlink.fid. "" to delete */ |
| 1195 | const char *zFilename, /* Filename */ |
| 1196 | const char *zPrior, /* Previous filename. NULL if unchanged */ |
| 1197 | int isPublic, /* True if mid is not a private manifest */ |
| 1198 | int mperm /* 1: exec, 2: symlink */ |
| 1199 | ){ |
| 1200 | int fnid, pfnid, pid, fid; |
| 1201 | static Stmt s1; |
| 1202 | |
| @@ -1216,19 +1218,21 @@ | |
| 1216 | }else{ |
| 1217 | fid = uuid_to_rid(zToUuid, 1); |
| 1218 | if( isPublic ) content_make_public(fid); |
| 1219 | } |
| 1220 | db_static_prepare(&s1, |
| 1221 | "INSERT INTO mlink(mid,pid,fid,fnid,pfnid,mperm)" |
| 1222 | "VALUES(:m,:p,:f,:n,:pfn,:mp)" |
| 1223 | ); |
| 1224 | db_bind_int(&s1, ":m", mid); |
| 1225 | db_bind_int(&s1, ":p", pid); |
| 1226 | db_bind_int(&s1, ":f", fid); |
| 1227 | db_bind_int(&s1, ":n", fnid); |
| 1228 | db_bind_int(&s1, ":pfn", pfnid); |
| 1229 | db_bind_int(&s1, ":mp", mperm); |
| 1230 | db_exec(&s1); |
| 1231 | if( pid && fid ){ |
| 1232 | content_deltify(pid, fid, 0); |
| 1233 | } |
| 1234 | } |
| @@ -1342,24 +1346,29 @@ | |
| 1342 | ** |
| 1343 | ** Deleted files have mlink.fid=0. |
| 1344 | ** Added files have mlink.pid=0. |
| 1345 | ** Edited files have both mlink.pid!=0 and mlink.fid!=0 |
| 1346 | */ |
| 1347 | static void add_mlink(int pid, Manifest *pParent, int cid, Manifest *pChild){ |
| 1348 | Blob otherContent; |
| 1349 | int otherRid; |
| 1350 | int i, rc; |
| 1351 | ManifestFile *pChildFile, *pParentFile; |
| 1352 | Manifest **ppOther; |
| 1353 | static Stmt eq; |
| 1354 | int isPublic; /* True if pChild is non-private */ |
| 1355 | |
| 1356 | /* If mlink table entires are already set for cid, then abort early |
| 1357 | ** doing no work. |
| 1358 | */ |
| 1359 | db_static_prepare(&eq, "SELECT 1 FROM mlink WHERE mid=:mid"); |
| 1360 | db_bind_int(&eq, ":mid", cid); |
| 1361 | rc = db_step(&eq); |
| 1362 | db_reset(&eq); |
| 1363 | if( rc==SQLITE_ROW ) return; |
| 1364 | |
| 1365 | /* Compute the value of the missing pParent or pChild parameter. |
| @@ -1366,14 +1375,14 @@ | |
| 1366 | ** Fetch the baseline checkins for both. |
| 1367 | */ |
| 1368 | assert( pParent==0 || pChild==0 ); |
| 1369 | if( pParent==0 ){ |
| 1370 | ppOther = &pParent; |
| 1371 | otherRid = pid; |
| 1372 | }else{ |
| 1373 | ppOther = &pChild; |
| 1374 | otherRid = cid; |
| 1375 | } |
| 1376 | if( (*ppOther = manifest_cache_find(otherRid))==0 ){ |
| 1377 | content_get(otherRid, &otherContent); |
| 1378 | if( blob_size(&otherContent)==0 ) return; |
| 1379 | *ppOther = manifest_parse(&otherContent, otherRid, 0); |
| @@ -1381,20 +1390,20 @@ | |
| 1381 | } |
| 1382 | if( fetch_baseline(pParent, 0) || fetch_baseline(pChild, 0) ){ |
| 1383 | manifest_destroy(*ppOther); |
| 1384 | return; |
| 1385 | } |
| 1386 | isPublic = !content_is_private(cid); |
| 1387 | |
| 1388 | /* Try to make the parent manifest a delta from the child, if that |
| 1389 | ** is an appropriate thing to do. For a new baseline, make the |
| 1390 | ** previous baseline a delta from the current baseline. |
| 1391 | */ |
| 1392 | if( (pParent->zBaseline==0)==(pChild->zBaseline==0) ){ |
| 1393 | content_deltify(pid, cid, 0); |
| 1394 | }else if( pChild->zBaseline==0 && pParent->zBaseline!=0 ){ |
| 1395 | content_deltify(pParent->pBaseline->rid, cid, 0); |
| 1396 | } |
| 1397 | |
| 1398 | /* Remember all children less than a few seconds younger than their parent, |
| 1399 | ** as we might want to fudge the times for those children. |
| 1400 | */ |
| @@ -1414,31 +1423,32 @@ | |
| 1414 | int mperm = manifest_file_mperm(pChildFile); |
| 1415 | if( pChildFile->zPrior ){ |
| 1416 | pParentFile = manifest_file_seek(pParent, pChildFile->zPrior, 0); |
| 1417 | if( pParentFile ){ |
| 1418 | /* File with name change */ |
| 1419 | add_one_mlink(cid, pParentFile->zUuid, pChildFile->zUuid, |
| 1420 | pChildFile->zName, pChildFile->zPrior, isPublic, mperm); |
| 1421 | }else{ |
| 1422 | /* File name changed, but the old name is not found in the parent! |
| 1423 | ** Treat this like a new file. */ |
| 1424 | add_one_mlink(cid, 0, pChildFile->zUuid, pChildFile->zName, 0, |
| 1425 | isPublic, mperm); |
| 1426 | } |
| 1427 | }else{ |
| 1428 | pParentFile = manifest_file_seek(pParent, pChildFile->zName, 0); |
| 1429 | if( pParentFile==0 ){ |
| 1430 | if( pChildFile->zUuid ){ |
| 1431 | /* A new file */ |
| 1432 | add_one_mlink(cid, 0, pChildFile->zUuid, pChildFile->zName, 0, |
| 1433 | isPublic, mperm); |
| 1434 | } |
| 1435 | }else if( fossil_strcmp(pChildFile->zUuid, pParentFile->zUuid)!=0 |
| 1436 | || manifest_file_mperm(pParentFile)!=mperm ){ |
| 1437 | /* Changes in file content or permissions */ |
| 1438 | add_one_mlink(cid, pParentFile->zUuid, pChildFile->zUuid, |
| 1439 | pChildFile->zName, 0, isPublic, mperm); |
| 1440 | } |
| 1441 | } |
| 1442 | } |
| 1443 | if( pParent->zBaseline && pChild->zBaseline ){ |
| 1444 | /* Both parent and child are delta manifests. Look for files that |
| @@ -1450,22 +1460,22 @@ | |
| 1450 | pChildFile = manifest_file_seek_base(pChild, pParentFile->zName, 0); |
| 1451 | if( pChildFile==0 ){ |
| 1452 | /* The child file reverts to baseline. Show this as a change */ |
| 1453 | pChildFile = manifest_file_seek(pChild, pParentFile->zName, 0); |
| 1454 | if( pChildFile ){ |
| 1455 | add_one_mlink(cid, pParentFile->zUuid, pChildFile->zUuid, |
| 1456 | pChildFile->zName, 0, isPublic, |
| 1457 | manifest_file_mperm(pChildFile)); |
| 1458 | } |
| 1459 | } |
| 1460 | }else{ |
| 1461 | pChildFile = manifest_file_seek(pChild, pParentFile->zName, 0); |
| 1462 | if( pChildFile ){ |
| 1463 | /* File resurrected in the child after having been deleted in |
| 1464 | ** the parent. Show this as an added file. */ |
| 1465 | add_one_mlink(cid, 0, pChildFile->zUuid, pChildFile->zName, 0, |
| 1466 | isPublic, manifest_file_mperm(pChildFile)); |
| 1467 | } |
| 1468 | } |
| 1469 | } |
| 1470 | }else if( pChild->zBaseline==0 ){ |
| 1471 | /* pChild is a baseline. Look for files that are present in pParent |
| @@ -1472,12 +1482,12 @@ | |
| 1472 | ** but are missing from pChild and mark them as having been deleted. */ |
| 1473 | manifest_file_rewind(pParent); |
| 1474 | while( (pParentFile = manifest_file_next(pParent,0))!=0 ){ |
| 1475 | pChildFile = manifest_file_seek(pChild, pParentFile->zName, 0); |
| 1476 | if( pChildFile==0 && pParentFile->zUuid!=0 ){ |
| 1477 | add_one_mlink(cid, pParentFile->zUuid, 0, pParentFile->zName, 0, |
| 1478 | isPublic, 0); |
| 1479 | } |
| 1480 | } |
| 1481 | } |
| 1482 | manifest_cache_insert(*ppOther); |
| 1483 | } |
| @@ -1781,45 +1791,46 @@ | |
| 1781 | sqlite3_snprintf(sizeof(zBaseId), zBaseId, "%d", |
| 1782 | uuid_to_rid(p->zBaseline,1)); |
| 1783 | }else{ |
| 1784 | sqlite3_snprintf(sizeof(zBaseId), zBaseId, "NULL"); |
| 1785 | } |
| 1786 | (void)db_schema_is_outofdate(); /* Make sure g.zAuxSchema is initialized */ |
| 1787 | for(i=0; i<p->nParent; i++){ |
| 1788 | int pid = uuid_to_rid(p->azParent[i], 1); |
| 1789 | if( strcmp(g.zAuxSchema,"2014-11-24 20:35")>=0 ){ |
| 1790 | /* Support for PLINK.BASEID added on 2014-11-24 */ |
| 1791 | db_multi_exec( |
| 1792 | "INSERT OR IGNORE INTO plink(pid, cid, isprim, mtime, baseid)" |
| 1793 | "VALUES(%d, %d, %d, %.17g, %s)", |
| 1794 | pid, rid, i==0, p->rDate, zBaseId/*safe-for-%s*/); |
| 1795 | }else{ |
| 1796 | /* Continue to work with older schema to avoid an unnecessary |
| 1797 | ** rebuild */ |
| 1798 | db_multi_exec( |
| 1799 | "INSERT OR IGNORE INTO plink(pid, cid, isprim, mtime)" |
| 1800 | "VALUES(%d, %d, %d, %.17g)", |
| 1801 | pid, rid, i==0, p->rDate); |
| 1802 | } |
| 1803 | if( i==0 ){ |
| 1804 | add_mlink(pid, 0, rid, p); |
| 1805 | parentid = pid; |
| 1806 | } |
| 1807 | } |
| 1808 | db_prepare(&q, "SELECT cid FROM plink WHERE pid=%d AND isprim", rid); |
| 1809 | while( db_step(&q)==SQLITE_ROW ){ |
| 1810 | int cid = db_column_int(&q, 0); |
| 1811 | add_mlink(rid, p, cid, 0); |
| 1812 | } |
| 1813 | db_finalize(&q); |
| 1814 | if( p->nParent==0 ){ |
| 1815 | /* For root files (files without parents) add mlink entries |
| 1816 | ** showing all content as new. */ |
| 1817 | int isPublic = !content_is_private(rid); |
| 1818 | for(i=0; i<p->nFile; i++){ |
| 1819 | add_one_mlink(rid, 0, p->aFile[i].zUuid, p->aFile[i].zName, 0, |
| 1820 | isPublic, manifest_file_mperm(&p->aFile[i])); |
| 1821 | } |
| 1822 | } |
| 1823 | db_multi_exec( |
| 1824 | "REPLACE INTO event(type,mtime,objid,user,comment," |
| 1825 | "bgcolor,euser,ecomment,omtime)" |
| 1826 |
| --- src/manifest.c | |
| +++ src/manifest.c | |
| @@ -1187,16 +1187,18 @@ | |
| 1187 | /* |
| 1188 | ** Add a single entry to the mlink table. Also add the filename to |
| 1189 | ** the filename table if it is not there already. |
| 1190 | */ |
| 1191 | static void add_one_mlink( |
| 1192 | int pmid, /* The parent manifest */ |
| 1193 | const char *zFromUuid, /* UUID for content in parent */ |
| 1194 | int mid, /* The record ID of the manifest */ |
| 1195 | const char *zToUuid, /* UUID for content in child */ |
| 1196 | const char *zFilename, /* Filename */ |
| 1197 | const char *zPrior, /* Previous filename. NULL if unchanged */ |
| 1198 | int isPublic, /* True if mid is not a private manifest */ |
| 1199 | int isPrimary, /* pmid is the primary parent of mid */ |
| 1200 | int mperm /* 1: exec, 2: symlink */ |
| 1201 | ){ |
| 1202 | int fnid, pfnid, pid, fid; |
| 1203 | static Stmt s1; |
| 1204 | |
| @@ -1216,19 +1218,21 @@ | |
| 1218 | }else{ |
| 1219 | fid = uuid_to_rid(zToUuid, 1); |
| 1220 | if( isPublic ) content_make_public(fid); |
| 1221 | } |
| 1222 | db_static_prepare(&s1, |
| 1223 | "INSERT INTO mlink(mid,fid,pmid,pid,fnid,pfnid,mperm,isaux)" |
| 1224 | "VALUES(:m,:f,:pm,:p,:n,:pfn,:mp,:isaux)" |
| 1225 | ); |
| 1226 | db_bind_int(&s1, ":m", mid); |
| 1227 | db_bind_int(&s1, ":f", fid); |
| 1228 | db_bind_int(&s1, ":pm", pmid); |
| 1229 | db_bind_int(&s1, ":p", pid); |
| 1230 | db_bind_int(&s1, ":n", fnid); |
| 1231 | db_bind_int(&s1, ":pfn", pfnid); |
| 1232 | db_bind_int(&s1, ":mp", mperm); |
| 1233 | db_bind_int(&s1, ":isaux", isPrimary==0); |
| 1234 | db_exec(&s1); |
| 1235 | if( pid && fid ){ |
| 1236 | content_deltify(pid, fid, 0); |
| 1237 | } |
| 1238 | } |
| @@ -1342,24 +1346,29 @@ | |
| 1346 | ** |
| 1347 | ** Deleted files have mlink.fid=0. |
| 1348 | ** Added files have mlink.pid=0. |
| 1349 | ** Edited files have both mlink.pid!=0 and mlink.fid!=0 |
| 1350 | */ |
| 1351 | static void add_mlink( |
| 1352 | int pmid, Manifest *pParent, /* Parent check-in */ |
| 1353 | int mid, Manifest *pChild, /* The child check-in */ |
| 1354 | int isPrim /* TRUE if pmid is the primary parent of mid */ |
| 1355 | ){ |
| 1356 | Blob otherContent; |
| 1357 | int otherRid; |
| 1358 | int i, rc; |
| 1359 | ManifestFile *pChildFile, *pParentFile; |
| 1360 | Manifest **ppOther; |
| 1361 | static Stmt eq; |
| 1362 | int isPublic; /* True if pChild is non-private */ |
| 1363 | |
| 1364 | /* If mlink table entires are already exist for the pmid-to-mid transition, |
| 1365 | ** then abort early doing no work. |
| 1366 | */ |
| 1367 | db_static_prepare(&eq, "SELECT 1 FROM mlink WHERE mid=:mid AND pmid=:pmid"); |
| 1368 | db_bind_int(&eq, ":mid", mid); |
| 1369 | db_bind_int(&eq, ":pmid", pmid); |
| 1370 | rc = db_step(&eq); |
| 1371 | db_reset(&eq); |
| 1372 | if( rc==SQLITE_ROW ) return; |
| 1373 | |
| 1374 | /* Compute the value of the missing pParent or pChild parameter. |
| @@ -1366,14 +1375,14 @@ | |
| 1375 | ** Fetch the baseline checkins for both. |
| 1376 | */ |
| 1377 | assert( pParent==0 || pChild==0 ); |
| 1378 | if( pParent==0 ){ |
| 1379 | ppOther = &pParent; |
| 1380 | otherRid = pmid; |
| 1381 | }else{ |
| 1382 | ppOther = &pChild; |
| 1383 | otherRid = mid; |
| 1384 | } |
| 1385 | if( (*ppOther = manifest_cache_find(otherRid))==0 ){ |
| 1386 | content_get(otherRid, &otherContent); |
| 1387 | if( blob_size(&otherContent)==0 ) return; |
| 1388 | *ppOther = manifest_parse(&otherContent, otherRid, 0); |
| @@ -1381,20 +1390,20 @@ | |
| 1390 | } |
| 1391 | if( fetch_baseline(pParent, 0) || fetch_baseline(pChild, 0) ){ |
| 1392 | manifest_destroy(*ppOther); |
| 1393 | return; |
| 1394 | } |
| 1395 | isPublic = !content_is_private(mid); |
| 1396 | |
| 1397 | /* Try to make the parent manifest a delta from the child, if that |
| 1398 | ** is an appropriate thing to do. For a new baseline, make the |
| 1399 | ** previous baseline a delta from the current baseline. |
| 1400 | */ |
| 1401 | if( (pParent->zBaseline==0)==(pChild->zBaseline==0) ){ |
| 1402 | content_deltify(pmid, mid, 0); |
| 1403 | }else if( pChild->zBaseline==0 && pParent->zBaseline!=0 ){ |
| 1404 | content_deltify(pParent->pBaseline->rid, mid, 0); |
| 1405 | } |
| 1406 | |
| 1407 | /* Remember all children less than a few seconds younger than their parent, |
| 1408 | ** as we might want to fudge the times for those children. |
| 1409 | */ |
| @@ -1414,31 +1423,32 @@ | |
| 1423 | int mperm = manifest_file_mperm(pChildFile); |
| 1424 | if( pChildFile->zPrior ){ |
| 1425 | pParentFile = manifest_file_seek(pParent, pChildFile->zPrior, 0); |
| 1426 | if( pParentFile ){ |
| 1427 | /* File with name change */ |
| 1428 | add_one_mlink(pmid, pParentFile->zUuid, mid, pChildFile->zUuid, |
| 1429 | pChildFile->zName, pChildFile->zPrior, |
| 1430 | isPublic, isPrim, mperm); |
| 1431 | }else{ |
| 1432 | /* File name changed, but the old name is not found in the parent! |
| 1433 | ** Treat this like a new file. */ |
| 1434 | add_one_mlink(pmid, 0, mid, pChildFile->zUuid, pChildFile->zName, 0, |
| 1435 | isPublic, isPrim, mperm); |
| 1436 | } |
| 1437 | }else{ |
| 1438 | pParentFile = manifest_file_seek(pParent, pChildFile->zName, 0); |
| 1439 | if( pParentFile==0 ){ |
| 1440 | if( pChildFile->zUuid ){ |
| 1441 | /* A new file */ |
| 1442 | add_one_mlink(pmid, 0, mid, pChildFile->zUuid, pChildFile->zName, 0, |
| 1443 | isPublic, isPrim, mperm); |
| 1444 | } |
| 1445 | }else if( fossil_strcmp(pChildFile->zUuid, pParentFile->zUuid)!=0 |
| 1446 | || manifest_file_mperm(pParentFile)!=mperm ){ |
| 1447 | /* Changes in file content or permissions */ |
| 1448 | add_one_mlink(pmid, pParentFile->zUuid, mid, pChildFile->zUuid, |
| 1449 | pChildFile->zName, 0, isPublic, isPrim, mperm); |
| 1450 | } |
| 1451 | } |
| 1452 | } |
| 1453 | if( pParent->zBaseline && pChild->zBaseline ){ |
| 1454 | /* Both parent and child are delta manifests. Look for files that |
| @@ -1450,22 +1460,22 @@ | |
| 1460 | pChildFile = manifest_file_seek_base(pChild, pParentFile->zName, 0); |
| 1461 | if( pChildFile==0 ){ |
| 1462 | /* The child file reverts to baseline. Show this as a change */ |
| 1463 | pChildFile = manifest_file_seek(pChild, pParentFile->zName, 0); |
| 1464 | if( pChildFile ){ |
| 1465 | add_one_mlink(pmid, pParentFile->zUuid, mid, pChildFile->zUuid, |
| 1466 | pChildFile->zName, 0, isPublic, isPrim, |
| 1467 | manifest_file_mperm(pChildFile)); |
| 1468 | } |
| 1469 | } |
| 1470 | }else{ |
| 1471 | pChildFile = manifest_file_seek(pChild, pParentFile->zName, 0); |
| 1472 | if( pChildFile ){ |
| 1473 | /* File resurrected in the child after having been deleted in |
| 1474 | ** the parent. Show this as an added file. */ |
| 1475 | add_one_mlink(pmid, 0, mid, pChildFile->zUuid, pChildFile->zName, 0, |
| 1476 | isPublic, isPrim, manifest_file_mperm(pChildFile)); |
| 1477 | } |
| 1478 | } |
| 1479 | } |
| 1480 | }else if( pChild->zBaseline==0 ){ |
| 1481 | /* pChild is a baseline. Look for files that are present in pParent |
| @@ -1472,12 +1482,12 @@ | |
| 1482 | ** but are missing from pChild and mark them as having been deleted. */ |
| 1483 | manifest_file_rewind(pParent); |
| 1484 | while( (pParentFile = manifest_file_next(pParent,0))!=0 ){ |
| 1485 | pChildFile = manifest_file_seek(pChild, pParentFile->zName, 0); |
| 1486 | if( pChildFile==0 && pParentFile->zUuid!=0 ){ |
| 1487 | add_one_mlink(pmid, pParentFile->zUuid, mid, 0, pParentFile->zName, 0, |
| 1488 | isPublic, isPrim, 0); |
| 1489 | } |
| 1490 | } |
| 1491 | } |
| 1492 | manifest_cache_insert(*ppOther); |
| 1493 | } |
| @@ -1781,45 +1791,46 @@ | |
| 1791 | sqlite3_snprintf(sizeof(zBaseId), zBaseId, "%d", |
| 1792 | uuid_to_rid(p->zBaseline,1)); |
| 1793 | }else{ |
| 1794 | sqlite3_snprintf(sizeof(zBaseId), zBaseId, "NULL"); |
| 1795 | } |
| 1796 | for(i=0; i<p->nParent; i++){ |
| 1797 | int pid = uuid_to_rid(p->azParent[i], 1); |
| 1798 | db_multi_exec( |
| 1799 | "INSERT OR IGNORE INTO plink(pid, cid, isprim, mtime, baseid)" |
| 1800 | "VALUES(%d, %d, %d, %.17g, %s)", |
| 1801 | pid, rid, i==0, p->rDate, zBaseId/*safe-for-%s*/); |
| 1802 | add_mlink(pid, 0, rid, p, i==0); |
| 1803 | if( i==0 ) parentid = pid; |
| 1804 | } |
| 1805 | if( p->nParent>1 ){ |
| 1806 | /* Remove incorrect MLINK create-file entries that arise when a |
| 1807 | ** file is added by merge. */ |
| 1808 | db_multi_exec( |
| 1809 | "DELETE FROM mlink" |
| 1810 | " WHERE mid=%d" |
| 1811 | " AND pid=0" |
| 1812 | " AND fnid IN " |
| 1813 | " (SELECT fnid FROM mlink WHERE mid=%d GROUP BY fnid" |
| 1814 | " HAVING count(*)<%d)", |
| 1815 | rid, rid, p->nParent |
| 1816 | ); |
| 1817 | } |
| 1818 | db_prepare(&q, "SELECT cid, isprim FROM plink WHERE pid=%d", rid); |
| 1819 | while( db_step(&q)==SQLITE_ROW ){ |
| 1820 | int cid = db_column_int(&q, 0); |
| 1821 | int isprim = db_column_int(&q, 1); |
| 1822 | add_mlink(rid, p, cid, 0, isprim); |
| 1823 | } |
| 1824 | db_finalize(&q); |
| 1825 | if( p->nParent==0 ){ |
| 1826 | /* For root files (files without parents) add mlink entries |
| 1827 | ** showing all content as new. */ |
| 1828 | int isPublic = !content_is_private(rid); |
| 1829 | for(i=0; i<p->nFile; i++){ |
| 1830 | add_one_mlink(0, 0, rid, p->aFile[i].zUuid, p->aFile[i].zName, 0, |
| 1831 | isPublic, 1, manifest_file_mperm(&p->aFile[i])); |
| 1832 | } |
| 1833 | } |
| 1834 | db_multi_exec( |
| 1835 | "REPLACE INTO event(type,mtime,objid,user,comment," |
| 1836 | "bgcolor,euser,ecomment,omtime)" |
| 1837 |
+64
-53
| --- src/manifest.c | ||
| +++ src/manifest.c | ||
| @@ -1187,16 +1187,18 @@ | ||
| 1187 | 1187 | /* |
| 1188 | 1188 | ** Add a single entry to the mlink table. Also add the filename to |
| 1189 | 1189 | ** the filename table if it is not there already. |
| 1190 | 1190 | */ |
| 1191 | 1191 | static void add_one_mlink( |
| 1192 | + int pmid, /* The parent manifest */ | |
| 1193 | + const char *zFromUuid, /* UUID for content in parent */ | |
| 1192 | 1194 | int mid, /* The record ID of the manifest */ |
| 1193 | - const char *zFromUuid, /* UUID for the mlink.pid. "" to add file */ | |
| 1194 | - const char *zToUuid, /* UUID for the mlink.fid. "" to delete */ | |
| 1195 | + const char *zToUuid, /* UUID for content in child */ | |
| 1195 | 1196 | const char *zFilename, /* Filename */ |
| 1196 | 1197 | const char *zPrior, /* Previous filename. NULL if unchanged */ |
| 1197 | 1198 | int isPublic, /* True if mid is not a private manifest */ |
| 1199 | + int isPrimary, /* pmid is the primary parent of mid */ | |
| 1198 | 1200 | int mperm /* 1: exec, 2: symlink */ |
| 1199 | 1201 | ){ |
| 1200 | 1202 | int fnid, pfnid, pid, fid; |
| 1201 | 1203 | static Stmt s1; |
| 1202 | 1204 | |
| @@ -1216,19 +1218,21 @@ | ||
| 1216 | 1218 | }else{ |
| 1217 | 1219 | fid = uuid_to_rid(zToUuid, 1); |
| 1218 | 1220 | if( isPublic ) content_make_public(fid); |
| 1219 | 1221 | } |
| 1220 | 1222 | db_static_prepare(&s1, |
| 1221 | - "INSERT INTO mlink(mid,pid,fid,fnid,pfnid,mperm)" | |
| 1222 | - "VALUES(:m,:p,:f,:n,:pfn,:mp)" | |
| 1223 | + "INSERT INTO mlink(mid,fid,pmid,pid,fnid,pfnid,mperm,isaux)" | |
| 1224 | + "VALUES(:m,:f,:pm,:p,:n,:pfn,:mp,:isaux)" | |
| 1223 | 1225 | ); |
| 1224 | 1226 | db_bind_int(&s1, ":m", mid); |
| 1225 | - db_bind_int(&s1, ":p", pid); | |
| 1226 | 1227 | db_bind_int(&s1, ":f", fid); |
| 1228 | + db_bind_int(&s1, ":pm", pmid); | |
| 1229 | + db_bind_int(&s1, ":p", pid); | |
| 1227 | 1230 | db_bind_int(&s1, ":n", fnid); |
| 1228 | 1231 | db_bind_int(&s1, ":pfn", pfnid); |
| 1229 | 1232 | db_bind_int(&s1, ":mp", mperm); |
| 1233 | + db_bind_int(&s1, ":isaux", isPrimary==0); | |
| 1230 | 1234 | db_exec(&s1); |
| 1231 | 1235 | if( pid && fid ){ |
| 1232 | 1236 | content_deltify(pid, fid, 0); |
| 1233 | 1237 | } |
| 1234 | 1238 | } |
| @@ -1342,24 +1346,29 @@ | ||
| 1342 | 1346 | ** |
| 1343 | 1347 | ** Deleted files have mlink.fid=0. |
| 1344 | 1348 | ** Added files have mlink.pid=0. |
| 1345 | 1349 | ** Edited files have both mlink.pid!=0 and mlink.fid!=0 |
| 1346 | 1350 | */ |
| 1347 | -static void add_mlink(int pid, Manifest *pParent, int cid, Manifest *pChild){ | |
| 1351 | +static void add_mlink( | |
| 1352 | + int pmid, Manifest *pParent, /* Parent check-in */ | |
| 1353 | + int mid, Manifest *pChild, /* The child check-in */ | |
| 1354 | + int isPrim /* TRUE if pmid is the primary parent of mid */ | |
| 1355 | +){ | |
| 1348 | 1356 | Blob otherContent; |
| 1349 | 1357 | int otherRid; |
| 1350 | 1358 | int i, rc; |
| 1351 | 1359 | ManifestFile *pChildFile, *pParentFile; |
| 1352 | 1360 | Manifest **ppOther; |
| 1353 | 1361 | static Stmt eq; |
| 1354 | 1362 | int isPublic; /* True if pChild is non-private */ |
| 1355 | 1363 | |
| 1356 | - /* If mlink table entires are already set for cid, then abort early | |
| 1357 | - ** doing no work. | |
| 1364 | + /* If mlink table entires are already exist for the pmid-to-mid transition, | |
| 1365 | + ** then abort early doing no work. | |
| 1358 | 1366 | */ |
| 1359 | - db_static_prepare(&eq, "SELECT 1 FROM mlink WHERE mid=:mid"); | |
| 1360 | - db_bind_int(&eq, ":mid", cid); | |
| 1367 | + db_static_prepare(&eq, "SELECT 1 FROM mlink WHERE mid=:mid AND pmid=:pmid"); | |
| 1368 | + db_bind_int(&eq, ":mid", mid); | |
| 1369 | + db_bind_int(&eq, ":pmid", pmid); | |
| 1361 | 1370 | rc = db_step(&eq); |
| 1362 | 1371 | db_reset(&eq); |
| 1363 | 1372 | if( rc==SQLITE_ROW ) return; |
| 1364 | 1373 | |
| 1365 | 1374 | /* Compute the value of the missing pParent or pChild parameter. |
| @@ -1366,14 +1375,14 @@ | ||
| 1366 | 1375 | ** Fetch the baseline checkins for both. |
| 1367 | 1376 | */ |
| 1368 | 1377 | assert( pParent==0 || pChild==0 ); |
| 1369 | 1378 | if( pParent==0 ){ |
| 1370 | 1379 | ppOther = &pParent; |
| 1371 | - otherRid = pid; | |
| 1380 | + otherRid = pmid; | |
| 1372 | 1381 | }else{ |
| 1373 | 1382 | ppOther = &pChild; |
| 1374 | - otherRid = cid; | |
| 1383 | + otherRid = mid; | |
| 1375 | 1384 | } |
| 1376 | 1385 | if( (*ppOther = manifest_cache_find(otherRid))==0 ){ |
| 1377 | 1386 | content_get(otherRid, &otherContent); |
| 1378 | 1387 | if( blob_size(&otherContent)==0 ) return; |
| 1379 | 1388 | *ppOther = manifest_parse(&otherContent, otherRid, 0); |
| @@ -1381,20 +1390,20 @@ | ||
| 1381 | 1390 | } |
| 1382 | 1391 | if( fetch_baseline(pParent, 0) || fetch_baseline(pChild, 0) ){ |
| 1383 | 1392 | manifest_destroy(*ppOther); |
| 1384 | 1393 | return; |
| 1385 | 1394 | } |
| 1386 | - isPublic = !content_is_private(cid); | |
| 1395 | + isPublic = !content_is_private(mid); | |
| 1387 | 1396 | |
| 1388 | 1397 | /* Try to make the parent manifest a delta from the child, if that |
| 1389 | 1398 | ** is an appropriate thing to do. For a new baseline, make the |
| 1390 | 1399 | ** previous baseline a delta from the current baseline. |
| 1391 | 1400 | */ |
| 1392 | 1401 | if( (pParent->zBaseline==0)==(pChild->zBaseline==0) ){ |
| 1393 | - content_deltify(pid, cid, 0); | |
| 1402 | + content_deltify(pmid, mid, 0); | |
| 1394 | 1403 | }else if( pChild->zBaseline==0 && pParent->zBaseline!=0 ){ |
| 1395 | - content_deltify(pParent->pBaseline->rid, cid, 0); | |
| 1404 | + content_deltify(pParent->pBaseline->rid, mid, 0); | |
| 1396 | 1405 | } |
| 1397 | 1406 | |
| 1398 | 1407 | /* Remember all children less than a few seconds younger than their parent, |
| 1399 | 1408 | ** as we might want to fudge the times for those children. |
| 1400 | 1409 | */ |
| @@ -1414,31 +1423,32 @@ | ||
| 1414 | 1423 | int mperm = manifest_file_mperm(pChildFile); |
| 1415 | 1424 | if( pChildFile->zPrior ){ |
| 1416 | 1425 | pParentFile = manifest_file_seek(pParent, pChildFile->zPrior, 0); |
| 1417 | 1426 | if( pParentFile ){ |
| 1418 | 1427 | /* File with name change */ |
| 1419 | - add_one_mlink(cid, pParentFile->zUuid, pChildFile->zUuid, | |
| 1420 | - pChildFile->zName, pChildFile->zPrior, isPublic, mperm); | |
| 1428 | + add_one_mlink(pmid, pParentFile->zUuid, mid, pChildFile->zUuid, | |
| 1429 | + pChildFile->zName, pChildFile->zPrior, | |
| 1430 | + isPublic, isPrim, mperm); | |
| 1421 | 1431 | }else{ |
| 1422 | 1432 | /* File name changed, but the old name is not found in the parent! |
| 1423 | 1433 | ** Treat this like a new file. */ |
| 1424 | - add_one_mlink(cid, 0, pChildFile->zUuid, pChildFile->zName, 0, | |
| 1425 | - isPublic, mperm); | |
| 1434 | + add_one_mlink(pmid, 0, mid, pChildFile->zUuid, pChildFile->zName, 0, | |
| 1435 | + isPublic, isPrim, mperm); | |
| 1426 | 1436 | } |
| 1427 | 1437 | }else{ |
| 1428 | 1438 | pParentFile = manifest_file_seek(pParent, pChildFile->zName, 0); |
| 1429 | 1439 | if( pParentFile==0 ){ |
| 1430 | 1440 | if( pChildFile->zUuid ){ |
| 1431 | 1441 | /* A new file */ |
| 1432 | - add_one_mlink(cid, 0, pChildFile->zUuid, pChildFile->zName, 0, | |
| 1433 | - isPublic, mperm); | |
| 1442 | + add_one_mlink(pmid, 0, mid, pChildFile->zUuid, pChildFile->zName, 0, | |
| 1443 | + isPublic, isPrim, mperm); | |
| 1434 | 1444 | } |
| 1435 | 1445 | }else if( fossil_strcmp(pChildFile->zUuid, pParentFile->zUuid)!=0 |
| 1436 | 1446 | || manifest_file_mperm(pParentFile)!=mperm ){ |
| 1437 | 1447 | /* Changes in file content or permissions */ |
| 1438 | - add_one_mlink(cid, pParentFile->zUuid, pChildFile->zUuid, | |
| 1439 | - pChildFile->zName, 0, isPublic, mperm); | |
| 1448 | + add_one_mlink(pmid, pParentFile->zUuid, mid, pChildFile->zUuid, | |
| 1449 | + pChildFile->zName, 0, isPublic, isPrim, mperm); | |
| 1440 | 1450 | } |
| 1441 | 1451 | } |
| 1442 | 1452 | } |
| 1443 | 1453 | if( pParent->zBaseline && pChild->zBaseline ){ |
| 1444 | 1454 | /* Both parent and child are delta manifests. Look for files that |
| @@ -1450,22 +1460,22 @@ | ||
| 1450 | 1460 | pChildFile = manifest_file_seek_base(pChild, pParentFile->zName, 0); |
| 1451 | 1461 | if( pChildFile==0 ){ |
| 1452 | 1462 | /* The child file reverts to baseline. Show this as a change */ |
| 1453 | 1463 | pChildFile = manifest_file_seek(pChild, pParentFile->zName, 0); |
| 1454 | 1464 | if( pChildFile ){ |
| 1455 | - add_one_mlink(cid, pParentFile->zUuid, pChildFile->zUuid, | |
| 1456 | - pChildFile->zName, 0, isPublic, | |
| 1465 | + add_one_mlink(pmid, pParentFile->zUuid, mid, pChildFile->zUuid, | |
| 1466 | + pChildFile->zName, 0, isPublic, isPrim, | |
| 1457 | 1467 | manifest_file_mperm(pChildFile)); |
| 1458 | 1468 | } |
| 1459 | 1469 | } |
| 1460 | 1470 | }else{ |
| 1461 | 1471 | pChildFile = manifest_file_seek(pChild, pParentFile->zName, 0); |
| 1462 | 1472 | if( pChildFile ){ |
| 1463 | 1473 | /* File resurrected in the child after having been deleted in |
| 1464 | 1474 | ** the parent. Show this as an added file. */ |
| 1465 | - add_one_mlink(cid, 0, pChildFile->zUuid, pChildFile->zName, 0, | |
| 1466 | - isPublic, manifest_file_mperm(pChildFile)); | |
| 1475 | + add_one_mlink(pmid, 0, mid, pChildFile->zUuid, pChildFile->zName, 0, | |
| 1476 | + isPublic, isPrim, manifest_file_mperm(pChildFile)); | |
| 1467 | 1477 | } |
| 1468 | 1478 | } |
| 1469 | 1479 | } |
| 1470 | 1480 | }else if( pChild->zBaseline==0 ){ |
| 1471 | 1481 | /* pChild is a baseline. Look for files that are present in pParent |
| @@ -1472,12 +1482,12 @@ | ||
| 1472 | 1482 | ** but are missing from pChild and mark them as having been deleted. */ |
| 1473 | 1483 | manifest_file_rewind(pParent); |
| 1474 | 1484 | while( (pParentFile = manifest_file_next(pParent,0))!=0 ){ |
| 1475 | 1485 | pChildFile = manifest_file_seek(pChild, pParentFile->zName, 0); |
| 1476 | 1486 | if( pChildFile==0 && pParentFile->zUuid!=0 ){ |
| 1477 | - add_one_mlink(cid, pParentFile->zUuid, 0, pParentFile->zName, 0, | |
| 1478 | - isPublic, 0); | |
| 1487 | + add_one_mlink(pmid, pParentFile->zUuid, mid, 0, pParentFile->zName, 0, | |
| 1488 | + isPublic, isPrim, 0); | |
| 1479 | 1489 | } |
| 1480 | 1490 | } |
| 1481 | 1491 | } |
| 1482 | 1492 | manifest_cache_insert(*ppOther); |
| 1483 | 1493 | } |
| @@ -1781,45 +1791,46 @@ | ||
| 1781 | 1791 | sqlite3_snprintf(sizeof(zBaseId), zBaseId, "%d", |
| 1782 | 1792 | uuid_to_rid(p->zBaseline,1)); |
| 1783 | 1793 | }else{ |
| 1784 | 1794 | sqlite3_snprintf(sizeof(zBaseId), zBaseId, "NULL"); |
| 1785 | 1795 | } |
| 1786 | - (void)db_schema_is_outofdate(); /* Make sure g.zAuxSchema is initialized */ | |
| 1787 | 1796 | for(i=0; i<p->nParent; i++){ |
| 1788 | 1797 | int pid = uuid_to_rid(p->azParent[i], 1); |
| 1789 | - if( strcmp(g.zAuxSchema,"2014-11-24 20:35")>=0 ){ | |
| 1790 | - /* Support for PLINK.BASEID added on 2014-11-24 */ | |
| 1791 | - db_multi_exec( | |
| 1792 | - "INSERT OR IGNORE INTO plink(pid, cid, isprim, mtime, baseid)" | |
| 1793 | - "VALUES(%d, %d, %d, %.17g, %s)", | |
| 1794 | - pid, rid, i==0, p->rDate, zBaseId/*safe-for-%s*/); | |
| 1795 | - }else{ | |
| 1796 | - /* Continue to work with older schema to avoid an unnecessary | |
| 1797 | - ** rebuild */ | |
| 1798 | - db_multi_exec( | |
| 1799 | - "INSERT OR IGNORE INTO plink(pid, cid, isprim, mtime)" | |
| 1800 | - "VALUES(%d, %d, %d, %.17g)", | |
| 1801 | - pid, rid, i==0, p->rDate); | |
| 1802 | - } | |
| 1803 | - if( i==0 ){ | |
| 1804 | - add_mlink(pid, 0, rid, p); | |
| 1805 | - parentid = pid; | |
| 1806 | - } | |
| 1807 | - } | |
| 1808 | - db_prepare(&q, "SELECT cid FROM plink WHERE pid=%d AND isprim", rid); | |
| 1798 | + db_multi_exec( | |
| 1799 | + "INSERT OR IGNORE INTO plink(pid, cid, isprim, mtime, baseid)" | |
| 1800 | + "VALUES(%d, %d, %d, %.17g, %s)", | |
| 1801 | + pid, rid, i==0, p->rDate, zBaseId/*safe-for-%s*/); | |
| 1802 | + add_mlink(pid, 0, rid, p, i==0); | |
| 1803 | + if( i==0 ) parentid = pid; | |
| 1804 | + } | |
| 1805 | + if( p->nParent>1 ){ | |
| 1806 | + /* Remove incorrect MLINK create-file entries that arise when a | |
| 1807 | + ** file is added by merge. */ | |
| 1808 | + db_multi_exec( | |
| 1809 | + "DELETE FROM mlink" | |
| 1810 | + " WHERE mid=%d" | |
| 1811 | + " AND pid=0" | |
| 1812 | + " AND fnid IN " | |
| 1813 | + " (SELECT fnid FROM mlink WHERE mid=%d GROUP BY fnid" | |
| 1814 | + " HAVING count(*)<%d)", | |
| 1815 | + rid, rid, p->nParent | |
| 1816 | + ); | |
| 1817 | + } | |
| 1818 | + db_prepare(&q, "SELECT cid, isprim FROM plink WHERE pid=%d", rid); | |
| 1809 | 1819 | while( db_step(&q)==SQLITE_ROW ){ |
| 1810 | 1820 | int cid = db_column_int(&q, 0); |
| 1811 | - add_mlink(rid, p, cid, 0); | |
| 1821 | + int isprim = db_column_int(&q, 1); | |
| 1822 | + add_mlink(rid, p, cid, 0, isprim); | |
| 1812 | 1823 | } |
| 1813 | 1824 | db_finalize(&q); |
| 1814 | 1825 | if( p->nParent==0 ){ |
| 1815 | 1826 | /* For root files (files without parents) add mlink entries |
| 1816 | 1827 | ** showing all content as new. */ |
| 1817 | 1828 | int isPublic = !content_is_private(rid); |
| 1818 | 1829 | for(i=0; i<p->nFile; i++){ |
| 1819 | - add_one_mlink(rid, 0, p->aFile[i].zUuid, p->aFile[i].zName, 0, | |
| 1820 | - isPublic, manifest_file_mperm(&p->aFile[i])); | |
| 1830 | + add_one_mlink(0, 0, rid, p->aFile[i].zUuid, p->aFile[i].zName, 0, | |
| 1831 | + isPublic, 1, manifest_file_mperm(&p->aFile[i])); | |
| 1821 | 1832 | } |
| 1822 | 1833 | } |
| 1823 | 1834 | db_multi_exec( |
| 1824 | 1835 | "REPLACE INTO event(type,mtime,objid,user,comment," |
| 1825 | 1836 | "bgcolor,euser,ecomment,omtime)" |
| 1826 | 1837 |
| --- src/manifest.c | |
| +++ src/manifest.c | |
| @@ -1187,16 +1187,18 @@ | |
| 1187 | /* |
| 1188 | ** Add a single entry to the mlink table. Also add the filename to |
| 1189 | ** the filename table if it is not there already. |
| 1190 | */ |
| 1191 | static void add_one_mlink( |
| 1192 | int mid, /* The record ID of the manifest */ |
| 1193 | const char *zFromUuid, /* UUID for the mlink.pid. "" to add file */ |
| 1194 | const char *zToUuid, /* UUID for the mlink.fid. "" to delete */ |
| 1195 | const char *zFilename, /* Filename */ |
| 1196 | const char *zPrior, /* Previous filename. NULL if unchanged */ |
| 1197 | int isPublic, /* True if mid is not a private manifest */ |
| 1198 | int mperm /* 1: exec, 2: symlink */ |
| 1199 | ){ |
| 1200 | int fnid, pfnid, pid, fid; |
| 1201 | static Stmt s1; |
| 1202 | |
| @@ -1216,19 +1218,21 @@ | |
| 1216 | }else{ |
| 1217 | fid = uuid_to_rid(zToUuid, 1); |
| 1218 | if( isPublic ) content_make_public(fid); |
| 1219 | } |
| 1220 | db_static_prepare(&s1, |
| 1221 | "INSERT INTO mlink(mid,pid,fid,fnid,pfnid,mperm)" |
| 1222 | "VALUES(:m,:p,:f,:n,:pfn,:mp)" |
| 1223 | ); |
| 1224 | db_bind_int(&s1, ":m", mid); |
| 1225 | db_bind_int(&s1, ":p", pid); |
| 1226 | db_bind_int(&s1, ":f", fid); |
| 1227 | db_bind_int(&s1, ":n", fnid); |
| 1228 | db_bind_int(&s1, ":pfn", pfnid); |
| 1229 | db_bind_int(&s1, ":mp", mperm); |
| 1230 | db_exec(&s1); |
| 1231 | if( pid && fid ){ |
| 1232 | content_deltify(pid, fid, 0); |
| 1233 | } |
| 1234 | } |
| @@ -1342,24 +1346,29 @@ | |
| 1342 | ** |
| 1343 | ** Deleted files have mlink.fid=0. |
| 1344 | ** Added files have mlink.pid=0. |
| 1345 | ** Edited files have both mlink.pid!=0 and mlink.fid!=0 |
| 1346 | */ |
| 1347 | static void add_mlink(int pid, Manifest *pParent, int cid, Manifest *pChild){ |
| 1348 | Blob otherContent; |
| 1349 | int otherRid; |
| 1350 | int i, rc; |
| 1351 | ManifestFile *pChildFile, *pParentFile; |
| 1352 | Manifest **ppOther; |
| 1353 | static Stmt eq; |
| 1354 | int isPublic; /* True if pChild is non-private */ |
| 1355 | |
| 1356 | /* If mlink table entires are already set for cid, then abort early |
| 1357 | ** doing no work. |
| 1358 | */ |
| 1359 | db_static_prepare(&eq, "SELECT 1 FROM mlink WHERE mid=:mid"); |
| 1360 | db_bind_int(&eq, ":mid", cid); |
| 1361 | rc = db_step(&eq); |
| 1362 | db_reset(&eq); |
| 1363 | if( rc==SQLITE_ROW ) return; |
| 1364 | |
| 1365 | /* Compute the value of the missing pParent or pChild parameter. |
| @@ -1366,14 +1375,14 @@ | |
| 1366 | ** Fetch the baseline checkins for both. |
| 1367 | */ |
| 1368 | assert( pParent==0 || pChild==0 ); |
| 1369 | if( pParent==0 ){ |
| 1370 | ppOther = &pParent; |
| 1371 | otherRid = pid; |
| 1372 | }else{ |
| 1373 | ppOther = &pChild; |
| 1374 | otherRid = cid; |
| 1375 | } |
| 1376 | if( (*ppOther = manifest_cache_find(otherRid))==0 ){ |
| 1377 | content_get(otherRid, &otherContent); |
| 1378 | if( blob_size(&otherContent)==0 ) return; |
| 1379 | *ppOther = manifest_parse(&otherContent, otherRid, 0); |
| @@ -1381,20 +1390,20 @@ | |
| 1381 | } |
| 1382 | if( fetch_baseline(pParent, 0) || fetch_baseline(pChild, 0) ){ |
| 1383 | manifest_destroy(*ppOther); |
| 1384 | return; |
| 1385 | } |
| 1386 | isPublic = !content_is_private(cid); |
| 1387 | |
| 1388 | /* Try to make the parent manifest a delta from the child, if that |
| 1389 | ** is an appropriate thing to do. For a new baseline, make the |
| 1390 | ** previous baseline a delta from the current baseline. |
| 1391 | */ |
| 1392 | if( (pParent->zBaseline==0)==(pChild->zBaseline==0) ){ |
| 1393 | content_deltify(pid, cid, 0); |
| 1394 | }else if( pChild->zBaseline==0 && pParent->zBaseline!=0 ){ |
| 1395 | content_deltify(pParent->pBaseline->rid, cid, 0); |
| 1396 | } |
| 1397 | |
| 1398 | /* Remember all children less than a few seconds younger than their parent, |
| 1399 | ** as we might want to fudge the times for those children. |
| 1400 | */ |
| @@ -1414,31 +1423,32 @@ | |
| 1414 | int mperm = manifest_file_mperm(pChildFile); |
| 1415 | if( pChildFile->zPrior ){ |
| 1416 | pParentFile = manifest_file_seek(pParent, pChildFile->zPrior, 0); |
| 1417 | if( pParentFile ){ |
| 1418 | /* File with name change */ |
| 1419 | add_one_mlink(cid, pParentFile->zUuid, pChildFile->zUuid, |
| 1420 | pChildFile->zName, pChildFile->zPrior, isPublic, mperm); |
| 1421 | }else{ |
| 1422 | /* File name changed, but the old name is not found in the parent! |
| 1423 | ** Treat this like a new file. */ |
| 1424 | add_one_mlink(cid, 0, pChildFile->zUuid, pChildFile->zName, 0, |
| 1425 | isPublic, mperm); |
| 1426 | } |
| 1427 | }else{ |
| 1428 | pParentFile = manifest_file_seek(pParent, pChildFile->zName, 0); |
| 1429 | if( pParentFile==0 ){ |
| 1430 | if( pChildFile->zUuid ){ |
| 1431 | /* A new file */ |
| 1432 | add_one_mlink(cid, 0, pChildFile->zUuid, pChildFile->zName, 0, |
| 1433 | isPublic, mperm); |
| 1434 | } |
| 1435 | }else if( fossil_strcmp(pChildFile->zUuid, pParentFile->zUuid)!=0 |
| 1436 | || manifest_file_mperm(pParentFile)!=mperm ){ |
| 1437 | /* Changes in file content or permissions */ |
| 1438 | add_one_mlink(cid, pParentFile->zUuid, pChildFile->zUuid, |
| 1439 | pChildFile->zName, 0, isPublic, mperm); |
| 1440 | } |
| 1441 | } |
| 1442 | } |
| 1443 | if( pParent->zBaseline && pChild->zBaseline ){ |
| 1444 | /* Both parent and child are delta manifests. Look for files that |
| @@ -1450,22 +1460,22 @@ | |
| 1450 | pChildFile = manifest_file_seek_base(pChild, pParentFile->zName, 0); |
| 1451 | if( pChildFile==0 ){ |
| 1452 | /* The child file reverts to baseline. Show this as a change */ |
| 1453 | pChildFile = manifest_file_seek(pChild, pParentFile->zName, 0); |
| 1454 | if( pChildFile ){ |
| 1455 | add_one_mlink(cid, pParentFile->zUuid, pChildFile->zUuid, |
| 1456 | pChildFile->zName, 0, isPublic, |
| 1457 | manifest_file_mperm(pChildFile)); |
| 1458 | } |
| 1459 | } |
| 1460 | }else{ |
| 1461 | pChildFile = manifest_file_seek(pChild, pParentFile->zName, 0); |
| 1462 | if( pChildFile ){ |
| 1463 | /* File resurrected in the child after having been deleted in |
| 1464 | ** the parent. Show this as an added file. */ |
| 1465 | add_one_mlink(cid, 0, pChildFile->zUuid, pChildFile->zName, 0, |
| 1466 | isPublic, manifest_file_mperm(pChildFile)); |
| 1467 | } |
| 1468 | } |
| 1469 | } |
| 1470 | }else if( pChild->zBaseline==0 ){ |
| 1471 | /* pChild is a baseline. Look for files that are present in pParent |
| @@ -1472,12 +1482,12 @@ | |
| 1472 | ** but are missing from pChild and mark them as having been deleted. */ |
| 1473 | manifest_file_rewind(pParent); |
| 1474 | while( (pParentFile = manifest_file_next(pParent,0))!=0 ){ |
| 1475 | pChildFile = manifest_file_seek(pChild, pParentFile->zName, 0); |
| 1476 | if( pChildFile==0 && pParentFile->zUuid!=0 ){ |
| 1477 | add_one_mlink(cid, pParentFile->zUuid, 0, pParentFile->zName, 0, |
| 1478 | isPublic, 0); |
| 1479 | } |
| 1480 | } |
| 1481 | } |
| 1482 | manifest_cache_insert(*ppOther); |
| 1483 | } |
| @@ -1781,45 +1791,46 @@ | |
| 1781 | sqlite3_snprintf(sizeof(zBaseId), zBaseId, "%d", |
| 1782 | uuid_to_rid(p->zBaseline,1)); |
| 1783 | }else{ |
| 1784 | sqlite3_snprintf(sizeof(zBaseId), zBaseId, "NULL"); |
| 1785 | } |
| 1786 | (void)db_schema_is_outofdate(); /* Make sure g.zAuxSchema is initialized */ |
| 1787 | for(i=0; i<p->nParent; i++){ |
| 1788 | int pid = uuid_to_rid(p->azParent[i], 1); |
| 1789 | if( strcmp(g.zAuxSchema,"2014-11-24 20:35")>=0 ){ |
| 1790 | /* Support for PLINK.BASEID added on 2014-11-24 */ |
| 1791 | db_multi_exec( |
| 1792 | "INSERT OR IGNORE INTO plink(pid, cid, isprim, mtime, baseid)" |
| 1793 | "VALUES(%d, %d, %d, %.17g, %s)", |
| 1794 | pid, rid, i==0, p->rDate, zBaseId/*safe-for-%s*/); |
| 1795 | }else{ |
| 1796 | /* Continue to work with older schema to avoid an unnecessary |
| 1797 | ** rebuild */ |
| 1798 | db_multi_exec( |
| 1799 | "INSERT OR IGNORE INTO plink(pid, cid, isprim, mtime)" |
| 1800 | "VALUES(%d, %d, %d, %.17g)", |
| 1801 | pid, rid, i==0, p->rDate); |
| 1802 | } |
| 1803 | if( i==0 ){ |
| 1804 | add_mlink(pid, 0, rid, p); |
| 1805 | parentid = pid; |
| 1806 | } |
| 1807 | } |
| 1808 | db_prepare(&q, "SELECT cid FROM plink WHERE pid=%d AND isprim", rid); |
| 1809 | while( db_step(&q)==SQLITE_ROW ){ |
| 1810 | int cid = db_column_int(&q, 0); |
| 1811 | add_mlink(rid, p, cid, 0); |
| 1812 | } |
| 1813 | db_finalize(&q); |
| 1814 | if( p->nParent==0 ){ |
| 1815 | /* For root files (files without parents) add mlink entries |
| 1816 | ** showing all content as new. */ |
| 1817 | int isPublic = !content_is_private(rid); |
| 1818 | for(i=0; i<p->nFile; i++){ |
| 1819 | add_one_mlink(rid, 0, p->aFile[i].zUuid, p->aFile[i].zName, 0, |
| 1820 | isPublic, manifest_file_mperm(&p->aFile[i])); |
| 1821 | } |
| 1822 | } |
| 1823 | db_multi_exec( |
| 1824 | "REPLACE INTO event(type,mtime,objid,user,comment," |
| 1825 | "bgcolor,euser,ecomment,omtime)" |
| 1826 |
| --- src/manifest.c | |
| +++ src/manifest.c | |
| @@ -1187,16 +1187,18 @@ | |
| 1187 | /* |
| 1188 | ** Add a single entry to the mlink table. Also add the filename to |
| 1189 | ** the filename table if it is not there already. |
| 1190 | */ |
| 1191 | static void add_one_mlink( |
| 1192 | int pmid, /* The parent manifest */ |
| 1193 | const char *zFromUuid, /* UUID for content in parent */ |
| 1194 | int mid, /* The record ID of the manifest */ |
| 1195 | const char *zToUuid, /* UUID for content in child */ |
| 1196 | const char *zFilename, /* Filename */ |
| 1197 | const char *zPrior, /* Previous filename. NULL if unchanged */ |
| 1198 | int isPublic, /* True if mid is not a private manifest */ |
| 1199 | int isPrimary, /* pmid is the primary parent of mid */ |
| 1200 | int mperm /* 1: exec, 2: symlink */ |
| 1201 | ){ |
| 1202 | int fnid, pfnid, pid, fid; |
| 1203 | static Stmt s1; |
| 1204 | |
| @@ -1216,19 +1218,21 @@ | |
| 1218 | }else{ |
| 1219 | fid = uuid_to_rid(zToUuid, 1); |
| 1220 | if( isPublic ) content_make_public(fid); |
| 1221 | } |
| 1222 | db_static_prepare(&s1, |
| 1223 | "INSERT INTO mlink(mid,fid,pmid,pid,fnid,pfnid,mperm,isaux)" |
| 1224 | "VALUES(:m,:f,:pm,:p,:n,:pfn,:mp,:isaux)" |
| 1225 | ); |
| 1226 | db_bind_int(&s1, ":m", mid); |
| 1227 | db_bind_int(&s1, ":f", fid); |
| 1228 | db_bind_int(&s1, ":pm", pmid); |
| 1229 | db_bind_int(&s1, ":p", pid); |
| 1230 | db_bind_int(&s1, ":n", fnid); |
| 1231 | db_bind_int(&s1, ":pfn", pfnid); |
| 1232 | db_bind_int(&s1, ":mp", mperm); |
| 1233 | db_bind_int(&s1, ":isaux", isPrimary==0); |
| 1234 | db_exec(&s1); |
| 1235 | if( pid && fid ){ |
| 1236 | content_deltify(pid, fid, 0); |
| 1237 | } |
| 1238 | } |
| @@ -1342,24 +1346,29 @@ | |
| 1346 | ** |
| 1347 | ** Deleted files have mlink.fid=0. |
| 1348 | ** Added files have mlink.pid=0. |
| 1349 | ** Edited files have both mlink.pid!=0 and mlink.fid!=0 |
| 1350 | */ |
| 1351 | static void add_mlink( |
| 1352 | int pmid, Manifest *pParent, /* Parent check-in */ |
| 1353 | int mid, Manifest *pChild, /* The child check-in */ |
| 1354 | int isPrim /* TRUE if pmid is the primary parent of mid */ |
| 1355 | ){ |
| 1356 | Blob otherContent; |
| 1357 | int otherRid; |
| 1358 | int i, rc; |
| 1359 | ManifestFile *pChildFile, *pParentFile; |
| 1360 | Manifest **ppOther; |
| 1361 | static Stmt eq; |
| 1362 | int isPublic; /* True if pChild is non-private */ |
| 1363 | |
| 1364 | /* If mlink table entires are already exist for the pmid-to-mid transition, |
| 1365 | ** then abort early doing no work. |
| 1366 | */ |
| 1367 | db_static_prepare(&eq, "SELECT 1 FROM mlink WHERE mid=:mid AND pmid=:pmid"); |
| 1368 | db_bind_int(&eq, ":mid", mid); |
| 1369 | db_bind_int(&eq, ":pmid", pmid); |
| 1370 | rc = db_step(&eq); |
| 1371 | db_reset(&eq); |
| 1372 | if( rc==SQLITE_ROW ) return; |
| 1373 | |
| 1374 | /* Compute the value of the missing pParent or pChild parameter. |
| @@ -1366,14 +1375,14 @@ | |
| 1375 | ** Fetch the baseline checkins for both. |
| 1376 | */ |
| 1377 | assert( pParent==0 || pChild==0 ); |
| 1378 | if( pParent==0 ){ |
| 1379 | ppOther = &pParent; |
| 1380 | otherRid = pmid; |
| 1381 | }else{ |
| 1382 | ppOther = &pChild; |
| 1383 | otherRid = mid; |
| 1384 | } |
| 1385 | if( (*ppOther = manifest_cache_find(otherRid))==0 ){ |
| 1386 | content_get(otherRid, &otherContent); |
| 1387 | if( blob_size(&otherContent)==0 ) return; |
| 1388 | *ppOther = manifest_parse(&otherContent, otherRid, 0); |
| @@ -1381,20 +1390,20 @@ | |
| 1390 | } |
| 1391 | if( fetch_baseline(pParent, 0) || fetch_baseline(pChild, 0) ){ |
| 1392 | manifest_destroy(*ppOther); |
| 1393 | return; |
| 1394 | } |
| 1395 | isPublic = !content_is_private(mid); |
| 1396 | |
| 1397 | /* Try to make the parent manifest a delta from the child, if that |
| 1398 | ** is an appropriate thing to do. For a new baseline, make the |
| 1399 | ** previous baseline a delta from the current baseline. |
| 1400 | */ |
| 1401 | if( (pParent->zBaseline==0)==(pChild->zBaseline==0) ){ |
| 1402 | content_deltify(pmid, mid, 0); |
| 1403 | }else if( pChild->zBaseline==0 && pParent->zBaseline!=0 ){ |
| 1404 | content_deltify(pParent->pBaseline->rid, mid, 0); |
| 1405 | } |
| 1406 | |
| 1407 | /* Remember all children less than a few seconds younger than their parent, |
| 1408 | ** as we might want to fudge the times for those children. |
| 1409 | */ |
| @@ -1414,31 +1423,32 @@ | |
| 1423 | int mperm = manifest_file_mperm(pChildFile); |
| 1424 | if( pChildFile->zPrior ){ |
| 1425 | pParentFile = manifest_file_seek(pParent, pChildFile->zPrior, 0); |
| 1426 | if( pParentFile ){ |
| 1427 | /* File with name change */ |
| 1428 | add_one_mlink(pmid, pParentFile->zUuid, mid, pChildFile->zUuid, |
| 1429 | pChildFile->zName, pChildFile->zPrior, |
| 1430 | isPublic, isPrim, mperm); |
| 1431 | }else{ |
| 1432 | /* File name changed, but the old name is not found in the parent! |
| 1433 | ** Treat this like a new file. */ |
| 1434 | add_one_mlink(pmid, 0, mid, pChildFile->zUuid, pChildFile->zName, 0, |
| 1435 | isPublic, isPrim, mperm); |
| 1436 | } |
| 1437 | }else{ |
| 1438 | pParentFile = manifest_file_seek(pParent, pChildFile->zName, 0); |
| 1439 | if( pParentFile==0 ){ |
| 1440 | if( pChildFile->zUuid ){ |
| 1441 | /* A new file */ |
| 1442 | add_one_mlink(pmid, 0, mid, pChildFile->zUuid, pChildFile->zName, 0, |
| 1443 | isPublic, isPrim, mperm); |
| 1444 | } |
| 1445 | }else if( fossil_strcmp(pChildFile->zUuid, pParentFile->zUuid)!=0 |
| 1446 | || manifest_file_mperm(pParentFile)!=mperm ){ |
| 1447 | /* Changes in file content or permissions */ |
| 1448 | add_one_mlink(pmid, pParentFile->zUuid, mid, pChildFile->zUuid, |
| 1449 | pChildFile->zName, 0, isPublic, isPrim, mperm); |
| 1450 | } |
| 1451 | } |
| 1452 | } |
| 1453 | if( pParent->zBaseline && pChild->zBaseline ){ |
| 1454 | /* Both parent and child are delta manifests. Look for files that |
| @@ -1450,22 +1460,22 @@ | |
| 1460 | pChildFile = manifest_file_seek_base(pChild, pParentFile->zName, 0); |
| 1461 | if( pChildFile==0 ){ |
| 1462 | /* The child file reverts to baseline. Show this as a change */ |
| 1463 | pChildFile = manifest_file_seek(pChild, pParentFile->zName, 0); |
| 1464 | if( pChildFile ){ |
| 1465 | add_one_mlink(pmid, pParentFile->zUuid, mid, pChildFile->zUuid, |
| 1466 | pChildFile->zName, 0, isPublic, isPrim, |
| 1467 | manifest_file_mperm(pChildFile)); |
| 1468 | } |
| 1469 | } |
| 1470 | }else{ |
| 1471 | pChildFile = manifest_file_seek(pChild, pParentFile->zName, 0); |
| 1472 | if( pChildFile ){ |
| 1473 | /* File resurrected in the child after having been deleted in |
| 1474 | ** the parent. Show this as an added file. */ |
| 1475 | add_one_mlink(pmid, 0, mid, pChildFile->zUuid, pChildFile->zName, 0, |
| 1476 | isPublic, isPrim, manifest_file_mperm(pChildFile)); |
| 1477 | } |
| 1478 | } |
| 1479 | } |
| 1480 | }else if( pChild->zBaseline==0 ){ |
| 1481 | /* pChild is a baseline. Look for files that are present in pParent |
| @@ -1472,12 +1482,12 @@ | |
| 1482 | ** but are missing from pChild and mark them as having been deleted. */ |
| 1483 | manifest_file_rewind(pParent); |
| 1484 | while( (pParentFile = manifest_file_next(pParent,0))!=0 ){ |
| 1485 | pChildFile = manifest_file_seek(pChild, pParentFile->zName, 0); |
| 1486 | if( pChildFile==0 && pParentFile->zUuid!=0 ){ |
| 1487 | add_one_mlink(pmid, pParentFile->zUuid, mid, 0, pParentFile->zName, 0, |
| 1488 | isPublic, isPrim, 0); |
| 1489 | } |
| 1490 | } |
| 1491 | } |
| 1492 | manifest_cache_insert(*ppOther); |
| 1493 | } |
| @@ -1781,45 +1791,46 @@ | |
| 1791 | sqlite3_snprintf(sizeof(zBaseId), zBaseId, "%d", |
| 1792 | uuid_to_rid(p->zBaseline,1)); |
| 1793 | }else{ |
| 1794 | sqlite3_snprintf(sizeof(zBaseId), zBaseId, "NULL"); |
| 1795 | } |
| 1796 | for(i=0; i<p->nParent; i++){ |
| 1797 | int pid = uuid_to_rid(p->azParent[i], 1); |
| 1798 | db_multi_exec( |
| 1799 | "INSERT OR IGNORE INTO plink(pid, cid, isprim, mtime, baseid)" |
| 1800 | "VALUES(%d, %d, %d, %.17g, %s)", |
| 1801 | pid, rid, i==0, p->rDate, zBaseId/*safe-for-%s*/); |
| 1802 | add_mlink(pid, 0, rid, p, i==0); |
| 1803 | if( i==0 ) parentid = pid; |
| 1804 | } |
| 1805 | if( p->nParent>1 ){ |
| 1806 | /* Remove incorrect MLINK create-file entries that arise when a |
| 1807 | ** file is added by merge. */ |
| 1808 | db_multi_exec( |
| 1809 | "DELETE FROM mlink" |
| 1810 | " WHERE mid=%d" |
| 1811 | " AND pid=0" |
| 1812 | " AND fnid IN " |
| 1813 | " (SELECT fnid FROM mlink WHERE mid=%d GROUP BY fnid" |
| 1814 | " HAVING count(*)<%d)", |
| 1815 | rid, rid, p->nParent |
| 1816 | ); |
| 1817 | } |
| 1818 | db_prepare(&q, "SELECT cid, isprim FROM plink WHERE pid=%d", rid); |
| 1819 | while( db_step(&q)==SQLITE_ROW ){ |
| 1820 | int cid = db_column_int(&q, 0); |
| 1821 | int isprim = db_column_int(&q, 1); |
| 1822 | add_mlink(rid, p, cid, 0, isprim); |
| 1823 | } |
| 1824 | db_finalize(&q); |
| 1825 | if( p->nParent==0 ){ |
| 1826 | /* For root files (files without parents) add mlink entries |
| 1827 | ** showing all content as new. */ |
| 1828 | int isPublic = !content_is_private(rid); |
| 1829 | for(i=0; i<p->nFile; i++){ |
| 1830 | add_one_mlink(0, 0, rid, p->aFile[i].zUuid, p->aFile[i].zName, 0, |
| 1831 | isPublic, 1, manifest_file_mperm(&p->aFile[i])); |
| 1832 | } |
| 1833 | } |
| 1834 | db_multi_exec( |
| 1835 | "REPLACE INTO event(type,mtime,objid,user,comment," |
| 1836 | "bgcolor,euser,ecomment,omtime)" |
| 1837 |
+30
-7
| --- src/schema.c | ||
| +++ src/schema.c | ||
| @@ -45,11 +45,14 @@ | ||
| 45 | 45 | ** we have to execute special procedures to update the schema. When |
| 46 | 46 | ** the aux schema changes, all we need to do is rebuild the database. |
| 47 | 47 | */ |
| 48 | 48 | #define CONTENT_SCHEMA "2" |
| 49 | 49 | #define AUX_SCHEMA_MIN "2011-04-25 19:50" |
| 50 | -#define AUX_SCHEMA_MAX "2014-11-24 20:35" | |
| 50 | +#define AUX_SCHEMA_MAX "2015-01-24" | |
| 51 | +/* NB: Some features require the latest schema. Warning or error messages | |
| 52 | +** will appear if an older schema is used. However, the older schemas are | |
| 53 | +** adequate for many common functions. */ | |
| 51 | 54 | |
| 52 | 55 | #endif /* INTERFACE */ |
| 53 | 56 | |
| 54 | 57 | |
| 55 | 58 | /* |
| @@ -227,21 +230,41 @@ | ||
| 227 | 230 | @ name TEXT UNIQUE -- Name of file page |
| 228 | 231 | @ ); |
| 229 | 232 | @ |
| 230 | 233 | @ -- Linkages between checkins, files created by each checkin, and |
| 231 | 234 | @ -- the names of those files. |
| 235 | +@ -- | |
| 236 | +@ -- Each entry represents a file that changed content from pid to fid | |
| 237 | +@ -- due to the check-in that goes from pmid to mid. fnid is the name | |
| 238 | +@ -- of the file in the mid check-in. If the file was renamed as part | |
| 239 | +@ -- of the mid check-in, then pfnid is the previous filename. | |
| 240 | +@ | |
| 241 | +@ -- There can be multiple entries for (mid,fid) if the mid checkin was | |
| 242 | +@ -- a merge. Entries with isaux==0 are from the primary parent. Merge | |
| 243 | +@ -- parents have isaux set to true. | |
| 244 | +@ -- | |
| 245 | +@ -- Field name mnemonics: | |
| 246 | +@ -- mid = Manifest ID. (Each check-in is stored as a "Manifest") | |
| 247 | +@ -- fid = File ID. | |
| 248 | +@ -- pmid = Parent Manifest ID. | |
| 249 | +@ -- pid = Parent file ID. | |
| 250 | +@ -- fnid = File Name ID. | |
| 251 | +@ -- pfnid = Parent File Name ID. | |
| 252 | +@ -- isaux = pmid IS AUXiliary parent, not primary parent | |
| 232 | 253 | @ -- |
| 233 | 254 | @ -- pid==0 if the file is added by checkin mid. |
| 234 | 255 | @ -- fid==0 if the file is removed by checkin mid. |
| 235 | 256 | @ -- |
| 236 | 257 | @ CREATE TABLE mlink( |
| 237 | -@ mid INTEGER REFERENCES blob, -- Manifest ID where change occurs | |
| 238 | -@ pid INTEGER REFERENCES blob, -- File ID in parent manifest | |
| 239 | -@ fid INTEGER REFERENCES blob, -- Changed file ID in this manifest | |
| 258 | +@ mid INTEGER REFERENCES plink(cid), -- Checkin that contains fid | |
| 259 | +@ fid INTEGER REFERENCES blob, -- New file content. 0 if deleted | |
| 260 | +@ pmid INTEGER REFERENCES plink(cid), -- Checkin that contains pid | |
| 261 | +@ pid INTEGER REFERENCES blob, -- Prev file content. 0 if new | |
| 240 | 262 | @ fnid INTEGER REFERENCES filename, -- Name of the file |
| 241 | 263 | @ pfnid INTEGER REFERENCES filename, -- Previous name. 0 if unchanged |
| 242 | -@ mperm INTEGER -- File permissions. 1==exec | |
| 264 | +@ mperm INTEGER, -- File permissions. 1==exec | |
| 265 | +@ isaux BOOLEAN DEFAULT 0 -- TRUE if pmid is the primary | |
| 243 | 266 | @ ); |
| 244 | 267 | @ CREATE INDEX mlink_i1 ON mlink(mid); |
| 245 | 268 | @ CREATE INDEX mlink_i2 ON mlink(fnid); |
| 246 | 269 | @ CREATE INDEX mlink_i3 ON mlink(fid); |
| 247 | 270 | @ CREATE INDEX mlink_i4 ON mlink(pid); |
| @@ -251,11 +274,11 @@ | ||
| 251 | 274 | @ CREATE TABLE plink( |
| 252 | 275 | @ pid INTEGER REFERENCES blob, -- Parent manifest |
| 253 | 276 | @ cid INTEGER REFERENCES blob, -- Child manifest |
| 254 | 277 | @ isprim BOOLEAN, -- pid is the primary parent of cid |
| 255 | 278 | @ mtime DATETIME, -- the date/time stamp on cid. Julian day. |
| 256 | -@ baseid INTEGER REFERENCES blob, -- Baseline if child is a delta manifest | |
| 279 | +@ baseid INTEGER REFERENCES blob, -- Baseline if cid is a delta manifest. | |
| 257 | 280 | @ UNIQUE(pid, cid) |
| 258 | 281 | @ ); |
| 259 | 282 | @ CREATE INDEX plink_i2 ON plink(cid,pid); |
| 260 | 283 | @ |
| 261 | 284 | @ -- A "leaf" checkin is a checkin that has no children in the same |
| @@ -488,11 +511,11 @@ | ||
| 488 | 511 | @ -- current version of the file is already in the repository. |
| 489 | 512 | @ -- |
| 490 | 513 | @ CREATE TABLE vfile( |
| 491 | 514 | @ id INTEGER PRIMARY KEY, -- ID of the checked out file |
| 492 | 515 | @ vid INTEGER REFERENCES blob, -- The baseline this file is part of. |
| 493 | -@ chnged INT DEFAULT 0, -- 0:unchnged 1:edited 2:m-chng 3:m-add 4:i-chng 5:i-add | |
| 516 | +@ chnged INT DEFAULT 0, -- 0:unchng 1:edit 2:m-chng 3:m-add 4:i-chng 5:i-add | |
| 494 | 517 | @ deleted BOOLEAN DEFAULT 0, -- True if deleted |
| 495 | 518 | @ isexe BOOLEAN, -- True if file should be executable |
| 496 | 519 | @ islink BOOLEAN, -- True if file should be symlink |
| 497 | 520 | @ rid INTEGER, -- Originally from this repository record |
| 498 | 521 | @ mrid INTEGER, -- Based on this record due to a merge |
| 499 | 522 |
| --- src/schema.c | |
| +++ src/schema.c | |
| @@ -45,11 +45,14 @@ | |
| 45 | ** we have to execute special procedures to update the schema. When |
| 46 | ** the aux schema changes, all we need to do is rebuild the database. |
| 47 | */ |
| 48 | #define CONTENT_SCHEMA "2" |
| 49 | #define AUX_SCHEMA_MIN "2011-04-25 19:50" |
| 50 | #define AUX_SCHEMA_MAX "2014-11-24 20:35" |
| 51 | |
| 52 | #endif /* INTERFACE */ |
| 53 | |
| 54 | |
| 55 | /* |
| @@ -227,21 +230,41 @@ | |
| 227 | @ name TEXT UNIQUE -- Name of file page |
| 228 | @ ); |
| 229 | @ |
| 230 | @ -- Linkages between checkins, files created by each checkin, and |
| 231 | @ -- the names of those files. |
| 232 | @ -- |
| 233 | @ -- pid==0 if the file is added by checkin mid. |
| 234 | @ -- fid==0 if the file is removed by checkin mid. |
| 235 | @ -- |
| 236 | @ CREATE TABLE mlink( |
| 237 | @ mid INTEGER REFERENCES blob, -- Manifest ID where change occurs |
| 238 | @ pid INTEGER REFERENCES blob, -- File ID in parent manifest |
| 239 | @ fid INTEGER REFERENCES blob, -- Changed file ID in this manifest |
| 240 | @ fnid INTEGER REFERENCES filename, -- Name of the file |
| 241 | @ pfnid INTEGER REFERENCES filename, -- Previous name. 0 if unchanged |
| 242 | @ mperm INTEGER -- File permissions. 1==exec |
| 243 | @ ); |
| 244 | @ CREATE INDEX mlink_i1 ON mlink(mid); |
| 245 | @ CREATE INDEX mlink_i2 ON mlink(fnid); |
| 246 | @ CREATE INDEX mlink_i3 ON mlink(fid); |
| 247 | @ CREATE INDEX mlink_i4 ON mlink(pid); |
| @@ -251,11 +274,11 @@ | |
| 251 | @ CREATE TABLE plink( |
| 252 | @ pid INTEGER REFERENCES blob, -- Parent manifest |
| 253 | @ cid INTEGER REFERENCES blob, -- Child manifest |
| 254 | @ isprim BOOLEAN, -- pid is the primary parent of cid |
| 255 | @ mtime DATETIME, -- the date/time stamp on cid. Julian day. |
| 256 | @ baseid INTEGER REFERENCES blob, -- Baseline if child is a delta manifest |
| 257 | @ UNIQUE(pid, cid) |
| 258 | @ ); |
| 259 | @ CREATE INDEX plink_i2 ON plink(cid,pid); |
| 260 | @ |
| 261 | @ -- A "leaf" checkin is a checkin that has no children in the same |
| @@ -488,11 +511,11 @@ | |
| 488 | @ -- current version of the file is already in the repository. |
| 489 | @ -- |
| 490 | @ CREATE TABLE vfile( |
| 491 | @ id INTEGER PRIMARY KEY, -- ID of the checked out file |
| 492 | @ vid INTEGER REFERENCES blob, -- The baseline this file is part of. |
| 493 | @ chnged INT DEFAULT 0, -- 0:unchnged 1:edited 2:m-chng 3:m-add 4:i-chng 5:i-add |
| 494 | @ deleted BOOLEAN DEFAULT 0, -- True if deleted |
| 495 | @ isexe BOOLEAN, -- True if file should be executable |
| 496 | @ islink BOOLEAN, -- True if file should be symlink |
| 497 | @ rid INTEGER, -- Originally from this repository record |
| 498 | @ mrid INTEGER, -- Based on this record due to a merge |
| 499 |
| --- src/schema.c | |
| +++ src/schema.c | |
| @@ -45,11 +45,14 @@ | |
| 45 | ** we have to execute special procedures to update the schema. When |
| 46 | ** the aux schema changes, all we need to do is rebuild the database. |
| 47 | */ |
| 48 | #define CONTENT_SCHEMA "2" |
| 49 | #define AUX_SCHEMA_MIN "2011-04-25 19:50" |
| 50 | #define AUX_SCHEMA_MAX "2015-01-24" |
| 51 | /* NB: Some features require the latest schema. Warning or error messages |
| 52 | ** will appear if an older schema is used. However, the older schemas are |
| 53 | ** adequate for many common functions. */ |
| 54 | |
| 55 | #endif /* INTERFACE */ |
| 56 | |
| 57 | |
| 58 | /* |
| @@ -227,21 +230,41 @@ | |
| 230 | @ name TEXT UNIQUE -- Name of file page |
| 231 | @ ); |
| 232 | @ |
| 233 | @ -- Linkages between checkins, files created by each checkin, and |
| 234 | @ -- the names of those files. |
| 235 | @ -- |
| 236 | @ -- Each entry represents a file that changed content from pid to fid |
| 237 | @ -- due to the check-in that goes from pmid to mid. fnid is the name |
| 238 | @ -- of the file in the mid check-in. If the file was renamed as part |
| 239 | @ -- of the mid check-in, then pfnid is the previous filename. |
| 240 | @ |
| 241 | @ -- There can be multiple entries for (mid,fid) if the mid checkin was |
| 242 | @ -- a merge. Entries with isaux==0 are from the primary parent. Merge |
| 243 | @ -- parents have isaux set to true. |
| 244 | @ -- |
| 245 | @ -- Field name mnemonics: |
| 246 | @ -- mid = Manifest ID. (Each check-in is stored as a "Manifest") |
| 247 | @ -- fid = File ID. |
| 248 | @ -- pmid = Parent Manifest ID. |
| 249 | @ -- pid = Parent file ID. |
| 250 | @ -- fnid = File Name ID. |
| 251 | @ -- pfnid = Parent File Name ID. |
| 252 | @ -- isaux = pmid IS AUXiliary parent, not primary parent |
| 253 | @ -- |
| 254 | @ -- pid==0 if the file is added by checkin mid. |
| 255 | @ -- fid==0 if the file is removed by checkin mid. |
| 256 | @ -- |
| 257 | @ CREATE TABLE mlink( |
| 258 | @ mid INTEGER REFERENCES plink(cid), -- Checkin that contains fid |
| 259 | @ fid INTEGER REFERENCES blob, -- New file content. 0 if deleted |
| 260 | @ pmid INTEGER REFERENCES plink(cid), -- Checkin that contains pid |
| 261 | @ pid INTEGER REFERENCES blob, -- Prev file content. 0 if new |
| 262 | @ fnid INTEGER REFERENCES filename, -- Name of the file |
| 263 | @ pfnid INTEGER REFERENCES filename, -- Previous name. 0 if unchanged |
| 264 | @ mperm INTEGER, -- File permissions. 1==exec |
| 265 | @ isaux BOOLEAN DEFAULT 0 -- TRUE if pmid is the primary |
| 266 | @ ); |
| 267 | @ CREATE INDEX mlink_i1 ON mlink(mid); |
| 268 | @ CREATE INDEX mlink_i2 ON mlink(fnid); |
| 269 | @ CREATE INDEX mlink_i3 ON mlink(fid); |
| 270 | @ CREATE INDEX mlink_i4 ON mlink(pid); |
| @@ -251,11 +274,11 @@ | |
| 274 | @ CREATE TABLE plink( |
| 275 | @ pid INTEGER REFERENCES blob, -- Parent manifest |
| 276 | @ cid INTEGER REFERENCES blob, -- Child manifest |
| 277 | @ isprim BOOLEAN, -- pid is the primary parent of cid |
| 278 | @ mtime DATETIME, -- the date/time stamp on cid. Julian day. |
| 279 | @ baseid INTEGER REFERENCES blob, -- Baseline if cid is a delta manifest. |
| 280 | @ UNIQUE(pid, cid) |
| 281 | @ ); |
| 282 | @ CREATE INDEX plink_i2 ON plink(cid,pid); |
| 283 | @ |
| 284 | @ -- A "leaf" checkin is a checkin that has no children in the same |
| @@ -488,11 +511,11 @@ | |
| 511 | @ -- current version of the file is already in the repository. |
| 512 | @ -- |
| 513 | @ CREATE TABLE vfile( |
| 514 | @ id INTEGER PRIMARY KEY, -- ID of the checked out file |
| 515 | @ vid INTEGER REFERENCES blob, -- The baseline this file is part of. |
| 516 | @ chnged INT DEFAULT 0, -- 0:unchng 1:edit 2:m-chng 3:m-add 4:i-chng 5:i-add |
| 517 | @ deleted BOOLEAN DEFAULT 0, -- True if deleted |
| 518 | @ isexe BOOLEAN, -- True if file should be executable |
| 519 | @ islink BOOLEAN, -- True if file should be symlink |
| 520 | @ rid INTEGER, -- Originally from this repository record |
| 521 | @ mrid INTEGER, -- Based on this record due to a merge |
| 522 |
+30
-7
| --- src/schema.c | ||
| +++ src/schema.c | ||
| @@ -45,11 +45,14 @@ | ||
| 45 | 45 | ** we have to execute special procedures to update the schema. When |
| 46 | 46 | ** the aux schema changes, all we need to do is rebuild the database. |
| 47 | 47 | */ |
| 48 | 48 | #define CONTENT_SCHEMA "2" |
| 49 | 49 | #define AUX_SCHEMA_MIN "2011-04-25 19:50" |
| 50 | -#define AUX_SCHEMA_MAX "2014-11-24 20:35" | |
| 50 | +#define AUX_SCHEMA_MAX "2015-01-24" | |
| 51 | +/* NB: Some features require the latest schema. Warning or error messages | |
| 52 | +** will appear if an older schema is used. However, the older schemas are | |
| 53 | +** adequate for many common functions. */ | |
| 51 | 54 | |
| 52 | 55 | #endif /* INTERFACE */ |
| 53 | 56 | |
| 54 | 57 | |
| 55 | 58 | /* |
| @@ -227,21 +230,41 @@ | ||
| 227 | 230 | @ name TEXT UNIQUE -- Name of file page |
| 228 | 231 | @ ); |
| 229 | 232 | @ |
| 230 | 233 | @ -- Linkages between checkins, files created by each checkin, and |
| 231 | 234 | @ -- the names of those files. |
| 235 | +@ -- | |
| 236 | +@ -- Each entry represents a file that changed content from pid to fid | |
| 237 | +@ -- due to the check-in that goes from pmid to mid. fnid is the name | |
| 238 | +@ -- of the file in the mid check-in. If the file was renamed as part | |
| 239 | +@ -- of the mid check-in, then pfnid is the previous filename. | |
| 240 | +@ | |
| 241 | +@ -- There can be multiple entries for (mid,fid) if the mid checkin was | |
| 242 | +@ -- a merge. Entries with isaux==0 are from the primary parent. Merge | |
| 243 | +@ -- parents have isaux set to true. | |
| 244 | +@ -- | |
| 245 | +@ -- Field name mnemonics: | |
| 246 | +@ -- mid = Manifest ID. (Each check-in is stored as a "Manifest") | |
| 247 | +@ -- fid = File ID. | |
| 248 | +@ -- pmid = Parent Manifest ID. | |
| 249 | +@ -- pid = Parent file ID. | |
| 250 | +@ -- fnid = File Name ID. | |
| 251 | +@ -- pfnid = Parent File Name ID. | |
| 252 | +@ -- isaux = pmid IS AUXiliary parent, not primary parent | |
| 232 | 253 | @ -- |
| 233 | 254 | @ -- pid==0 if the file is added by checkin mid. |
| 234 | 255 | @ -- fid==0 if the file is removed by checkin mid. |
| 235 | 256 | @ -- |
| 236 | 257 | @ CREATE TABLE mlink( |
| 237 | -@ mid INTEGER REFERENCES blob, -- Manifest ID where change occurs | |
| 238 | -@ pid INTEGER REFERENCES blob, -- File ID in parent manifest | |
| 239 | -@ fid INTEGER REFERENCES blob, -- Changed file ID in this manifest | |
| 258 | +@ mid INTEGER REFERENCES plink(cid), -- Checkin that contains fid | |
| 259 | +@ fid INTEGER REFERENCES blob, -- New file content. 0 if deleted | |
| 260 | +@ pmid INTEGER REFERENCES plink(cid), -- Checkin that contains pid | |
| 261 | +@ pid INTEGER REFERENCES blob, -- Prev file content. 0 if new | |
| 240 | 262 | @ fnid INTEGER REFERENCES filename, -- Name of the file |
| 241 | 263 | @ pfnid INTEGER REFERENCES filename, -- Previous name. 0 if unchanged |
| 242 | -@ mperm INTEGER -- File permissions. 1==exec | |
| 264 | +@ mperm INTEGER, -- File permissions. 1==exec | |
| 265 | +@ isaux BOOLEAN DEFAULT 0 -- TRUE if pmid is the primary | |
| 243 | 266 | @ ); |
| 244 | 267 | @ CREATE INDEX mlink_i1 ON mlink(mid); |
| 245 | 268 | @ CREATE INDEX mlink_i2 ON mlink(fnid); |
| 246 | 269 | @ CREATE INDEX mlink_i3 ON mlink(fid); |
| 247 | 270 | @ CREATE INDEX mlink_i4 ON mlink(pid); |
| @@ -251,11 +274,11 @@ | ||
| 251 | 274 | @ CREATE TABLE plink( |
| 252 | 275 | @ pid INTEGER REFERENCES blob, -- Parent manifest |
| 253 | 276 | @ cid INTEGER REFERENCES blob, -- Child manifest |
| 254 | 277 | @ isprim BOOLEAN, -- pid is the primary parent of cid |
| 255 | 278 | @ mtime DATETIME, -- the date/time stamp on cid. Julian day. |
| 256 | -@ baseid INTEGER REFERENCES blob, -- Baseline if child is a delta manifest | |
| 279 | +@ baseid INTEGER REFERENCES blob, -- Baseline if cid is a delta manifest. | |
| 257 | 280 | @ UNIQUE(pid, cid) |
| 258 | 281 | @ ); |
| 259 | 282 | @ CREATE INDEX plink_i2 ON plink(cid,pid); |
| 260 | 283 | @ |
| 261 | 284 | @ -- A "leaf" checkin is a checkin that has no children in the same |
| @@ -488,11 +511,11 @@ | ||
| 488 | 511 | @ -- current version of the file is already in the repository. |
| 489 | 512 | @ -- |
| 490 | 513 | @ CREATE TABLE vfile( |
| 491 | 514 | @ id INTEGER PRIMARY KEY, -- ID of the checked out file |
| 492 | 515 | @ vid INTEGER REFERENCES blob, -- The baseline this file is part of. |
| 493 | -@ chnged INT DEFAULT 0, -- 0:unchnged 1:edited 2:m-chng 3:m-add 4:i-chng 5:i-add | |
| 516 | +@ chnged INT DEFAULT 0, -- 0:unchng 1:edit 2:m-chng 3:m-add 4:i-chng 5:i-add | |
| 494 | 517 | @ deleted BOOLEAN DEFAULT 0, -- True if deleted |
| 495 | 518 | @ isexe BOOLEAN, -- True if file should be executable |
| 496 | 519 | @ islink BOOLEAN, -- True if file should be symlink |
| 497 | 520 | @ rid INTEGER, -- Originally from this repository record |
| 498 | 521 | @ mrid INTEGER, -- Based on this record due to a merge |
| 499 | 522 |
| --- src/schema.c | |
| +++ src/schema.c | |
| @@ -45,11 +45,14 @@ | |
| 45 | ** we have to execute special procedures to update the schema. When |
| 46 | ** the aux schema changes, all we need to do is rebuild the database. |
| 47 | */ |
| 48 | #define CONTENT_SCHEMA "2" |
| 49 | #define AUX_SCHEMA_MIN "2011-04-25 19:50" |
| 50 | #define AUX_SCHEMA_MAX "2014-11-24 20:35" |
| 51 | |
| 52 | #endif /* INTERFACE */ |
| 53 | |
| 54 | |
| 55 | /* |
| @@ -227,21 +230,41 @@ | |
| 227 | @ name TEXT UNIQUE -- Name of file page |
| 228 | @ ); |
| 229 | @ |
| 230 | @ -- Linkages between checkins, files created by each checkin, and |
| 231 | @ -- the names of those files. |
| 232 | @ -- |
| 233 | @ -- pid==0 if the file is added by checkin mid. |
| 234 | @ -- fid==0 if the file is removed by checkin mid. |
| 235 | @ -- |
| 236 | @ CREATE TABLE mlink( |
| 237 | @ mid INTEGER REFERENCES blob, -- Manifest ID where change occurs |
| 238 | @ pid INTEGER REFERENCES blob, -- File ID in parent manifest |
| 239 | @ fid INTEGER REFERENCES blob, -- Changed file ID in this manifest |
| 240 | @ fnid INTEGER REFERENCES filename, -- Name of the file |
| 241 | @ pfnid INTEGER REFERENCES filename, -- Previous name. 0 if unchanged |
| 242 | @ mperm INTEGER -- File permissions. 1==exec |
| 243 | @ ); |
| 244 | @ CREATE INDEX mlink_i1 ON mlink(mid); |
| 245 | @ CREATE INDEX mlink_i2 ON mlink(fnid); |
| 246 | @ CREATE INDEX mlink_i3 ON mlink(fid); |
| 247 | @ CREATE INDEX mlink_i4 ON mlink(pid); |
| @@ -251,11 +274,11 @@ | |
| 251 | @ CREATE TABLE plink( |
| 252 | @ pid INTEGER REFERENCES blob, -- Parent manifest |
| 253 | @ cid INTEGER REFERENCES blob, -- Child manifest |
| 254 | @ isprim BOOLEAN, -- pid is the primary parent of cid |
| 255 | @ mtime DATETIME, -- the date/time stamp on cid. Julian day. |
| 256 | @ baseid INTEGER REFERENCES blob, -- Baseline if child is a delta manifest |
| 257 | @ UNIQUE(pid, cid) |
| 258 | @ ); |
| 259 | @ CREATE INDEX plink_i2 ON plink(cid,pid); |
| 260 | @ |
| 261 | @ -- A "leaf" checkin is a checkin that has no children in the same |
| @@ -488,11 +511,11 @@ | |
| 488 | @ -- current version of the file is already in the repository. |
| 489 | @ -- |
| 490 | @ CREATE TABLE vfile( |
| 491 | @ id INTEGER PRIMARY KEY, -- ID of the checked out file |
| 492 | @ vid INTEGER REFERENCES blob, -- The baseline this file is part of. |
| 493 | @ chnged INT DEFAULT 0, -- 0:unchnged 1:edited 2:m-chng 3:m-add 4:i-chng 5:i-add |
| 494 | @ deleted BOOLEAN DEFAULT 0, -- True if deleted |
| 495 | @ isexe BOOLEAN, -- True if file should be executable |
| 496 | @ islink BOOLEAN, -- True if file should be symlink |
| 497 | @ rid INTEGER, -- Originally from this repository record |
| 498 | @ mrid INTEGER, -- Based on this record due to a merge |
| 499 |
| --- src/schema.c | |
| +++ src/schema.c | |
| @@ -45,11 +45,14 @@ | |
| 45 | ** we have to execute special procedures to update the schema. When |
| 46 | ** the aux schema changes, all we need to do is rebuild the database. |
| 47 | */ |
| 48 | #define CONTENT_SCHEMA "2" |
| 49 | #define AUX_SCHEMA_MIN "2011-04-25 19:50" |
| 50 | #define AUX_SCHEMA_MAX "2015-01-24" |
| 51 | /* NB: Some features require the latest schema. Warning or error messages |
| 52 | ** will appear if an older schema is used. However, the older schemas are |
| 53 | ** adequate for many common functions. */ |
| 54 | |
| 55 | #endif /* INTERFACE */ |
| 56 | |
| 57 | |
| 58 | /* |
| @@ -227,21 +230,41 @@ | |
| 230 | @ name TEXT UNIQUE -- Name of file page |
| 231 | @ ); |
| 232 | @ |
| 233 | @ -- Linkages between checkins, files created by each checkin, and |
| 234 | @ -- the names of those files. |
| 235 | @ -- |
| 236 | @ -- Each entry represents a file that changed content from pid to fid |
| 237 | @ -- due to the check-in that goes from pmid to mid. fnid is the name |
| 238 | @ -- of the file in the mid check-in. If the file was renamed as part |
| 239 | @ -- of the mid check-in, then pfnid is the previous filename. |
| 240 | @ |
| 241 | @ -- There can be multiple entries for (mid,fid) if the mid checkin was |
| 242 | @ -- a merge. Entries with isaux==0 are from the primary parent. Merge |
| 243 | @ -- parents have isaux set to true. |
| 244 | @ -- |
| 245 | @ -- Field name mnemonics: |
| 246 | @ -- mid = Manifest ID. (Each check-in is stored as a "Manifest") |
| 247 | @ -- fid = File ID. |
| 248 | @ -- pmid = Parent Manifest ID. |
| 249 | @ -- pid = Parent file ID. |
| 250 | @ -- fnid = File Name ID. |
| 251 | @ -- pfnid = Parent File Name ID. |
| 252 | @ -- isaux = pmid IS AUXiliary parent, not primary parent |
| 253 | @ -- |
| 254 | @ -- pid==0 if the file is added by checkin mid. |
| 255 | @ -- fid==0 if the file is removed by checkin mid. |
| 256 | @ -- |
| 257 | @ CREATE TABLE mlink( |
| 258 | @ mid INTEGER REFERENCES plink(cid), -- Checkin that contains fid |
| 259 | @ fid INTEGER REFERENCES blob, -- New file content. 0 if deleted |
| 260 | @ pmid INTEGER REFERENCES plink(cid), -- Checkin that contains pid |
| 261 | @ pid INTEGER REFERENCES blob, -- Prev file content. 0 if new |
| 262 | @ fnid INTEGER REFERENCES filename, -- Name of the file |
| 263 | @ pfnid INTEGER REFERENCES filename, -- Previous name. 0 if unchanged |
| 264 | @ mperm INTEGER, -- File permissions. 1==exec |
| 265 | @ isaux BOOLEAN DEFAULT 0 -- TRUE if pmid is the primary |
| 266 | @ ); |
| 267 | @ CREATE INDEX mlink_i1 ON mlink(mid); |
| 268 | @ CREATE INDEX mlink_i2 ON mlink(fnid); |
| 269 | @ CREATE INDEX mlink_i3 ON mlink(fid); |
| 270 | @ CREATE INDEX mlink_i4 ON mlink(pid); |
| @@ -251,11 +274,11 @@ | |
| 274 | @ CREATE TABLE plink( |
| 275 | @ pid INTEGER REFERENCES blob, -- Parent manifest |
| 276 | @ cid INTEGER REFERENCES blob, -- Child manifest |
| 277 | @ isprim BOOLEAN, -- pid is the primary parent of cid |
| 278 | @ mtime DATETIME, -- the date/time stamp on cid. Julian day. |
| 279 | @ baseid INTEGER REFERENCES blob, -- Baseline if cid is a delta manifest. |
| 280 | @ UNIQUE(pid, cid) |
| 281 | @ ); |
| 282 | @ CREATE INDEX plink_i2 ON plink(cid,pid); |
| 283 | @ |
| 284 | @ -- A "leaf" checkin is a checkin that has no children in the same |
| @@ -488,11 +511,11 @@ | |
| 511 | @ -- current version of the file is already in the repository. |
| 512 | @ -- |
| 513 | @ CREATE TABLE vfile( |
| 514 | @ id INTEGER PRIMARY KEY, -- ID of the checked out file |
| 515 | @ vid INTEGER REFERENCES blob, -- The baseline this file is part of. |
| 516 | @ chnged INT DEFAULT 0, -- 0:unchng 1:edit 2:m-chng 3:m-add 4:i-chng 5:i-add |
| 517 | @ deleted BOOLEAN DEFAULT 0, -- True if deleted |
| 518 | @ isexe BOOLEAN, -- True if file should be executable |
| 519 | @ islink BOOLEAN, -- True if file should be symlink |
| 520 | @ rid INTEGER, -- Originally from this repository record |
| 521 | @ mrid INTEGER, -- Based on this record due to a merge |
| 522 |
+30
-7
| --- src/schema.c | ||
| +++ src/schema.c | ||
| @@ -45,11 +45,14 @@ | ||
| 45 | 45 | ** we have to execute special procedures to update the schema. When |
| 46 | 46 | ** the aux schema changes, all we need to do is rebuild the database. |
| 47 | 47 | */ |
| 48 | 48 | #define CONTENT_SCHEMA "2" |
| 49 | 49 | #define AUX_SCHEMA_MIN "2011-04-25 19:50" |
| 50 | -#define AUX_SCHEMA_MAX "2014-11-24 20:35" | |
| 50 | +#define AUX_SCHEMA_MAX "2015-01-24" | |
| 51 | +/* NB: Some features require the latest schema. Warning or error messages | |
| 52 | +** will appear if an older schema is used. However, the older schemas are | |
| 53 | +** adequate for many common functions. */ | |
| 51 | 54 | |
| 52 | 55 | #endif /* INTERFACE */ |
| 53 | 56 | |
| 54 | 57 | |
| 55 | 58 | /* |
| @@ -227,21 +230,41 @@ | ||
| 227 | 230 | @ name TEXT UNIQUE -- Name of file page |
| 228 | 231 | @ ); |
| 229 | 232 | @ |
| 230 | 233 | @ -- Linkages between checkins, files created by each checkin, and |
| 231 | 234 | @ -- the names of those files. |
| 235 | +@ -- | |
| 236 | +@ -- Each entry represents a file that changed content from pid to fid | |
| 237 | +@ -- due to the check-in that goes from pmid to mid. fnid is the name | |
| 238 | +@ -- of the file in the mid check-in. If the file was renamed as part | |
| 239 | +@ -- of the mid check-in, then pfnid is the previous filename. | |
| 240 | +@ | |
| 241 | +@ -- There can be multiple entries for (mid,fid) if the mid checkin was | |
| 242 | +@ -- a merge. Entries with isaux==0 are from the primary parent. Merge | |
| 243 | +@ -- parents have isaux set to true. | |
| 244 | +@ -- | |
| 245 | +@ -- Field name mnemonics: | |
| 246 | +@ -- mid = Manifest ID. (Each check-in is stored as a "Manifest") | |
| 247 | +@ -- fid = File ID. | |
| 248 | +@ -- pmid = Parent Manifest ID. | |
| 249 | +@ -- pid = Parent file ID. | |
| 250 | +@ -- fnid = File Name ID. | |
| 251 | +@ -- pfnid = Parent File Name ID. | |
| 252 | +@ -- isaux = pmid IS AUXiliary parent, not primary parent | |
| 232 | 253 | @ -- |
| 233 | 254 | @ -- pid==0 if the file is added by checkin mid. |
| 234 | 255 | @ -- fid==0 if the file is removed by checkin mid. |
| 235 | 256 | @ -- |
| 236 | 257 | @ CREATE TABLE mlink( |
| 237 | -@ mid INTEGER REFERENCES blob, -- Manifest ID where change occurs | |
| 238 | -@ pid INTEGER REFERENCES blob, -- File ID in parent manifest | |
| 239 | -@ fid INTEGER REFERENCES blob, -- Changed file ID in this manifest | |
| 258 | +@ mid INTEGER REFERENCES plink(cid), -- Checkin that contains fid | |
| 259 | +@ fid INTEGER REFERENCES blob, -- New file content. 0 if deleted | |
| 260 | +@ pmid INTEGER REFERENCES plink(cid), -- Checkin that contains pid | |
| 261 | +@ pid INTEGER REFERENCES blob, -- Prev file content. 0 if new | |
| 240 | 262 | @ fnid INTEGER REFERENCES filename, -- Name of the file |
| 241 | 263 | @ pfnid INTEGER REFERENCES filename, -- Previous name. 0 if unchanged |
| 242 | -@ mperm INTEGER -- File permissions. 1==exec | |
| 264 | +@ mperm INTEGER, -- File permissions. 1==exec | |
| 265 | +@ isaux BOOLEAN DEFAULT 0 -- TRUE if pmid is the primary | |
| 243 | 266 | @ ); |
| 244 | 267 | @ CREATE INDEX mlink_i1 ON mlink(mid); |
| 245 | 268 | @ CREATE INDEX mlink_i2 ON mlink(fnid); |
| 246 | 269 | @ CREATE INDEX mlink_i3 ON mlink(fid); |
| 247 | 270 | @ CREATE INDEX mlink_i4 ON mlink(pid); |
| @@ -251,11 +274,11 @@ | ||
| 251 | 274 | @ CREATE TABLE plink( |
| 252 | 275 | @ pid INTEGER REFERENCES blob, -- Parent manifest |
| 253 | 276 | @ cid INTEGER REFERENCES blob, -- Child manifest |
| 254 | 277 | @ isprim BOOLEAN, -- pid is the primary parent of cid |
| 255 | 278 | @ mtime DATETIME, -- the date/time stamp on cid. Julian day. |
| 256 | -@ baseid INTEGER REFERENCES blob, -- Baseline if child is a delta manifest | |
| 279 | +@ baseid INTEGER REFERENCES blob, -- Baseline if cid is a delta manifest. | |
| 257 | 280 | @ UNIQUE(pid, cid) |
| 258 | 281 | @ ); |
| 259 | 282 | @ CREATE INDEX plink_i2 ON plink(cid,pid); |
| 260 | 283 | @ |
| 261 | 284 | @ -- A "leaf" checkin is a checkin that has no children in the same |
| @@ -488,11 +511,11 @@ | ||
| 488 | 511 | @ -- current version of the file is already in the repository. |
| 489 | 512 | @ -- |
| 490 | 513 | @ CREATE TABLE vfile( |
| 491 | 514 | @ id INTEGER PRIMARY KEY, -- ID of the checked out file |
| 492 | 515 | @ vid INTEGER REFERENCES blob, -- The baseline this file is part of. |
| 493 | -@ chnged INT DEFAULT 0, -- 0:unchnged 1:edited 2:m-chng 3:m-add 4:i-chng 5:i-add | |
| 516 | +@ chnged INT DEFAULT 0, -- 0:unchng 1:edit 2:m-chng 3:m-add 4:i-chng 5:i-add | |
| 494 | 517 | @ deleted BOOLEAN DEFAULT 0, -- True if deleted |
| 495 | 518 | @ isexe BOOLEAN, -- True if file should be executable |
| 496 | 519 | @ islink BOOLEAN, -- True if file should be symlink |
| 497 | 520 | @ rid INTEGER, -- Originally from this repository record |
| 498 | 521 | @ mrid INTEGER, -- Based on this record due to a merge |
| 499 | 522 |
| --- src/schema.c | |
| +++ src/schema.c | |
| @@ -45,11 +45,14 @@ | |
| 45 | ** we have to execute special procedures to update the schema. When |
| 46 | ** the aux schema changes, all we need to do is rebuild the database. |
| 47 | */ |
| 48 | #define CONTENT_SCHEMA "2" |
| 49 | #define AUX_SCHEMA_MIN "2011-04-25 19:50" |
| 50 | #define AUX_SCHEMA_MAX "2014-11-24 20:35" |
| 51 | |
| 52 | #endif /* INTERFACE */ |
| 53 | |
| 54 | |
| 55 | /* |
| @@ -227,21 +230,41 @@ | |
| 227 | @ name TEXT UNIQUE -- Name of file page |
| 228 | @ ); |
| 229 | @ |
| 230 | @ -- Linkages between checkins, files created by each checkin, and |
| 231 | @ -- the names of those files. |
| 232 | @ -- |
| 233 | @ -- pid==0 if the file is added by checkin mid. |
| 234 | @ -- fid==0 if the file is removed by checkin mid. |
| 235 | @ -- |
| 236 | @ CREATE TABLE mlink( |
| 237 | @ mid INTEGER REFERENCES blob, -- Manifest ID where change occurs |
| 238 | @ pid INTEGER REFERENCES blob, -- File ID in parent manifest |
| 239 | @ fid INTEGER REFERENCES blob, -- Changed file ID in this manifest |
| 240 | @ fnid INTEGER REFERENCES filename, -- Name of the file |
| 241 | @ pfnid INTEGER REFERENCES filename, -- Previous name. 0 if unchanged |
| 242 | @ mperm INTEGER -- File permissions. 1==exec |
| 243 | @ ); |
| 244 | @ CREATE INDEX mlink_i1 ON mlink(mid); |
| 245 | @ CREATE INDEX mlink_i2 ON mlink(fnid); |
| 246 | @ CREATE INDEX mlink_i3 ON mlink(fid); |
| 247 | @ CREATE INDEX mlink_i4 ON mlink(pid); |
| @@ -251,11 +274,11 @@ | |
| 251 | @ CREATE TABLE plink( |
| 252 | @ pid INTEGER REFERENCES blob, -- Parent manifest |
| 253 | @ cid INTEGER REFERENCES blob, -- Child manifest |
| 254 | @ isprim BOOLEAN, -- pid is the primary parent of cid |
| 255 | @ mtime DATETIME, -- the date/time stamp on cid. Julian day. |
| 256 | @ baseid INTEGER REFERENCES blob, -- Baseline if child is a delta manifest |
| 257 | @ UNIQUE(pid, cid) |
| 258 | @ ); |
| 259 | @ CREATE INDEX plink_i2 ON plink(cid,pid); |
| 260 | @ |
| 261 | @ -- A "leaf" checkin is a checkin that has no children in the same |
| @@ -488,11 +511,11 @@ | |
| 488 | @ -- current version of the file is already in the repository. |
| 489 | @ -- |
| 490 | @ CREATE TABLE vfile( |
| 491 | @ id INTEGER PRIMARY KEY, -- ID of the checked out file |
| 492 | @ vid INTEGER REFERENCES blob, -- The baseline this file is part of. |
| 493 | @ chnged INT DEFAULT 0, -- 0:unchnged 1:edited 2:m-chng 3:m-add 4:i-chng 5:i-add |
| 494 | @ deleted BOOLEAN DEFAULT 0, -- True if deleted |
| 495 | @ isexe BOOLEAN, -- True if file should be executable |
| 496 | @ islink BOOLEAN, -- True if file should be symlink |
| 497 | @ rid INTEGER, -- Originally from this repository record |
| 498 | @ mrid INTEGER, -- Based on this record due to a merge |
| 499 |
| --- src/schema.c | |
| +++ src/schema.c | |
| @@ -45,11 +45,14 @@ | |
| 45 | ** we have to execute special procedures to update the schema. When |
| 46 | ** the aux schema changes, all we need to do is rebuild the database. |
| 47 | */ |
| 48 | #define CONTENT_SCHEMA "2" |
| 49 | #define AUX_SCHEMA_MIN "2011-04-25 19:50" |
| 50 | #define AUX_SCHEMA_MAX "2015-01-24" |
| 51 | /* NB: Some features require the latest schema. Warning or error messages |
| 52 | ** will appear if an older schema is used. However, the older schemas are |
| 53 | ** adequate for many common functions. */ |
| 54 | |
| 55 | #endif /* INTERFACE */ |
| 56 | |
| 57 | |
| 58 | /* |
| @@ -227,21 +230,41 @@ | |
| 230 | @ name TEXT UNIQUE -- Name of file page |
| 231 | @ ); |
| 232 | @ |
| 233 | @ -- Linkages between checkins, files created by each checkin, and |
| 234 | @ -- the names of those files. |
| 235 | @ -- |
| 236 | @ -- Each entry represents a file that changed content from pid to fid |
| 237 | @ -- due to the check-in that goes from pmid to mid. fnid is the name |
| 238 | @ -- of the file in the mid check-in. If the file was renamed as part |
| 239 | @ -- of the mid check-in, then pfnid is the previous filename. |
| 240 | @ |
| 241 | @ -- There can be multiple entries for (mid,fid) if the mid checkin was |
| 242 | @ -- a merge. Entries with isaux==0 are from the primary parent. Merge |
| 243 | @ -- parents have isaux set to true. |
| 244 | @ -- |
| 245 | @ -- Field name mnemonics: |
| 246 | @ -- mid = Manifest ID. (Each check-in is stored as a "Manifest") |
| 247 | @ -- fid = File ID. |
| 248 | @ -- pmid = Parent Manifest ID. |
| 249 | @ -- pid = Parent file ID. |
| 250 | @ -- fnid = File Name ID. |
| 251 | @ -- pfnid = Parent File Name ID. |
| 252 | @ -- isaux = pmid IS AUXiliary parent, not primary parent |
| 253 | @ -- |
| 254 | @ -- pid==0 if the file is added by checkin mid. |
| 255 | @ -- fid==0 if the file is removed by checkin mid. |
| 256 | @ -- |
| 257 | @ CREATE TABLE mlink( |
| 258 | @ mid INTEGER REFERENCES plink(cid), -- Checkin that contains fid |
| 259 | @ fid INTEGER REFERENCES blob, -- New file content. 0 if deleted |
| 260 | @ pmid INTEGER REFERENCES plink(cid), -- Checkin that contains pid |
| 261 | @ pid INTEGER REFERENCES blob, -- Prev file content. 0 if new |
| 262 | @ fnid INTEGER REFERENCES filename, -- Name of the file |
| 263 | @ pfnid INTEGER REFERENCES filename, -- Previous name. 0 if unchanged |
| 264 | @ mperm INTEGER, -- File permissions. 1==exec |
| 265 | @ isaux BOOLEAN DEFAULT 0 -- TRUE if pmid is the primary |
| 266 | @ ); |
| 267 | @ CREATE INDEX mlink_i1 ON mlink(mid); |
| 268 | @ CREATE INDEX mlink_i2 ON mlink(fnid); |
| 269 | @ CREATE INDEX mlink_i3 ON mlink(fid); |
| 270 | @ CREATE INDEX mlink_i4 ON mlink(pid); |
| @@ -251,11 +274,11 @@ | |
| 274 | @ CREATE TABLE plink( |
| 275 | @ pid INTEGER REFERENCES blob, -- Parent manifest |
| 276 | @ cid INTEGER REFERENCES blob, -- Child manifest |
| 277 | @ isprim BOOLEAN, -- pid is the primary parent of cid |
| 278 | @ mtime DATETIME, -- the date/time stamp on cid. Julian day. |
| 279 | @ baseid INTEGER REFERENCES blob, -- Baseline if cid is a delta manifest. |
| 280 | @ UNIQUE(pid, cid) |
| 281 | @ ); |
| 282 | @ CREATE INDEX plink_i2 ON plink(cid,pid); |
| 283 | @ |
| 284 | @ -- A "leaf" checkin is a checkin that has no children in the same |
| @@ -488,11 +511,11 @@ | |
| 511 | @ -- current version of the file is already in the repository. |
| 512 | @ -- |
| 513 | @ CREATE TABLE vfile( |
| 514 | @ id INTEGER PRIMARY KEY, -- ID of the checked out file |
| 515 | @ vid INTEGER REFERENCES blob, -- The baseline this file is part of. |
| 516 | @ chnged INT DEFAULT 0, -- 0:unchng 1:edit 2:m-chng 3:m-add 4:i-chng 5:i-add |
| 517 | @ deleted BOOLEAN DEFAULT 0, -- True if deleted |
| 518 | @ isexe BOOLEAN, -- True if file should be executable |
| 519 | @ islink BOOLEAN, -- True if file should be symlink |
| 520 | @ rid INTEGER, -- Originally from this repository record |
| 521 | @ mrid INTEGER, -- Based on this record due to a merge |
| 522 |
+2
-2
| --- src/timeline.c | ||
| +++ src/timeline.c | ||
| @@ -360,20 +360,20 @@ | ||
| 360 | 360 | } |
| 361 | 361 | } |
| 362 | 362 | } |
| 363 | 363 | if( zType[0]=='c' && (pGraph || (tmFlags & TIMELINE_BRCOLOR)!=0) ){ |
| 364 | 364 | int nParent = 0; |
| 365 | - int aParent[32]; | |
| 365 | + int aParent[GR_MAX_RAIL]; | |
| 366 | 366 | int gidx; |
| 367 | 367 | static Stmt qparent; |
| 368 | 368 | db_static_prepare(&qparent, |
| 369 | 369 | "SELECT pid FROM plink" |
| 370 | 370 | " WHERE cid=:rid AND pid NOT IN phantom" |
| 371 | 371 | " ORDER BY isprim DESC /*sort*/" |
| 372 | 372 | ); |
| 373 | 373 | db_bind_int(&qparent, ":rid", rid); |
| 374 | - while( db_step(&qparent)==SQLITE_ROW && nParent<32 ){ | |
| 374 | + while( db_step(&qparent)==SQLITE_ROW && nParent<ArraySize(aParent) ){ | |
| 375 | 375 | aParent[nParent++] = db_column_int(&qparent, 0); |
| 376 | 376 | } |
| 377 | 377 | db_reset(&qparent); |
| 378 | 378 | gidx = graph_add_row(pGraph, rid, nParent, aParent, zBr, zBgClr, |
| 379 | 379 | zUuid, isLeaf); |
| 380 | 380 |
| --- src/timeline.c | |
| +++ src/timeline.c | |
| @@ -360,20 +360,20 @@ | |
| 360 | } |
| 361 | } |
| 362 | } |
| 363 | if( zType[0]=='c' && (pGraph || (tmFlags & TIMELINE_BRCOLOR)!=0) ){ |
| 364 | int nParent = 0; |
| 365 | int aParent[32]; |
| 366 | int gidx; |
| 367 | static Stmt qparent; |
| 368 | db_static_prepare(&qparent, |
| 369 | "SELECT pid FROM plink" |
| 370 | " WHERE cid=:rid AND pid NOT IN phantom" |
| 371 | " ORDER BY isprim DESC /*sort*/" |
| 372 | ); |
| 373 | db_bind_int(&qparent, ":rid", rid); |
| 374 | while( db_step(&qparent)==SQLITE_ROW && nParent<32 ){ |
| 375 | aParent[nParent++] = db_column_int(&qparent, 0); |
| 376 | } |
| 377 | db_reset(&qparent); |
| 378 | gidx = graph_add_row(pGraph, rid, nParent, aParent, zBr, zBgClr, |
| 379 | zUuid, isLeaf); |
| 380 |
| --- src/timeline.c | |
| +++ src/timeline.c | |
| @@ -360,20 +360,20 @@ | |
| 360 | } |
| 361 | } |
| 362 | } |
| 363 | if( zType[0]=='c' && (pGraph || (tmFlags & TIMELINE_BRCOLOR)!=0) ){ |
| 364 | int nParent = 0; |
| 365 | int aParent[GR_MAX_RAIL]; |
| 366 | int gidx; |
| 367 | static Stmt qparent; |
| 368 | db_static_prepare(&qparent, |
| 369 | "SELECT pid FROM plink" |
| 370 | " WHERE cid=:rid AND pid NOT IN phantom" |
| 371 | " ORDER BY isprim DESC /*sort*/" |
| 372 | ); |
| 373 | db_bind_int(&qparent, ":rid", rid); |
| 374 | while( db_step(&qparent)==SQLITE_ROW && nParent<ArraySize(aParent) ){ |
| 375 | aParent[nParent++] = db_column_int(&qparent, 0); |
| 376 | } |
| 377 | db_reset(&qparent); |
| 378 | gidx = graph_add_row(pGraph, rid, nParent, aParent, zBr, zBgClr, |
| 379 | zUuid, isLeaf); |
| 380 |
+2
-2
| --- src/timeline.c | ||
| +++ src/timeline.c | ||
| @@ -360,20 +360,20 @@ | ||
| 360 | 360 | } |
| 361 | 361 | } |
| 362 | 362 | } |
| 363 | 363 | if( zType[0]=='c' && (pGraph || (tmFlags & TIMELINE_BRCOLOR)!=0) ){ |
| 364 | 364 | int nParent = 0; |
| 365 | - int aParent[32]; | |
| 365 | + int aParent[GR_MAX_RAIL]; | |
| 366 | 366 | int gidx; |
| 367 | 367 | static Stmt qparent; |
| 368 | 368 | db_static_prepare(&qparent, |
| 369 | 369 | "SELECT pid FROM plink" |
| 370 | 370 | " WHERE cid=:rid AND pid NOT IN phantom" |
| 371 | 371 | " ORDER BY isprim DESC /*sort*/" |
| 372 | 372 | ); |
| 373 | 373 | db_bind_int(&qparent, ":rid", rid); |
| 374 | - while( db_step(&qparent)==SQLITE_ROW && nParent<32 ){ | |
| 374 | + while( db_step(&qparent)==SQLITE_ROW && nParent<ArraySize(aParent) ){ | |
| 375 | 375 | aParent[nParent++] = db_column_int(&qparent, 0); |
| 376 | 376 | } |
| 377 | 377 | db_reset(&qparent); |
| 378 | 378 | gidx = graph_add_row(pGraph, rid, nParent, aParent, zBr, zBgClr, |
| 379 | 379 | zUuid, isLeaf); |
| 380 | 380 |
| --- src/timeline.c | |
| +++ src/timeline.c | |
| @@ -360,20 +360,20 @@ | |
| 360 | } |
| 361 | } |
| 362 | } |
| 363 | if( zType[0]=='c' && (pGraph || (tmFlags & TIMELINE_BRCOLOR)!=0) ){ |
| 364 | int nParent = 0; |
| 365 | int aParent[32]; |
| 366 | int gidx; |
| 367 | static Stmt qparent; |
| 368 | db_static_prepare(&qparent, |
| 369 | "SELECT pid FROM plink" |
| 370 | " WHERE cid=:rid AND pid NOT IN phantom" |
| 371 | " ORDER BY isprim DESC /*sort*/" |
| 372 | ); |
| 373 | db_bind_int(&qparent, ":rid", rid); |
| 374 | while( db_step(&qparent)==SQLITE_ROW && nParent<32 ){ |
| 375 | aParent[nParent++] = db_column_int(&qparent, 0); |
| 376 | } |
| 377 | db_reset(&qparent); |
| 378 | gidx = graph_add_row(pGraph, rid, nParent, aParent, zBr, zBgClr, |
| 379 | zUuid, isLeaf); |
| 380 |
| --- src/timeline.c | |
| +++ src/timeline.c | |
| @@ -360,20 +360,20 @@ | |
| 360 | } |
| 361 | } |
| 362 | } |
| 363 | if( zType[0]=='c' && (pGraph || (tmFlags & TIMELINE_BRCOLOR)!=0) ){ |
| 364 | int nParent = 0; |
| 365 | int aParent[GR_MAX_RAIL]; |
| 366 | int gidx; |
| 367 | static Stmt qparent; |
| 368 | db_static_prepare(&qparent, |
| 369 | "SELECT pid FROM plink" |
| 370 | " WHERE cid=:rid AND pid NOT IN phantom" |
| 371 | " ORDER BY isprim DESC /*sort*/" |
| 372 | ); |
| 373 | db_bind_int(&qparent, ":rid", rid); |
| 374 | while( db_step(&qparent)==SQLITE_ROW && nParent<ArraySize(aParent) ){ |
| 375 | aParent[nParent++] = db_column_int(&qparent, 0); |
| 376 | } |
| 377 | db_reset(&qparent); |
| 378 | gidx = graph_add_row(pGraph, rid, nParent, aParent, zBr, zBgClr, |
| 379 | zUuid, isLeaf); |
| 380 |
+2
-2
| --- src/timeline.c | ||
| +++ src/timeline.c | ||
| @@ -360,20 +360,20 @@ | ||
| 360 | 360 | } |
| 361 | 361 | } |
| 362 | 362 | } |
| 363 | 363 | if( zType[0]=='c' && (pGraph || (tmFlags & TIMELINE_BRCOLOR)!=0) ){ |
| 364 | 364 | int nParent = 0; |
| 365 | - int aParent[32]; | |
| 365 | + int aParent[GR_MAX_RAIL]; | |
| 366 | 366 | int gidx; |
| 367 | 367 | static Stmt qparent; |
| 368 | 368 | db_static_prepare(&qparent, |
| 369 | 369 | "SELECT pid FROM plink" |
| 370 | 370 | " WHERE cid=:rid AND pid NOT IN phantom" |
| 371 | 371 | " ORDER BY isprim DESC /*sort*/" |
| 372 | 372 | ); |
| 373 | 373 | db_bind_int(&qparent, ":rid", rid); |
| 374 | - while( db_step(&qparent)==SQLITE_ROW && nParent<32 ){ | |
| 374 | + while( db_step(&qparent)==SQLITE_ROW && nParent<ArraySize(aParent) ){ | |
| 375 | 375 | aParent[nParent++] = db_column_int(&qparent, 0); |
| 376 | 376 | } |
| 377 | 377 | db_reset(&qparent); |
| 378 | 378 | gidx = graph_add_row(pGraph, rid, nParent, aParent, zBr, zBgClr, |
| 379 | 379 | zUuid, isLeaf); |
| 380 | 380 |
| --- src/timeline.c | |
| +++ src/timeline.c | |
| @@ -360,20 +360,20 @@ | |
| 360 | } |
| 361 | } |
| 362 | } |
| 363 | if( zType[0]=='c' && (pGraph || (tmFlags & TIMELINE_BRCOLOR)!=0) ){ |
| 364 | int nParent = 0; |
| 365 | int aParent[32]; |
| 366 | int gidx; |
| 367 | static Stmt qparent; |
| 368 | db_static_prepare(&qparent, |
| 369 | "SELECT pid FROM plink" |
| 370 | " WHERE cid=:rid AND pid NOT IN phantom" |
| 371 | " ORDER BY isprim DESC /*sort*/" |
| 372 | ); |
| 373 | db_bind_int(&qparent, ":rid", rid); |
| 374 | while( db_step(&qparent)==SQLITE_ROW && nParent<32 ){ |
| 375 | aParent[nParent++] = db_column_int(&qparent, 0); |
| 376 | } |
| 377 | db_reset(&qparent); |
| 378 | gidx = graph_add_row(pGraph, rid, nParent, aParent, zBr, zBgClr, |
| 379 | zUuid, isLeaf); |
| 380 |
| --- src/timeline.c | |
| +++ src/timeline.c | |
| @@ -360,20 +360,20 @@ | |
| 360 | } |
| 361 | } |
| 362 | } |
| 363 | if( zType[0]=='c' && (pGraph || (tmFlags & TIMELINE_BRCOLOR)!=0) ){ |
| 364 | int nParent = 0; |
| 365 | int aParent[GR_MAX_RAIL]; |
| 366 | int gidx; |
| 367 | static Stmt qparent; |
| 368 | db_static_prepare(&qparent, |
| 369 | "SELECT pid FROM plink" |
| 370 | " WHERE cid=:rid AND pid NOT IN phantom" |
| 371 | " ORDER BY isprim DESC /*sort*/" |
| 372 | ); |
| 373 | db_bind_int(&qparent, ":rid", rid); |
| 374 | while( db_step(&qparent)==SQLITE_ROW && nParent<ArraySize(aParent) ){ |
| 375 | aParent[nParent++] = db_column_int(&qparent, 0); |
| 376 | } |
| 377 | db_reset(&qparent); |
| 378 | gidx = graph_add_row(pGraph, rid, nParent, aParent, zBr, zBgClr, |
| 379 | zUuid, isLeaf); |
| 380 |