Fossil SCM

Fix issues with the prior commit on this branch. The small-stack non-recursive implementation appears to be working. Ticket [2a1e8e3c4b0b39e08fdde].

drh 2010-10-05 03:24 UTC small_stack
Commit f93a54d0bafffc9e2548e9fb54801f121c665805
3 files changed +1 -84 +1 -2 +4 -2
+1 -84
--- src/content.c
+++ src/content.c
@@ -102,25 +102,10 @@
102102
p->content = *pBlob;
103103
blob_zero(pBlob);
104104
bag_insert(&contentCache.inCache, rid);
105105
}
106106
107
-#if 0
108
-/*
109
-** Remove an entry from the content cache
110
-*/
111
-void content_cache_remove(int rid){
112
- int i;
113
- for(i=0; i<contentCache.n && contentCache.a[i].rid!=rid; i++){}
114
- if( i>=contentCache.n ) return;
115
- contentCache.szTotal -= blob_size(&contentCache.a[i].content);
116
- blob_reset(&contentCache.a[i].content);
117
- contentCache.n--;
118
- contentCache.a[i] = contentCache.a[contentCache.n];
119
-}
120
-#endif
121
-
122107
/*
123108
** Clear the content cache.
124109
*/
125110
void content_clear_cache(void){
126111
int i;
@@ -280,11 +265,11 @@
280265
if( a==0 ) fossil_panic("out of memory");
281266
}
282267
a[n] = nextRid;
283268
}
284269
mx = n;
285
- rc = content_of_blob(a[n], pBlob);
270
+ rc = content_get(a[n], pBlob);
286271
n--;
287272
while( rc && n>=0 ){
288273
rc = content_of_blob(a[n], &delta);
289274
if( rc ){
290275
blob_delta_apply(pBlob, &delta, &next);
@@ -299,85 +284,17 @@
299284
n--;
300285
}
301286
free(a);
302287
if( !rc ) blob_reset(pBlob);
303288
}
304
- return rc;
305
-}
306
-
307
-#if 0
308
-/*
309
-** Extract the content for ID rid and put it into the
310
-** uninitialized blob. Return 1 on success. If the record
311
-** is a phantom, zero pBlob and return 0.
312
-*/
313
-int old_content_get(int rid, Blob *pBlob){
314
- Blob src;
315
- int srcid;
316
- int rc = 0;
317
- int i;
318
- static Bag inProcess;
319
-
320
- assert( g.repositoryOpen );
321
- blob_zero(pBlob);
322
- if( rid==0 ) return 0;
323
-
324
- /* Early out if we know the content is not available */
325
- if( bag_find(&contentCache.missing, rid) ){
326
- return 0;
327
- }
328
-
329
- /* Look for the artifact in the cache first */
330
- for(i=0; i<contentCache.n; i++){
331
- if( contentCache.a[i].rid==rid ){
332
- blob_copy(pBlob, &contentCache.a[i].content);
333
- contentCache.a[i].age = contentCache.nextAge++;
334
- return 1;
335
- }
336
- }
337
-
338
- /* See if we need to apply a delta to find this artifact */
339
- srcid = findSrcid(rid);
340
- if( srcid ){
341
- /* Yes, a delta is required */
342
- if( bag_find(&inProcess, srcid) ){
343
- db_multi_exec(
344
- "UPDATE blob SET content=NULL, size=-1 WHERE rid=%d;"
345
- "DELETE FROM delta WHERE rid=%d;"
346
- "INSERT OR IGNORE INTO phantom VALUES(%d);",
347
- srcid, srcid, srcid
348
- );
349
- blob_zero(pBlob);
350
- return 0;
351
- }
352
- bag_insert(&inProcess, srcid);
353
-
354
- cacheSrcid(rid);
355
- if( content_get(srcid, &src) ){
356
- Blob delta;
357
- if( content_of_blob(rid, &delta) ){
358
- blob_init(pBlob,0,0);
359
- blob_delta_apply(&src, &delta, pBlob);
360
- blob_reset(&delta);
361
- rc = 1;
362
- }
363
- }
364
- bag_remove(&inProcess, srcid);
365
- }else{
366
- /* No delta required. Read content directly from the database */
367
- if( content_of_blob(rid, pBlob) ){
368
- rc = 1;
369
- }
370
- }
371289
if( rc==0 ){
372290
bag_insert(&contentCache.missing, rid);
373291
}else{
374292
bag_insert(&contentCache.available, rid);
375293
}
376294
return rc;
377295
}
378
-#endif
379296
380297
/*
381298
** COMMAND: artifact
382299
**
383300
** Usage: %fossil artifact ARTIFACT-ID ?OUTPUT-FILENAME?
384301
--- src/content.c
+++ src/content.c
@@ -102,25 +102,10 @@
102 p->content = *pBlob;
103 blob_zero(pBlob);
104 bag_insert(&contentCache.inCache, rid);
105 }
106
107 #if 0
108 /*
109 ** Remove an entry from the content cache
110 */
111 void content_cache_remove(int rid){
112 int i;
113 for(i=0; i<contentCache.n && contentCache.a[i].rid!=rid; i++){}
114 if( i>=contentCache.n ) return;
115 contentCache.szTotal -= blob_size(&contentCache.a[i].content);
116 blob_reset(&contentCache.a[i].content);
117 contentCache.n--;
118 contentCache.a[i] = contentCache.a[contentCache.n];
119 }
120 #endif
121
122 /*
123 ** Clear the content cache.
124 */
125 void content_clear_cache(void){
126 int i;
@@ -280,11 +265,11 @@
280 if( a==0 ) fossil_panic("out of memory");
281 }
282 a[n] = nextRid;
283 }
284 mx = n;
285 rc = content_of_blob(a[n], pBlob);
286 n--;
287 while( rc && n>=0 ){
288 rc = content_of_blob(a[n], &delta);
289 if( rc ){
290 blob_delta_apply(pBlob, &delta, &next);
@@ -299,85 +284,17 @@
299 n--;
300 }
301 free(a);
302 if( !rc ) blob_reset(pBlob);
303 }
304 return rc;
305 }
306
307 #if 0
308 /*
309 ** Extract the content for ID rid and put it into the
310 ** uninitialized blob. Return 1 on success. If the record
311 ** is a phantom, zero pBlob and return 0.
312 */
313 int old_content_get(int rid, Blob *pBlob){
314 Blob src;
315 int srcid;
316 int rc = 0;
317 int i;
318 static Bag inProcess;
319
320 assert( g.repositoryOpen );
321 blob_zero(pBlob);
322 if( rid==0 ) return 0;
323
324 /* Early out if we know the content is not available */
325 if( bag_find(&contentCache.missing, rid) ){
326 return 0;
327 }
328
329 /* Look for the artifact in the cache first */
330 for(i=0; i<contentCache.n; i++){
331 if( contentCache.a[i].rid==rid ){
332 blob_copy(pBlob, &contentCache.a[i].content);
333 contentCache.a[i].age = contentCache.nextAge++;
334 return 1;
335 }
336 }
337
338 /* See if we need to apply a delta to find this artifact */
339 srcid = findSrcid(rid);
340 if( srcid ){
341 /* Yes, a delta is required */
342 if( bag_find(&inProcess, srcid) ){
343 db_multi_exec(
344 "UPDATE blob SET content=NULL, size=-1 WHERE rid=%d;"
345 "DELETE FROM delta WHERE rid=%d;"
346 "INSERT OR IGNORE INTO phantom VALUES(%d);",
347 srcid, srcid, srcid
348 );
349 blob_zero(pBlob);
350 return 0;
351 }
352 bag_insert(&inProcess, srcid);
353
354 cacheSrcid(rid);
355 if( content_get(srcid, &src) ){
356 Blob delta;
357 if( content_of_blob(rid, &delta) ){
358 blob_init(pBlob,0,0);
359 blob_delta_apply(&src, &delta, pBlob);
360 blob_reset(&delta);
361 rc = 1;
362 }
363 }
364 bag_remove(&inProcess, srcid);
365 }else{
366 /* No delta required. Read content directly from the database */
367 if( content_of_blob(rid, pBlob) ){
368 rc = 1;
369 }
370 }
371 if( rc==0 ){
372 bag_insert(&contentCache.missing, rid);
373 }else{
374 bag_insert(&contentCache.available, rid);
375 }
376 return rc;
377 }
378 #endif
379
380 /*
381 ** COMMAND: artifact
382 **
383 ** Usage: %fossil artifact ARTIFACT-ID ?OUTPUT-FILENAME?
384
--- src/content.c
+++ src/content.c
@@ -102,25 +102,10 @@
102 p->content = *pBlob;
103 blob_zero(pBlob);
104 bag_insert(&contentCache.inCache, rid);
105 }
106
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
107 /*
108 ** Clear the content cache.
109 */
110 void content_clear_cache(void){
111 int i;
@@ -280,11 +265,11 @@
265 if( a==0 ) fossil_panic("out of memory");
266 }
267 a[n] = nextRid;
268 }
269 mx = n;
270 rc = content_get(a[n], pBlob);
271 n--;
272 while( rc && n>=0 ){
273 rc = content_of_blob(a[n], &delta);
274 if( rc ){
275 blob_delta_apply(pBlob, &delta, &next);
@@ -299,85 +284,17 @@
284 n--;
285 }
286 free(a);
287 if( !rc ) blob_reset(pBlob);
288 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
289 if( rc==0 ){
290 bag_insert(&contentCache.missing, rid);
291 }else{
292 bag_insert(&contentCache.available, rid);
293 }
294 return rc;
295 }
 
