Differences From:
File
src/db.c
part of check-in
[2bd0690fe8]
- Add the "all rebuild" subcommand. Be more aggressive about adding
repositories to the repository list.
by
drh on
2008-10-17 12:31:26.
[view]
To:
File
src/db.c
part of check-in
[8bdea95c58]
- Allow the "_FOSSIL_" file at the root of each check-out to be renamed ".fos".
At some point we might make .fos the default, but for now _FOSSIL_ is the
default. The file can be freely changed between these two names.
by
drh on
2008-10-24 11:14:57.
[view]
@@ -29,10 +29,10 @@
** (1) The "user" database in ~/.fossil
**
** (2) The "repository" database
**
-** (3) A local checkout database named "FOSSIL" and located at the
-** root of the local copy of the source tree.
+** (3) A local checkout database named "_FOSSIL_" or ".fos"
+** and located at the root of the local copy of the source tree.
**
*/
#include "config.h"
#ifndef __MINGW32__
@@ -602,24 +602,26 @@
}
/*
** Locate the root directory of the local repository tree. The root
-** directory is found by searching for a file named "FOSSIL" that contains
-** a valid repository database.
-**
-** If no valid FOSSIL file is found, we move up one level and try again.
-** Once the file is found, the g.zLocalRoot variable is set to the root of
-** the repository tree and this routine returns 1. If no database is
-** found, then this routine return 0.
+** directory is found by searching for a file named "_FOSSIL_" or ".fos"
+** that contains a valid repository database.
+**
+** If no valid _FOSSIL_ or .fos file is found, we move up one level and
+** try again. Once the file is found, the g.zLocalRoot variable is set
+** to the root of the repository tree and this routine returns 1. If
+** no database is found, then this routine return 0.
**
** This routine always opens the user database regardless of whether or
-** not the repository database is found. If the FOSSIL file is found,
-** it is attached to the open database connection too.
+** not the repository database is found. If the _FOSSIL_ or .fos file
+** is found, it is attached to the open database connection too.
*/
int db_open_local(void){
- int n;
+ int i, n;
char zPwd[2000];
char *zPwdConv;
+ static const char *aDbName[] = { "/_FOSSIL_", "/.fos" };
+
if( g.localOpen) return 1;
if( getcwd(zPwd, sizeof(zPwd)-20)==0 ){
db_err("pwd too big: max %d", sizeof(zPwd)-20);
}
@@ -628,22 +630,24 @@
strncpy(zPwd, zPwdConv, 2000-20);
free(zPwdConv);
while( n>0 ){
if( access(zPwd, W_OK) ) break;
- strcpy(&zPwd[n], "/_FOSSIL_");
- if( isValidLocalDb(zPwd) ){
- /* Found a valid _FOSSIL_ file */
- zPwd[n] = 0;
- g.zLocalRoot = mprintf("%s/", zPwd);
- return 1;
+ for(i=0; i<sizeof(aDbName)/sizeof(aDbName[0]); i++){
+ strcpy(&zPwd[n], aDbName[i]);
+ if( isValidLocalDb(zPwd) ){
+ /* Found a valid checkout database file */
+ zPwd[n] = 0;
+ g.zLocalRoot = mprintf("%s/", zPwd);
+ return 1;
+ }
}
n--;
while( n>0 && zPwd[n]!='/' ){ n--; }
while( n>0 && zPwd[n-1]=='/' ){ n--; }
zPwd[n] = 0;
}
- /* A _FOSSIL_ file could not be found */
+ /* A checkout database file could not be found */
return 0;
}
/*