Fossil SCM

Simplify branch changes. The historical_version_of_file() function appears to return ^>0 upon success. Also, remove superfluous slash from '.fossil-settings' path construction in print_setting().

mistachkin 2015-04-08 06:08 andygoth-versioned-open
Commit 20972e8042763226ad6b6a0a02656566ae1324c4
1 file changed +20 -12
+20 -12
--- src/db.c
+++ src/db.c
@@ -1913,49 +1913,57 @@
19131913
}
19141914
cacheEntry = cacheEntry->next;
19151915
}
19161916
/* Attempt to read value from file in checkout if there wasn't a cache hit. */
19171917
if( cacheEntry==0 ){
1918
- Blob setting;
19191918
Blob versionedPathname;
1920
- char *zVersionedPathname;
1919
+ Blob setting;
19211920
blob_zero(&versionedPathname);
1921
+ blob_zero(&setting);
19221922
blob_appendf(&versionedPathname, "%s.fossil-settings/%s",
19231923
g.zLocalRoot, zName);
1924
- zVersionedPathname = blob_str(&versionedPathname);
1925
- blob_zero(&setting);
19261924
if( !g.localOpen ){
1927
- if( historical_version_of_file(g.zOpenRevision, zVersionedPathname,
1928
- &setting, 0, 0, 0, -1)!=-1 ){
1925
+ Blob noWarnFile;
1926
+ if( historical_version_of_file(g.zOpenRevision,
1927
+ blob_str(&versionedPathname),
1928
+ &setting, 0, 0, 0, -1)>0 ){
19291929
found = 1;
19301930
}
1931
- noWarn = 1;
1932
- }else if( file_size(zVersionedPathname)>=0 ){
1931
+ /* See if there's a no-warn flag */
1932
+ blob_append(&versionedPathname, ".no-warn", -1);
1933
+ blob_zero(&noWarnFile);
1934
+ if( historical_version_of_file(g.zOpenRevision,
1935
+ blob_str(&versionedPathname),
1936
+ &noWarnFile, 0, 0, 0, -1)>0 ){
1937
+ noWarn = 1;
1938
+ }
1939
+ blob_reset(&noWarnFile);
1940
+ }else if( file_size(blob_str(&versionedPathname))>=0 ){
19331941
/* File exists, and contains the value for this setting. Load from
19341942
** the file. */
1935
- if( blob_read_from_file(&setting, zVersionedPathname) >= 0 ){
1943
+ if( blob_read_from_file(&setting, blob_str(&versionedPathname))>=0 ){
19361944
found = 1;
19371945
}
19381946
/* See if there's a no-warn flag */
19391947
blob_append(&versionedPathname, ".no-warn", -1);
19401948
if( file_size(blob_str(&versionedPathname))>=0 ){
19411949
noWarn = 1;
19421950
}
19431951
}
1952
+ blob_reset(&versionedPathname);
19441953
if( found ){
19451954
blob_trim(&setting); /* Avoid non-obvious problems with line endings
19461955
** on boolean properties */
19471956
zVersionedSetting = strdup(blob_str(&setting));
19481957
}
1949
- blob_reset(&versionedPathname);
1958
+ blob_reset(&setting);
19501959
/* Store result in cache, which can be the value or 0 if not found */
19511960
cacheEntry = (struct _cacheEntry*)fossil_malloc(sizeof(struct _cacheEntry));
19521961
cacheEntry->next = cache;
19531962
cacheEntry->zName = zName;
19541963
cacheEntry->zValue = fossil_strdup(zVersionedSetting);
19551964
cache = cacheEntry;
1956
- blob_reset(&setting);
19571965
}
19581966
/* Display a warning? */
19591967
if( zVersionedSetting!=0 && zNonVersionedSetting!=0
19601968
&& zNonVersionedSetting[0]!='\0' && !noWarn
19611969
){
@@ -2307,11 +2315,11 @@
23072315
}
23082316
if( pSetting->versionable && g.localOpen ){
23092317
/* Check to see if this is overridden by a versionable settings file */
23102318
Blob versionedPathname;
23112319
blob_zero(&versionedPathname);
2312
- blob_appendf(&versionedPathname, "%s/.fossil-settings/%s",
2320
+ blob_appendf(&versionedPathname, "%s.fossil-settings/%s",
23132321
g.zLocalRoot, pSetting->name);
23142322
if( file_size(blob_str(&versionedPathname))>=0 ){
23152323
fossil_print(" (overridden by contents of file .fossil-settings/%s)\n",
23162324
pSetting->name);
23172325
}
23182326
--- src/db.c
+++ src/db.c
@@ -1913,49 +1913,57 @@
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 ){
@@ -2307,11 +2315,11 @@
2307 }
2308 if( pSetting->versionable && g.localOpen ){
2309 /* Check to see if this is overridden by a versionable settings file */
2310 Blob versionedPathname;
2311 blob_zero(&versionedPathname);
2312 blob_appendf(&versionedPathname, "%s/.fossil-settings/%s",
2313 g.zLocalRoot, pSetting->name);
2314 if( file_size(blob_str(&versionedPathname))>=0 ){
2315 fossil_print(" (overridden by contents of file .fossil-settings/%s)\n",
2316 pSetting->name);
2317 }
2318
--- src/db.c
+++ src/db.c
@@ -1913,49 +1913,57 @@
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 versionedPathname;
1919 Blob setting;
1920 blob_zero(&versionedPathname);
1921 blob_zero(&setting);
1922 blob_appendf(&versionedPathname, "%s.fossil-settings/%s",
1923 g.zLocalRoot, zName);
 
 
1924 if( !g.localOpen ){
1925 Blob noWarnFile;
1926 if( historical_version_of_file(g.zOpenRevision,
1927 blob_str(&versionedPathname),
1928 &setting, 0, 0, 0, -1)>0 ){
1929 found = 1;
1930 }
1931 /* See if there's a no-warn flag */
1932 blob_append(&versionedPathname, ".no-warn", -1);
1933 blob_zero(&noWarnFile);
1934 if( historical_version_of_file(g.zOpenRevision,
1935 blob_str(&versionedPathname),
1936 &noWarnFile, 0, 0, 0, -1)>0 ){
1937 noWarn = 1;
1938 }
1939 blob_reset(&noWarnFile);
1940 }else if( file_size(blob_str(&versionedPathname))>=0 ){
1941 /* File exists, and contains the value for this setting. Load from
1942 ** the file. */
1943 if( blob_read_from_file(&setting, blob_str(&versionedPathname))>=0 ){
1944 found = 1;
1945 }
1946 /* See if there's a no-warn flag */
1947 blob_append(&versionedPathname, ".no-warn", -1);
1948 if( file_size(blob_str(&versionedPathname))>=0 ){
1949 noWarn = 1;
1950 }
1951 }
1952 blob_reset(&versionedPathname);
1953 if( found ){
1954 blob_trim(&setting); /* Avoid non-obvious problems with line endings
1955 ** on boolean properties */
1956 zVersionedSetting = strdup(blob_str(&setting));
1957 }
1958 blob_reset(&setting);
1959 /* Store result in cache, which can be the value or 0 if not found */
1960 cacheEntry = (struct _cacheEntry*)fossil_malloc(sizeof(struct _cacheEntry));
1961 cacheEntry->next = cache;
1962 cacheEntry->zName = zName;
1963 cacheEntry->zValue = fossil_strdup(zVersionedSetting);
1964 cache = cacheEntry;
 
1965 }
1966 /* Display a warning? */
1967 if( zVersionedSetting!=0 && zNonVersionedSetting!=0
1968 && zNonVersionedSetting[0]!='\0' && !noWarn
1969 ){
@@ -2307,11 +2315,11 @@
2315 }
2316 if( pSetting->versionable && g.localOpen ){
2317 /* Check to see if this is overridden by a versionable settings file */
2318 Blob versionedPathname;
2319 blob_zero(&versionedPathname);
2320 blob_appendf(&versionedPathname, "%s.fossil-settings/%s",
2321 g.zLocalRoot, pSetting->name);
2322 if( file_size(blob_str(&versionedPathname))>=0 ){
2323 fossil_print(" (overridden by contents of file .fossil-settings/%s)\n",
2324 pSetting->name);
2325 }
2326

Keyboard Shortcuts

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