296
297 /*
298 ** COMMAND: artifact
299 **
300 ** Usage: %fossil artifact ARTIFACT-ID ?OUTPUT-FILENAME?
301
+1 -2
--- src/rebuild.c
+++ src/rebuild.c
@@ -157,12 +157,11 @@
157157
manifest_crosslink(rid, pUse);
158158
}else{
159159
/* We are doing "fossil deconstruct" */
160160
char *zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid);
161161
char *zFile = mprintf(zFNameFormat, zUuid, zUuid+prefixLength);
162
-// blob_write_to_file(pUse,zFile);
163
-printf("%d - %s\n", rid, zUuid);
162
+ blob_write_to_file(pUse,zFile);
164163
free(zFile);
165164
free(zUuid);
166165
}
167166
blob_reset(pUse);
168167
rebuild_step_done(rid);
169168
--- src/rebuild.c
+++ src/rebuild.c
@@ -157,12 +157,11 @@
157 manifest_crosslink(rid, pUse);
158 }else{
159 /* We are doing "fossil deconstruct" */
160 char *zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid);
161 char *zFile = mprintf(zFNameFormat, zUuid, zUuid+prefixLength);
162 // blob_write_to_file(pUse,zFile);
163 printf("%d - %s\n", rid, zUuid);
164 free(zFile);
165 free(zUuid);
166 }
167 blob_reset(pUse);
168 rebuild_step_done(rid);
169
--- src/rebuild.c
+++ src/rebuild.c
@@ -157,12 +157,11 @@
157 manifest_crosslink(rid, pUse);
158 }else{
159 /* We are doing "fossil deconstruct" */
160 char *zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid);
161 char *zFile = mprintf(zFNameFormat, zUuid, zUuid+prefixLength);
162 blob_write_to_file(pUse,zFile);
 
