| | @@ -1894,53 +1894,70 @@ |
| 1894 | 1894 | ** might be generated. |
| 1895 | 1895 | */ |
| 1896 | 1896 | char *db_get_versioned(const char *zName, char *zNonVersionedSetting){ |
| 1897 | 1897 | char *zVersionedSetting = 0; |
| 1898 | 1898 | int noWarn = 0; |
| 1899 | + int found = 0; |
| 1899 | 1900 | struct _cacheEntry { |
| 1900 | 1901 | struct _cacheEntry *next; |
| 1901 | 1902 | const char *zName, *zValue; |
| 1902 | 1903 | } *cacheEntry = 0; |
| 1903 | 1904 | static struct _cacheEntry *cache = 0; |
| 1904 | 1905 | |
| 1905 | | - if( !g.localOpen) return zNonVersionedSetting; |
| 1906 | + if( !g.localOpen && g.zOpenRevision==0 ) return zNonVersionedSetting; |
| 1906 | 1907 | /* Look up name in cache */ |
| 1907 | 1908 | cacheEntry = cache; |
| 1908 | 1909 | while( cacheEntry!=0 ){ |
| 1909 | 1910 | if( fossil_strcmp(cacheEntry->zName, zName)==0 ){ |
| 1910 | 1911 | zVersionedSetting = fossil_strdup(cacheEntry->zValue); |
| 1911 | 1912 | break; |
| 1912 | 1913 | } |
| 1913 | 1914 | cacheEntry = cacheEntry->next; |
| 1914 | 1915 | } |
| 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. */ |
| 1917 | 1917 | if( cacheEntry==0 ){ |
| 1918 | 1918 | Blob versionedPathname; |
| 1919 | | - char *zVersionedPathname; |
| 1919 | + Blob setting; |
| 1920 | 1920 | blob_zero(&versionedPathname); |
| 1921 | + blob_zero(&setting); |
| 1921 | 1922 | blob_appendf(&versionedPathname, "%s.fossil-settings/%s", |
| 1922 | 1923 | g.zLocalRoot, zName); |
| 1923 | | - zVersionedPathname = blob_str(&versionedPathname); |
| 1924 | | - if( file_size(zVersionedPathname)>=0 ){ |
| 1924 | + if( !g.localOpen ){ |
| 1925 | + Blob noWarnFile; |
| 1926 | + if( historical_version_of_file(g.zOpenRevision, |
| 1927 | + blob_str(&versionedPathname), |
| 1928 | + &setting, 0, 0, 0, 2)!=2 ){ |
| 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, 2)!=2 ){ |
| 1937 | + noWarn = 1; |
| 1938 | + } |
| 1939 | + blob_reset(&noWarnFile); |
| 1940 | + }else if( file_size(blob_str(&versionedPathname))>=0 ){ |
| 1925 | 1941 | /* File exists, and contains the value for this setting. Load from |
| 1926 | 1942 | ** 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 = fossil_strdup(blob_str(&setting)); |
| 1933 | | - } |
| 1934 | | - blob_reset(&setting); |
| 1943 | + if( blob_read_from_file(&setting, blob_str(&versionedPathname))>=0 ){ |
| 1944 | + found = 1; |
| 1945 | + } |
| 1935 | 1946 | /* See if there's a no-warn flag */ |
| 1936 | 1947 | blob_append(&versionedPathname, ".no-warn", -1); |
| 1937 | 1948 | if( file_size(blob_str(&versionedPathname))>=0 ){ |
| 1938 | 1949 | noWarn = 1; |
| 1939 | 1950 | } |
| 1940 | 1951 | } |
| 1941 | 1952 | blob_reset(&versionedPathname); |
| 1953 | + if( found ){ |
| 1954 | + blob_trim(&setting); /* Avoid non-obvious problems with line endings |
| 1955 | + ** on boolean properties */ |
| 1956 | + zVersionedSetting = fossil_strdup(blob_str(&setting)); |
| 1957 | + } |
| 1958 | + blob_reset(&setting); |
| 1942 | 1959 | /* Store result in cache, which can be the value or 0 if not found */ |
| 1943 | 1960 | cacheEntry = (struct _cacheEntry*)fossil_malloc(sizeof(struct _cacheEntry)); |
| 1944 | 1961 | cacheEntry->next = cache; |
| 1945 | 1962 | cacheEntry->zName = zName; |
| 1946 | 1963 | cacheEntry->zValue = fossil_strdup(zVersionedSetting); |
| | @@ -2218,10 +2235,26 @@ |
| 2218 | 2235 | } |
| 2219 | 2236 | if( !allowNested && db_open_local(0) ){ |
| 2220 | 2237 | fossil_fatal("already within an open tree rooted at %s", g.zLocalRoot); |
| 2221 | 2238 | } |
| 2222 | 2239 | db_open_repository(g.argv[2]); |
| 2240 | + |
| 2241 | + /* Figure out which revision to open. */ |
| 2242 | + if( !emptyFlag ){ |
| 2243 | + if( g.argc==4 ){ |
| 2244 | + g.zOpenRevision = g.argv[3]; |
| 2245 | + }else if( db_exists("SELECT 1 FROM event WHERE type='ci'") ){ |
| 2246 | + g.zOpenRevision = db_get("main-branch", "trunk"); |
| 2247 | + } |
| 2248 | + } |
| 2249 | + |
| 2250 | + if( g.zOpenRevision ){ |
| 2251 | + /* Since the repository is open and we know the revision now, |
| 2252 | + ** refresh the allow-symlinks flag. */ |
| 2253 | + g.allowSymlinks = db_get_boolean("allow-symlinks", 0); |
| 2254 | + } |
| 2255 | + |
| 2223 | 2256 | #if defined(_WIN32) || defined(__CYGWIN__) |
| 2224 | 2257 | # define LOCALDB_NAME "./_FOSSIL_" |
| 2225 | 2258 | #else |
| 2226 | 2259 | # define LOCALDB_NAME "./.fslckout" |
| 2227 | 2260 | #endif |
| | @@ -2239,16 +2272,14 @@ |
| 2239 | 2272 | oldArgc = g.argc; |
| 2240 | 2273 | azNewArgv[0] = g.argv[0]; |
| 2241 | 2274 | g.argv = azNewArgv; |
| 2242 | 2275 | if( !emptyFlag ){ |
| 2243 | 2276 | 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"; |
| 2277 | + if( g.zOpenRevision ){ |
| 2278 | + azNewArgv[g.argc-1] = g.zOpenRevision; |
| 2248 | 2279 | }else{ |
| 2249 | | - azNewArgv[g.argc-1] = db_get("main-branch", "trunk"); |
| 2280 | + azNewArgv[g.argc-1] = "--latest"; |
| 2250 | 2281 | } |
| 2251 | 2282 | if( keepFlag ){ |
| 2252 | 2283 | azNewArgv[g.argc++] = "--keep"; |
| 2253 | 2284 | } |
| 2254 | 2285 | if( forceMissingFlag ){ |
| 2255 | 2286 | |