Fossil SCM
Merge the versionable-settings cache into trunk.
Commit
ea51d1272ca5f4ada919ae5491f71cf51092b7a5
Parent
1ec0739c4bb054a…
1 file changed
+24
-3
M
src/db.c
+24
-3
| --- src/db.c | ||
| +++ src/db.c | ||
| @@ -1407,15 +1407,30 @@ | ||
| 1407 | 1407 | ** .fossil-settings/<name> , and emits warnings if necessary. |
| 1408 | 1408 | ** Returns the non-versioned value without modification if there is no |
| 1409 | 1409 | ** versioned value. |
| 1410 | 1410 | */ |
| 1411 | 1411 | static char *db_get_do_versionable(const char *zName, char *zNonVersionedSetting){ |
| 1412 | - /* Attempt to load the versioned setting from a checked out file */ | |
| 1413 | 1412 | char *zVersionedSetting = 0; |
| 1414 | 1413 | int noWarn = 0; |
| 1415 | - | |
| 1416 | - if( db_open_local() ){ | |
| 1414 | + struct _cacheEntry { | |
| 1415 | + struct _cacheEntry *next; | |
| 1416 | + const char *zName, *zValue; | |
| 1417 | + } *cacheEntry = 0; | |
| 1418 | + static struct _cacheEntry *cache = 0; | |
| 1419 | + | |
| 1420 | + /* Look up name in cache */ | |
| 1421 | + cacheEntry = cache; | |
| 1422 | + while( cacheEntry!=0 ){ | |
| 1423 | + if( fossil_strcmp(cacheEntry->zName, zName)==0 ){ | |
| 1424 | + zVersionedSetting = fossil_strdup(cacheEntry->zValue); | |
| 1425 | + break; | |
| 1426 | + } | |
| 1427 | + cacheEntry = cacheEntry->next; | |
| 1428 | + } | |
| 1429 | + /* Attempt to read value from file in checkout if there wasn't a cache hit | |
| 1430 | + ** and a checkout is open. */ | |
| 1431 | + if( cacheEntry==0 && db_open_local() ){ | |
| 1417 | 1432 | Blob versionedPathname; |
| 1418 | 1433 | char *zVersionedPathname; |
| 1419 | 1434 | blob_zero(&versionedPathname); |
| 1420 | 1435 | blob_appendf(&versionedPathname, "%s/.fossil-settings/%s", |
| 1421 | 1436 | g.zLocalRoot, zName); |
| @@ -1436,10 +1451,16 @@ | ||
| 1436 | 1451 | if( file_size(blob_str(&versionedPathname))>=0 ){ |
| 1437 | 1452 | noWarn = 1; |
| 1438 | 1453 | } |
| 1439 | 1454 | } |
| 1440 | 1455 | blob_reset(&versionedPathname); |
| 1456 | + /* Store result in cache, which can be the value or 0 if not found */ | |
| 1457 | + cacheEntry = (struct _cacheEntry*)fossil_malloc(sizeof(struct _cacheEntry)); | |
| 1458 | + cacheEntry->next = cache; | |
| 1459 | + cacheEntry->zName = zName; | |
| 1460 | + cacheEntry->zValue = fossil_strdup(zVersionedSetting); | |
| 1461 | + cache = cacheEntry; | |
| 1441 | 1462 | } |
| 1442 | 1463 | /* Display a warning? */ |
| 1443 | 1464 | if( zVersionedSetting!=0 && zNonVersionedSetting!=0 |
| 1444 | 1465 | && zNonVersionedSetting[0]!='\0' && !noWarn |
| 1445 | 1466 | ){ |
| 1446 | 1467 |
| --- src/db.c | |
| +++ src/db.c | |
| @@ -1407,15 +1407,30 @@ | |
| 1407 | ** .fossil-settings/<name> , and emits warnings if necessary. |
| 1408 | ** Returns the non-versioned value without modification if there is no |
| 1409 | ** versioned value. |
| 1410 | */ |
| 1411 | static char *db_get_do_versionable(const char *zName, char *zNonVersionedSetting){ |
| 1412 | /* Attempt to load the versioned setting from a checked out file */ |
| 1413 | char *zVersionedSetting = 0; |
| 1414 | int noWarn = 0; |
| 1415 | |
| 1416 | if( db_open_local() ){ |
| 1417 | Blob versionedPathname; |
| 1418 | char *zVersionedPathname; |
| 1419 | blob_zero(&versionedPathname); |
| 1420 | blob_appendf(&versionedPathname, "%s/.fossil-settings/%s", |
| 1421 | g.zLocalRoot, zName); |
| @@ -1436,10 +1451,16 @@ | |
| 1436 | if( file_size(blob_str(&versionedPathname))>=0 ){ |
| 1437 | noWarn = 1; |
| 1438 | } |
| 1439 | } |
| 1440 | blob_reset(&versionedPathname); |
| 1441 | } |
| 1442 | /* Display a warning? */ |
| 1443 | if( zVersionedSetting!=0 && zNonVersionedSetting!=0 |
| 1444 | && zNonVersionedSetting[0]!='\0' && !noWarn |
| 1445 | ){ |
| 1446 |
| --- src/db.c | |
| +++ src/db.c | |
| @@ -1407,15 +1407,30 @@ | |
| 1407 | ** .fossil-settings/<name> , and emits warnings if necessary. |
| 1408 | ** Returns the non-versioned value without modification if there is no |
| 1409 | ** versioned value. |
| 1410 | */ |
| 1411 | static char *db_get_do_versionable(const char *zName, char *zNonVersionedSetting){ |
| 1412 | char *zVersionedSetting = 0; |
| 1413 | int noWarn = 0; |
| 1414 | struct _cacheEntry { |
| 1415 | struct _cacheEntry *next; |
| 1416 | const char *zName, *zValue; |
| 1417 | } *cacheEntry = 0; |
| 1418 | static struct _cacheEntry *cache = 0; |
| 1419 | |
| 1420 | /* Look up name in cache */ |
| 1421 | cacheEntry = cache; |
| 1422 | while( cacheEntry!=0 ){ |
| 1423 | if( fossil_strcmp(cacheEntry->zName, zName)==0 ){ |
| 1424 | zVersionedSetting = fossil_strdup(cacheEntry->zValue); |
| 1425 | break; |
| 1426 | } |
| 1427 | cacheEntry = cacheEntry->next; |
| 1428 | } |
| 1429 | /* Attempt to read value from file in checkout if there wasn't a cache hit |
| 1430 | ** and a checkout is open. */ |
| 1431 | if( cacheEntry==0 && db_open_local() ){ |
| 1432 | Blob versionedPathname; |
| 1433 | char *zVersionedPathname; |
| 1434 | blob_zero(&versionedPathname); |
| 1435 | blob_appendf(&versionedPathname, "%s/.fossil-settings/%s", |
| 1436 | g.zLocalRoot, zName); |
| @@ -1436,10 +1451,16 @@ | |
| 1451 | if( file_size(blob_str(&versionedPathname))>=0 ){ |
| 1452 | noWarn = 1; |
| 1453 | } |
| 1454 | } |
| 1455 | blob_reset(&versionedPathname); |
| 1456 | /* Store result in cache, which can be the value or 0 if not found */ |
| 1457 | cacheEntry = (struct _cacheEntry*)fossil_malloc(sizeof(struct _cacheEntry)); |
| 1458 | cacheEntry->next = cache; |
| 1459 | cacheEntry->zName = zName; |
| 1460 | cacheEntry->zValue = fossil_strdup(zVersionedSetting); |
| 1461 | cache = cacheEntry; |
| 1462 | } |
| 1463 | /* Display a warning? */ |
| 1464 | if( zVersionedSetting!=0 && zNonVersionedSetting!=0 |
| 1465 | && zNonVersionedSetting[0]!='\0' && !noWarn |
| 1466 | ){ |
| 1467 |