163 free(zFile);
164 free(zUuid);
165 }
166 blob_reset(pUse);
167 rebuild_step_done(rid);
168
+4 -2
--- src/xfer.c
+++ src/xfer.c
@@ -119,22 +119,24 @@
119119
if( uuid_is_shunned(blob_str(&pXfer->aToken[1])) ){
120120
/* Ignore files that have been shunned */
121121
return;
122122
}
123123
if( pXfer->nToken==4 ){
124
- Blob src;
124
+ Blob src, next;
125125
srcid = rid_from_uuid(&pXfer->aToken[2], 1);
126126
if( content_get(srcid, &src)==0 ){
127127
rid = content_put(&content, blob_str(&pXfer->aToken[1]), srcid);
128128
pXfer->nDanglingFile++;
129129
db_multi_exec("DELETE FROM phantom WHERE rid=%d", rid);
130130
content_make_public(rid);
131131
return;
132132
}
133133
pXfer->nDeltaRcvd++;
134
- blob_delta_apply(&src, &content, &content);
134
+ blob_delta_apply(&src, &content, &next);
135135
blob_reset(&src);
136
+ blob_reset(&content);
137
+ content = next;
136138
}else{
137139
pXfer->nFileRcvd++;
138140
}
139141
sha1sum_blob(&content, &hash);
140142
if( !blob_eq_str(&pXfer->aToken[1], blob_str(&hash), -1) ){
141143
--- src/xfer.c
+++ src/xfer.c
@@ -119,22 +119,24 @@
119 if( uuid_is_shunned(blob_str(&pXfer->aToken[1])) ){
120 /* Ignore files that have been shunned */
121 return;
122 }
123 if( pXfer->nToken==4 ){
124 Blob src;
125 srcid = rid_from_uuid(&pXfer->aToken[2], 1);
126 if( content_get(srcid, &src)==0 ){
127 rid = content_put(&content, blob_str(&pXfer->aToken[1]), srcid);
128 pXfer->nDanglingFile++;
129 db_multi_exec("DELETE FROM phantom WHERE rid=%d", rid);
130 content_make_public(rid);
131 return;
132 }
133 pXfer->nDeltaRcvd++;
134 blob_delta_apply(&src, &content, &content);
135 blob_reset(&src);
 
 
136 }else{
137 pXfer->nFileRcvd++;
138 }
139 sha1sum_blob(&content, &hash);
140 if( !blob_eq_str(&pXfer->aToken[1], blob_str(&hash), -1) ){
141
--- src/xfer.c
+++ src/xfer.c
@@ -119,22 +119,24 @@
119 if( uuid_is_shunned(blob_str(&pXfer->aToken[1])) ){
120 /* Ignore files that have been shunned */
121 return;
122 }
123 if( pXfer->nToken==4 ){
124 Blob src, next;
125 srcid = rid_from_uuid(&pXfer->aToken[2], 1);
126 if( content_get(srcid, &src)==0 ){
127 rid = content_put(&content, blob_str(&pXfer->aToken[1]), srcid);
128 pXfer->nDanglingFile++;
129 db_multi_exec("DELETE FROM phantom WHERE rid=%d", rid);
130 content_make_public(rid);
131 return;
132 }
133 pXfer->nDeltaRcvd++;
134 blob_delta_apply(&src, &content, &next);
135 blob_reset(&src);
136 blob_reset(&content);
137 content = next;
138 }else{
139 pXfer->nFileRcvd++;
140 }
141 sha1sum_blob(&content, &hash);
142 if( !blob_eq_str(&pXfer->aToken[1], blob_str(&hash), -1) ){
143

Keyboard Shortcuts

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