Fossil SCM

Fix the creation of orphan table entries when delta-manifests are received before their baselines. Ticket [fbea61caf0acfd0a].

drh 2011-02-10 21:28 trunk
Commit 195073fb78f7c6a112104b330fd50887bf54475c
1 file changed +4 -11
+4 -11
--- src/manifest.c
+++ src/manifest.c
@@ -863,10 +863,11 @@
863863
** a pointer to the manifest on success or NULL if there is a failure.
864864
*/
865865
Manifest *manifest_get(int rid, int cfType){
866866
Blob content;
867867
Manifest *p;
868
+ if( !rid ) return 0;
868869
p = manifest_cache_find(rid);
869870
if( p ){
870871
if( cfType!=CFTYPE_ANY && cfType!=p->type ){
871872
manifest_cache_insert(p);
872873
p = 0;
@@ -931,29 +932,21 @@
931932
/*
932933
** Fetch the baseline associated with the delta-manifest p.
933934
** Return 0 on success. If unable to parse the baseline,
934935
** throw an error. If the baseline is a manifest, throw an
935936
** error if throwError is true, or record that p is an orphan
936
-** and return 1 throwError is false.
937
+** and return 1 if throwError is false.
937938
*/
938939
static int fetch_baseline(Manifest *p, int throwError){
939940
if( p->zBaseline!=0 && p->pBaseline==0 ){
940
- int rid = uuid_to_rid(p->zBaseline, 0);
941
- if( rid==0 && !throwError ){
942
- rid = content_new(p->zBaseline);
943
- db_multi_exec(
944
- "INSERT OR IGNORE INTO orphan(rid, baseline) VALUES(%d,%d)",
945
- rid, p->rid
946
- );
947
- return 1;
948
- }
941
+ int rid = uuid_to_rid(p->zBaseline, 1);
949942
p->pBaseline = manifest_get(rid, CFTYPE_MANIFEST);
950943
if( p->pBaseline==0 ){
951944
if( !throwError ){
952945
db_multi_exec(
953946
"INSERT OR IGNORE INTO orphan(rid, baseline) VALUES(%d,%d)",
954
- rid, p->rid
947
+ p->rid, rid
955948
);
956949
return 1;
957950
}
958951
fossil_fatal("cannot access baseline manifest %S", p->zBaseline);
959952
}
960953
--- src/manifest.c
+++ src/manifest.c
@@ -863,10 +863,11 @@
863 ** a pointer to the manifest on success or NULL if there is a failure.
864 */
865 Manifest *manifest_get(int rid, int cfType){
866 Blob content;
867 Manifest *p;
 
868 p = manifest_cache_find(rid);
869 if( p ){
870 if( cfType!=CFTYPE_ANY && cfType!=p->type ){
871 manifest_cache_insert(p);
872 p = 0;
@@ -931,29 +932,21 @@
931 /*
932 ** Fetch the baseline associated with the delta-manifest p.
933 ** Return 0 on success. If unable to parse the baseline,
934 ** throw an error. If the baseline is a manifest, throw an
935 ** error if throwError is true, or record that p is an orphan
936 ** and return 1 throwError is false.
937 */
938 static int fetch_baseline(Manifest *p, int throwError){
939 if( p->zBaseline!=0 && p->pBaseline==0 ){
940 int rid = uuid_to_rid(p->zBaseline, 0);
941 if( rid==0 && !throwError ){
942 rid = content_new(p->zBaseline);
943 db_multi_exec(
944 "INSERT OR IGNORE INTO orphan(rid, baseline) VALUES(%d,%d)",
945 rid, p->rid
946 );
947 return 1;
948 }
949 p->pBaseline = manifest_get(rid, CFTYPE_MANIFEST);
950 if( p->pBaseline==0 ){
951 if( !throwError ){
952 db_multi_exec(
953 "INSERT OR IGNORE INTO orphan(rid, baseline) VALUES(%d,%d)",
954 rid, p->rid
955 );
956 return 1;
957 }
958 fossil_fatal("cannot access baseline manifest %S", p->zBaseline);
959 }
960
--- src/manifest.c
+++ src/manifest.c
@@ -863,10 +863,11 @@
863 ** a pointer to the manifest on success or NULL if there is a failure.
864 */
865 Manifest *manifest_get(int rid, int cfType){
866 Blob content;
867 Manifest *p;
868 if( !rid ) return 0;
869 p = manifest_cache_find(rid);
870 if( p ){
871 if( cfType!=CFTYPE_ANY && cfType!=p->type ){
872 manifest_cache_insert(p);
873 p = 0;
@@ -931,29 +932,21 @@
932 /*
933 ** Fetch the baseline associated with the delta-manifest p.
934 ** Return 0 on success. If unable to parse the baseline,
935 ** throw an error. If the baseline is a manifest, throw an
936 ** error if throwError is true, or record that p is an orphan
937 ** and return 1 if throwError is false.
938 */
939 static int fetch_baseline(Manifest *p, int throwError){
940 if( p->zBaseline!=0 && p->pBaseline==0 ){
941 int rid = uuid_to_rid(p->zBaseline, 1);
 
 
 
 
 
 
 
 
942 p->pBaseline = manifest_get(rid, CFTYPE_MANIFEST);
943 if( p->pBaseline==0 ){
944 if( !throwError ){
945 db_multi_exec(
946 "INSERT OR IGNORE INTO orphan(rid, baseline) VALUES(%d,%d)",
947 p->rid, rid
948 );
949 return 1;
950 }
951 fossil_fatal("cannot access baseline manifest %S", p->zBaseline);
952 }
953

Keyboard Shortcuts

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