Fossil

Check-in [09e52f0d]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Add db_get_versionable_setting() for implementing 'versionable settings', which is like db_get() except will prefer to read the value from .fossil-settings/NAME in the checked out source, rather than the database.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | versionable-settings
Files: files | file ages | folders
SHA1:09e52f0df7bab794159322def51e43c71debf9b7
User & Date: ben 2011-05-22 09:38:59
Context
2011-05-22
09:44
When parsing glob settings, allow splits on newlines as well as commas. Allows versionable glob settings to be written one glob per line for readability. check-in: 7d048033 user: ben tags: versionable-settings
09:38
Add db_get_versionable_setting() for implementing 'versionable settings', which is like db_get() except will prefer to read the value from .fossil-settings/NAME in the checked out source, rather than the database. check-in: 09e52f0d user: ben tags: versionable-settings
09:11
Create new branch named "versionable-settings" check-in: 3db75c48 user: ben tags: versionable-settings
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/db.c.

1388
1389
1390
1391
1392
1393
1394




































1395
1396
1397
1398
1399
1400
1401
void db_swap_connections(void){
  if( !g.useAttach ){
    sqlite3 *dbTemp = g.db;
    g.db = g.dbConfig;
    g.dbConfig = dbTemp;
  }
}





































/*
** Get and set values from the CONFIG, GLOBAL_CONFIG and VVAR table in the
** repository and local databases.
*/
char *db_get(const char *zName, char *zDefault){
  char *z = 0;







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
void db_swap_connections(void){
  if( !g.useAttach ){
    sqlite3 *dbTemp = g.db;
    g.db = g.dbConfig;
    g.dbConfig = dbTemp;
  }
}

/*
** Get a potentially versioned setting - either from .fossil-settings/<name>
*/
char *db_get_versionable_setting(const char *zName, char *zDefault){
  char *s = 0;
  if( db_open_local() ){
    /* See if there's a versioned setting */
    Blob versionedPathname;
    blob_zero(&versionedPathname);
    blob_appendf(&versionedPathname, "%s/.fossil-settings/%s", g.zLocalRoot, zName);
    char *zVersionedPathname = blob_str(&versionedPathname);
    if( file_size(zVersionedPathname) >= 0 ){
      /* File exists, and contains the value for this setting. Load from the file. */
      Blob setting;
      blob_zero(&setting);
      if( blob_read_from_file(&setting, zVersionedPathname) >= 0 ){
        s = strdup(blob_str(&setting));
      }
      blob_reset(&setting);
    }
    blob_reset(&versionedPathname);
  }
  if( s != 0 ){
    return s;
  }
  /* Fall back to settings in the database */
  return db_get(zName, zDefault);
}
int db_get_versionable_setting_boolean(const char *zName, int dflt){
  char *zVal = db_get_versionable_setting(zName, dflt ? "on" : "off");
  if( is_truth(zVal) ) return 1;
  if( is_false(zVal) ) return 0;
  return dflt;
}


/*
** Get and set values from the CONFIG, GLOBAL_CONFIG and VVAR table in the
** repository and local databases.
*/
char *db_get(const char *zName, char *zDefault){
  char *z = 0;