26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
** There are three separate database files that fossil interacts
** with:
**
** (1) The "user" database in ~/.fossil
**
** (2) The "repository" database
**
** (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__
# include <pwd.h>
#endif
|
|
|
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
** There are three separate database files that fossil interacts
** with:
**
** (1) The "user" database in ~/.fossil
**
** (2) The "repository" database
**
** (3) A local checkout database named "_MYCFG_" or ".fos"
** and located at the root of the local copy of the source tree.
**
*/
#include "config.h"
#ifndef __MINGW32__
# include <pwd.h>
#endif
|
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
|
db_open_config();
db_open_repository(0);
return 1;
}
/*
** Locate the root directory of the local repository tree. The root
** 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_ or .fos file
** is found, it is attached to the open database connection too.
*/
int db_open_local(void){
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);
}
n = strlen(zPwd);
zPwdConv = mprintf("%/", zPwd);
|
|
|
|
|
|
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
|
db_open_config();
db_open_repository(0);
return 1;
}
/*
** Locate the root directory of the local repository tree. The root
** directory is found by searching for a file named "_MYCFG_" or ".fos"
** that contains a valid repository database.
**
** If no valid _MYCFG_ 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 _MYCFG_ or .fos file
** is found, it is attached to the open database connection too.
*/
int db_open_local(void){
int i, n;
char zPwd[2000];
char *zPwdConv;
static const char *aDbName[] = { "/_MYCFG_", "/.fos" };
if( g.localOpen) return 1;
if( getcwd(zPwd, sizeof(zPwd)-20)==0 ){
db_err("pwd too big: max %d", sizeof(zPwd)-20);
}
n = strlen(zPwd);
zPwdConv = mprintf("%/", zPwd);
|
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
|
usage("REPOSITORY-FILENAME");
}
if( db_open_local() ){
fossil_panic("already within an open tree rooted at %s", g.zLocalRoot);
}
file_canonical_name(g.argv[2], &path);
db_open_repository(blob_str(&path));
db_init_database("./_FOSSIL_", zLocalSchema, (char*)0);
db_open_local();
db_lset("repository", blob_str(&path));
db_record_repository_filename(blob_str(&path));
vid = db_int(0, "SELECT pid FROM plink y"
" WHERE NOT EXISTS(SELECT 1 FROM plink x WHERE x.cid=y.pid)");
if( vid==0 ){
db_lset_int("checkout", 1);
|
|
|
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
|
usage("REPOSITORY-FILENAME");
}
if( db_open_local() ){
fossil_panic("already within an open tree rooted at %s", g.zLocalRoot);
}
file_canonical_name(g.argv[2], &path);
db_open_repository(blob_str(&path));
db_init_database("./_MYCFG_", zLocalSchema, (char*)0);
db_open_local();
db_lset("repository", blob_str(&path));
db_record_repository_filename(blob_str(&path));
vid = db_int(0, "SELECT pid FROM plink y"
" WHERE NOT EXISTS(SELECT 1 FROM plink x WHERE x.cid=y.pid)");
if( vid==0 ){
db_lset_int("checkout", 1);
|