Fossil SCM

Check versioned settings (namely, allow-symlinks) during open.

andygoth 2015-04-08 05:06 trunk
Commit 6a4c3c5ee20755800342f21615ecac2b84509e31
3 files changed +35 -15 +1 +1
+35 -15
--- src/db.c
+++ src/db.c
@@ -1894,59 +1894,68 @@
18941894
** might be generated.
18951895
*/
18961896
char *db_get_versioned(const char *zName, char *zNonVersionedSetting){
18971897
char *zVersionedSetting = 0;
18981898
int noWarn = 0;
1899
+ int found = 0;
18991900
struct _cacheEntry {
19001901
struct _cacheEntry *next;
19011902
const char *zName, *zValue;
19021903
} *cacheEntry = 0;
19031904
static struct _cacheEntry *cache = 0;
19041905
1905
- if( !g.localOpen) return zNonVersionedSetting;
1906
+ if( !g.localOpen && g.zOpenRevision==0 ) return zNonVersionedSetting;
19061907
/* Look up name in cache */
19071908
cacheEntry = cache;
19081909
while( cacheEntry!=0 ){
19091910
if( fossil_strcmp(cacheEntry->zName, zName)==0 ){
19101911
zVersionedSetting = fossil_strdup(cacheEntry->zValue);
19111912
break;
19121913
}
19131914
cacheEntry = cacheEntry->next;
19141915
}
1915
- /* Attempt to read value from file in checkout if there wasn't a cache hit
1916
- ** and a checkout is open. */
1916
+ /* Attempt to read value from file in checkout if there wasn't a cache hit. */
19171917
if( cacheEntry==0 ){
1918
+ Blob setting;
19181919
Blob versionedPathname;
19191920
char *zVersionedPathname;
19201921
blob_zero(&versionedPathname);
19211922
blob_appendf(&versionedPathname, "%s.fossil-settings/%s",
19221923
g.zLocalRoot, zName);
19231924
zVersionedPathname = blob_str(&versionedPathname);
1924
- if( file_size(zVersionedPathname)>=0 ){
1925
+ blob_zero(&setting);
1926
+ if( !g.localOpen ){
1927
+ if( historical_version_of_file(g.zOpenRevision, zVersionedPathname,
1928
+ &setting, 0, 0, 0, -1)!=-1 ){
1929
+ found = 1;
1930
+ }
1931
+ noWarn = 1;
1932
+ }else if( file_size(zVersionedPathname)>=0 ){
19251933
/* File exists, and contains the value for this setting. Load from
19261934
** the file. */
1927
- Blob setting;
1928
- blob_zero(&setting);
19291935
if( blob_read_from_file(&setting, zVersionedPathname) >= 0 ){
1930
- blob_trim(&setting); /* Avoid non-obvious problems with line endings
1931
- ** on boolean properties */
1932
- zVersionedSetting = strdup(blob_str(&setting));
1936
+ found = 1;
19331937
}
1934
- blob_reset(&setting);
19351938
/* See if there's a no-warn flag */
19361939
blob_append(&versionedPathname, ".no-warn", -1);
19371940
if( file_size(blob_str(&versionedPathname))>=0 ){
19381941
noWarn = 1;
19391942
}
19401943
}
1944
+ if( found ){
1945
+ blob_trim(&setting); /* Avoid non-obvious problems with line endings
1946
+ ** on boolean properties */
1947
+ zVersionedSetting = strdup(blob_str(&setting));
1948
+ }
19411949
blob_reset(&versionedPathname);
19421950
/* Store result in cache, which can be the value or 0 if not found */
19431951
cacheEntry = (struct _cacheEntry*)fossil_malloc(sizeof(struct _cacheEntry));
19441952
cacheEntry->next = cache;
19451953
cacheEntry->zName = zName;
19461954
cacheEntry->zValue = fossil_strdup(zVersionedSetting);
19471955
cache = cacheEntry;
1956
+ blob_reset(&setting);
19481957
}
19491958
/* Display a warning? */
19501959
if( zVersionedSetting!=0 && zNonVersionedSetting!=0
19511960
&& zNonVersionedSetting[0]!='\0' && !noWarn
19521961
){
@@ -2218,10 +2227,23 @@
22182227
}
22192228
if( !allowNested && db_open_local(0) ){
22202229
fossil_fatal("already within an open tree rooted at %s", g.zLocalRoot);
22212230
}
22222231
db_open_repository(g.argv[2]);
2232
+
2233
+ /* Figure out which revision to open. */
2234
+ if( !emptyFlag ){
2235
+ if( g.argc==4 ){
2236
+ g.zOpenRevision = g.argv[3];
2237
+ }else if( db_exists("SELECT 1 FROM event WHERE type='ci'") ){
2238
+ g.zOpenRevision = db_get("main-branch", "trunk");
2239
+ }
2240
+ }
2241
+
2242
+ /* Update the allow-symlinks flag now that the revision is known. */
2243
+ g.allowSymlinks = db_get_boolean("allow-symlinks", 0);
2244
+
22232245
#if defined(_WIN32) || defined(__CYGWIN__)
22242246
# define LOCALDB_NAME "./_FOSSIL_"
22252247
#else
22262248
# define LOCALDB_NAME "./.fslckout"
22272249
#endif
@@ -2239,16 +2261,14 @@
22392261
oldArgc = g.argc;
22402262
azNewArgv[0] = g.argv[0];
22412263
g.argv = azNewArgv;
22422264
if( !emptyFlag ){
22432265
g.argc = 3;
2244
- if( oldArgc==4 ){
2245
- azNewArgv[g.argc-1] = oldArgv[3];
2246
- }else if( !db_exists("SELECT 1 FROM event WHERE type='ci'") ){
2247
- azNewArgv[g.argc-1] = "--latest";
2266
+ if( g.zOpenRevision!=0 ){
2267
+ azNewArgv[g.argc-1] = g.zOpenRevision;
22482268
}else{
2249
- azNewArgv[g.argc-1] = db_get("main-branch", "trunk");
2269
+ azNewArgv[g.argc-1] = "--latest";
22502270
}
22512271
if( keepFlag ){
22522272
azNewArgv[g.argc++] = "--keep";
22532273
}
22542274
if( forceMissingFlag ){
22552275
--- src/db.c
+++ src/db.c
@@ -1894,59 +1894,68 @@
1894 ** might be generated.
1895 */
1896 char *db_get_versioned(const char *zName, char *zNonVersionedSetting){
1897 char *zVersionedSetting = 0;
1898 int noWarn = 0;
 
1899 struct _cacheEntry {
1900 struct _cacheEntry *next;
1901 const char *zName, *zValue;
1902 } *cacheEntry = 0;
1903 static struct _cacheEntry *cache = 0;
1904
1905 if( !g.localOpen) return zNonVersionedSetting;
1906 /* Look up name in cache */
1907 cacheEntry = cache;
1908 while( cacheEntry!=0 ){
1909 if( fossil_strcmp(cacheEntry->zName, zName)==0 ){
1910 zVersionedSetting = fossil_strdup(cacheEntry->zValue);
1911 break;
1912 }
1913 cacheEntry = cacheEntry->next;
1914 }
1915 /* Attempt to read value from file in checkout if there wasn't a cache hit
1916 ** and a checkout is open. */
1917 if( cacheEntry==0 ){
 
1918 Blob versionedPathname;
1919 char *zVersionedPathname;
1920 blob_zero(&versionedPathname);
1921 blob_appendf(&versionedPathname, "%s.fossil-settings/%s",
1922 g.zLocalRoot, zName);
1923 zVersionedPathname = blob_str(&versionedPathname);
1924 if( file_size(zVersionedPathname)>=0 ){
 
 
 
 
 
 
 
1925 /* File exists, and contains the value for this setting. Load from
1926 ** the file. */
1927 Blob setting;
1928 blob_zero(&setting);
1929 if( blob_read_from_file(&setting, zVersionedPathname) >= 0 ){
1930 blob_trim(&setting); /* Avoid non-obvious problems with line endings
1931 ** on boolean properties */
1932 zVersionedSetting = strdup(blob_str(&setting));
1933 }
1934 blob_reset(&setting);
1935 /* See if there's a no-warn flag */
1936 blob_append(&versionedPathname, ".no-warn", -1);
1937 if( file_size(blob_str(&versionedPathname))>=0 ){
1938 noWarn = 1;
1939 }
1940 }
 
 
 
 
 
1941 blob_reset(&versionedPathname);
1942 /* Store result in cache, which can be the value or 0 if not found */
1943 cacheEntry = (struct _cacheEntry*)fossil_malloc(sizeof(struct _cacheEntry));
1944 cacheEntry->next = cache;
1945 cacheEntry->zName = zName;
1946 cacheEntry->zValue = fossil_strdup(zVersionedSetting);
1947 cache = cacheEntry;
 
1948 }
1949 /* Display a warning? */
1950 if( zVersionedSetting!=0 && zNonVersionedSetting!=0
1951 && zNonVersionedSetting[0]!='\0' && !noWarn
1952 ){
@@ -2218,10 +2227,23 @@
2218 }
2219 if( !allowNested && db_open_local(0) ){
2220 fossil_fatal("already within an open tree rooted at %s", g.zLocalRoot);
2221 }
2222 db_open_repository(g.argv[2]);
 
 
 
 
 
 
 
 
 
 
 
 
 
2223 #if defined(_WIN32) || defined(__CYGWIN__)
2224 # define LOCALDB_NAME "./_FOSSIL_"
2225 #else
2226 # define LOCALDB_NAME "./.fslckout"
2227 #endif
@@ -2239,16 +2261,14 @@
2239 oldArgc = g.argc;
2240 azNewArgv[0] = g.argv[0];
2241 g.argv = azNewArgv;
2242 if( !emptyFlag ){
2243 g.argc = 3;
2244 if( oldArgc==4 ){
2245 azNewArgv[g.argc-1] = oldArgv[3];
2246 }else if( !db_exists("SELECT 1 FROM event WHERE type='ci'") ){
2247 azNewArgv[g.argc-1] = "--latest";
2248 }else{
2249 azNewArgv[g.argc-1] = db_get("main-branch", "trunk");
2250 }
2251 if( keepFlag ){
2252 azNewArgv[g.argc++] = "--keep";
2253 }
2254 if( forceMissingFlag ){
2255
--- src/db.c
+++ src/db.c
@@ -1894,59 +1894,68 @@
1894 ** might be generated.
1895 */
1896 char *db_get_versioned(const char *zName, char *zNonVersionedSetting){
1897 char *zVersionedSetting = 0;
1898 int noWarn = 0;
1899 int found = 0;
1900 struct _cacheEntry {
1901 struct _cacheEntry *next;
1902 const char *zName, *zValue;
1903 } *cacheEntry = 0;
1904 static struct _cacheEntry *cache = 0;
1905
1906 if( !g.localOpen && g.zOpenRevision==0 ) return zNonVersionedSetting;
1907 /* Look up name in cache */
1908 cacheEntry = cache;
1909 while( cacheEntry!=0 ){
1910 if( fossil_strcmp(cacheEntry->zName, zName)==0 ){
1911 zVersionedSetting = fossil_strdup(cacheEntry->zValue);
1912 break;
1913 }
1914 cacheEntry = cacheEntry->next;
1915 }
1916 /* Attempt to read value from file in checkout if there wasn't a cache hit. */
 
1917 if( cacheEntry==0 ){
1918 Blob setting;
1919 Blob versionedPathname;
1920 char *zVersionedPathname;
1921 blob_zero(&versionedPathname);
1922 blob_appendf(&versionedPathname, "%s.fossil-settings/%s",
1923 g.zLocalRoot, zName);
1924 zVersionedPathname = blob_str(&versionedPathname);
1925 blob_zero(&setting);
1926 if( !g.localOpen ){
1927 if( historical_version_of_file(g.zOpenRevision, zVersionedPathname,
1928 &setting, 0, 0, 0, -1)!=-1 ){
1929 found = 1;
1930 }
1931 noWarn = 1;
1932 }else if( file_size(zVersionedPathname)>=0 ){
1933 /* File exists, and contains the value for this setting. Load from
1934 ** the file. */
 
 
1935 if( blob_read_from_file(&setting, zVersionedPathname) >= 0 ){
1936 found = 1;
 
 
1937 }
 
1938 /* See if there's a no-warn flag */
1939 blob_append(&versionedPathname, ".no-warn", -1);
1940 if( file_size(blob_str(&versionedPathname))>=0 ){
1941 noWarn = 1;
1942 }
1943 }
1944 if( found ){
1945 blob_trim(&setting); /* Avoid non-obvious problems with line endings
1946 ** on boolean properties */
1947 zVersionedSetting = strdup(blob_str(&setting));
1948 }
1949 blob_reset(&versionedPathname);
1950 /* Store result in cache, which can be the value or 0 if not found */
1951 cacheEntry = (struct _cacheEntry*)fossil_malloc(sizeof(struct _cacheEntry));
1952 cacheEntry->next = cache;
1953 cacheEntry->zName = zName;
1954 cacheEntry->zValue = fossil_strdup(zVersionedSetting);
1955 cache = cacheEntry;
1956 blob_reset(&setting);
1957 }
1958 /* Display a warning? */
1959 if( zVersionedSetting!=0 && zNonVersionedSetting!=0
1960 && zNonVersionedSetting[0]!='\0' && !noWarn
1961 ){
@@ -2218,10 +2227,23 @@
2227 }
2228 if( !allowNested && db_open_local(0) ){
2229 fossil_fatal("already within an open tree rooted at %s", g.zLocalRoot);
2230 }
2231 db_open_repository(g.argv[2]);
2232
2233 /* Figure out which revision to open. */
2234 if( !emptyFlag ){
2235 if( g.argc==4 ){
2236 g.zOpenRevision = g.argv[3];
2237 }else if( db_exists("SELECT 1 FROM event WHERE type='ci'") ){
2238 g.zOpenRevision = db_get("main-branch", "trunk");
2239 }
2240 }
2241
2242 /* Update the allow-symlinks flag now that the revision is known. */
2243 g.allowSymlinks = db_get_boolean("allow-symlinks", 0);
2244
2245 #if defined(_WIN32) || defined(__CYGWIN__)
2246 # define LOCALDB_NAME "./_FOSSIL_"
2247 #else
2248 # define LOCALDB_NAME "./.fslckout"
2249 #endif
@@ -2239,16 +2261,14 @@
2261 oldArgc = g.argc;
2262 azNewArgv[0] = g.argv[0];
2263 g.argv = azNewArgv;
2264 if( !emptyFlag ){
2265 g.argc = 3;
2266 if( g.zOpenRevision!=0 ){
2267 azNewArgv[g.argc-1] = g.zOpenRevision;
 
 
2268 }else{
2269 azNewArgv[g.argc-1] = "--latest";
2270 }
2271 if( keepFlag ){
2272 azNewArgv[g.argc++] = "--keep";
2273 }
2274 if( forceMissingFlag ){
2275
+1
--- src/json.c
+++ src/json.c
@@ -1292,10 +1292,11 @@
12921292
INT(g, nAux);
12931293
INT(g, allowSymlinks);
12941294
12951295
CSTR(g, zMainDbType);
12961296
CSTR(g, zConfigDbType);
1297
+ CSTR(g, zOpenRevision);
12971298
CSTR(g, zLocalRoot);
12981299
CSTR(g, zPath);
12991300
CSTR(g, zExtra);
13001301
CSTR(g, zBaseURL);
13011302
CSTR(g, zTop);
13021303
--- src/json.c
+++ src/json.c
@@ -1292,10 +1292,11 @@
1292 INT(g, nAux);
1293 INT(g, allowSymlinks);
1294
1295 CSTR(g, zMainDbType);
1296 CSTR(g, zConfigDbType);
 
1297 CSTR(g, zLocalRoot);
1298 CSTR(g, zPath);
1299 CSTR(g, zExtra);
1300 CSTR(g, zBaseURL);
1301 CSTR(g, zTop);
1302
--- src/json.c
+++ src/json.c
@@ -1292,10 +1292,11 @@
1292 INT(g, nAux);
1293 INT(g, allowSymlinks);
1294
1295 CSTR(g, zMainDbType);
1296 CSTR(g, zConfigDbType);
1297 CSTR(g, zOpenRevision);
1298 CSTR(g, zLocalRoot);
1299 CSTR(g, zPath);
1300 CSTR(g, zExtra);
1301 CSTR(g, zBaseURL);
1302 CSTR(g, zTop);
1303
+1
--- src/main.c
+++ src/main.c
@@ -135,10 +135,11 @@
135135
char *zRepositoryOption; /* Most recent cached repository option value */
136136
char *zRepositoryName; /* Name of the repository database */
137137
char *zLocalDbName; /* Name of the local database */
138138
const char *zMainDbType;/* "configdb", "localdb", or "repository" */
139139
const char *zConfigDbType; /* "configdb", "localdb", or "repository" */
140
+ char *zOpenRevision; /* Check-in version to during database open */
140141
int localOpen; /* True if the local database is open */
141142
char *zLocalRoot; /* The directory holding the local database */
142143
int minPrefix; /* Number of digits needed for a distinct UUID */
143144
int fSqlTrace; /* True if --sqltrace flag is present */
144145
int fSqlStats; /* True if --sqltrace or --sqlstats are present */
145146
--- src/main.c
+++ src/main.c
@@ -135,10 +135,11 @@
135 char *zRepositoryOption; /* Most recent cached repository option value */
136 char *zRepositoryName; /* Name of the repository database */
137 char *zLocalDbName; /* Name of the local database */
138 const char *zMainDbType;/* "configdb", "localdb", or "repository" */
139 const char *zConfigDbType; /* "configdb", "localdb", or "repository" */
 
140 int localOpen; /* True if the local database is open */
141 char *zLocalRoot; /* The directory holding the local database */
142 int minPrefix; /* Number of digits needed for a distinct UUID */
143 int fSqlTrace; /* True if --sqltrace flag is present */
144 int fSqlStats; /* True if --sqltrace or --sqlstats are present */
145
--- src/main.c
+++ src/main.c
@@ -135,10 +135,11 @@
135 char *zRepositoryOption; /* Most recent cached repository option value */
136 char *zRepositoryName; /* Name of the repository database */
137 char *zLocalDbName; /* Name of the local database */
138 const char *zMainDbType;/* "configdb", "localdb", or "repository" */
139 const char *zConfigDbType; /* "configdb", "localdb", or "repository" */
140 char *zOpenRevision; /* Check-in version to during database open */
141 int localOpen; /* True if the local database is open */
142 char *zLocalRoot; /* The directory holding the local database */
143 int minPrefix; /* Number of digits needed for a distinct UUID */
144 int fSqlTrace; /* True if --sqltrace flag is present */
145 int fSqlStats; /* True if --sqltrace or --sqlstats are present */
146

Keyboard Shortcuts

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