Fossil SCM

Integrate andygoth-versioned-open. This makes "fossil open" respect ".fossil-settings/allow-symlinks".

andygoth 2015-05-15 01:41 trunk merge
Commit 010451e7a5fe116a878d57dacb94989134d48132
+50 -19
--- src/db.c
+++ src/db.c
@@ -1894,53 +1894,70 @@
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 ){
19181918
Blob versionedPathname;
1919
- char *zVersionedPathname;
1919
+ Blob setting;
19201920
blob_zero(&versionedPathname);
1921
+ blob_zero(&setting);
19211922
blob_appendf(&versionedPathname, "%s.fossil-settings/%s",
19221923
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 ){
19251941
/* File exists, and contains the value for this setting. Load from
19261942
** 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
+ }
19351946
/* See if there's a no-warn flag */
19361947
blob_append(&versionedPathname, ".no-warn", -1);
19371948
if( file_size(blob_str(&versionedPathname))>=0 ){
19381949
noWarn = 1;
19391950
}
19401951
}
19411952
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);
19421959
/* Store result in cache, which can be the value or 0 if not found */
19431960
cacheEntry = (struct _cacheEntry*)fossil_malloc(sizeof(struct _cacheEntry));
19441961
cacheEntry->next = cache;
19451962
cacheEntry->zName = zName;
19461963
cacheEntry->zValue = fossil_strdup(zVersionedSetting);
@@ -2218,10 +2235,26 @@
22182235
}
22192236
if( !allowNested && db_open_local(0) ){
22202237
fossil_fatal("already within an open tree rooted at %s", g.zLocalRoot);
22212238
}
22222239
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
+
22232256
#if defined(_WIN32) || defined(__CYGWIN__)
22242257
# define LOCALDB_NAME "./_FOSSIL_"
22252258
#else
22262259
# define LOCALDB_NAME "./.fslckout"
22272260
#endif
@@ -2239,16 +2272,14 @@
22392272
oldArgc = g.argc;
22402273
azNewArgv[0] = g.argv[0];
22412274
g.argv = azNewArgv;
22422275
if( !emptyFlag ){
22432276
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;
22482279
}else{
2249
- azNewArgv[g.argc-1] = db_get("main-branch", "trunk");
2280
+ azNewArgv[g.argc-1] = "--latest";
22502281
}
22512282
if( keepFlag ){
22522283
azNewArgv[g.argc++] = "--keep";
22532284
}
22542285
if( forceMissingFlag ){
22552286
--- src/db.c
+++ src/db.c
@@ -1894,53 +1894,70 @@
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 = fossil_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);
@@ -2218,10 +2235,26 @@
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 +2272,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,53 +1894,70 @@
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 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, 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 ){
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 = fossil_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);
@@ -2218,10 +2235,26 @@
2235 }
2236 if( !allowNested && db_open_local(0) ){
2237 fossil_fatal("already within an open tree rooted at %s", g.zLocalRoot);
2238 }
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
2256 #if defined(_WIN32) || defined(__CYGWIN__)
2257 # define LOCALDB_NAME "./_FOSSIL_"
2258 #else
2259 # define LOCALDB_NAME "./.fslckout"
2260 #endif
@@ -2239,16 +2272,14 @@
2272 oldArgc = g.argc;
2273 azNewArgv[0] = g.argv[0];
2274 g.argv = azNewArgv;
2275 if( !emptyFlag ){
2276 g.argc = 3;
2277 if( g.zOpenRevision ){
2278 azNewArgv[g.argc-1] = g.zOpenRevision;
 
 
2279 }else{
2280 azNewArgv[g.argc-1] = "--latest";
2281 }
2282 if( keepFlag ){
2283 azNewArgv[g.argc++] = "--keep";
2284 }
2285 if( forceMissingFlag ){
2286
+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
+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