1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
/*
** Copyright (c) 2006 D. Richard Hipp
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public
** License version 2 as published by the Free Software Foundation.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
** General Public License for more details.
**
** You should have received a copy of the GNU General Public
** License along with this library; if not, write to the
** Free Software Foundation, Inc., 59 Temple Place - Suite 330,
** Boston, MA 02111-1307, USA.
**
** Author contact information:
** drh@hwaci.com
** http://www.hwaci.com/drh/
**
*******************************************************************************
**
** Code for interfacing to the various databases.
**
** There are three separate database files that fossil interacts
** with:
**
** (1) The "user" database in ~/.fossil
**
|
|
|
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
/*
** Copyright (c) 2006 D. Richard Hipp
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public
** License version 2 as published by the Free Software Foundation.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
** General Public License for more details.
**
** You should have received a copy of the GNU General Public
** License along with this library; if not, write to the
** Free Software Foundation, Inc., 59 Temple Place - Suite 330,
** Boston, MA 02111-1307, USA.
**
** Author contact information:
** drh@hwaci.com
** http://www.hwaci.com/drh/
**
*******************************************************************************
**
** Code for interfacing to the various databases.
**
** There are three separate database files that fossil interacts
** with:
**
** (1) The "user" database in ~/.fossil
**
|
︙ | | | ︙ | |
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
}
void db_force_rollback(void){
if( nBegin ){
sqlite3_exec(g.db, "ROLLBACK", 0, 0, 0);
}
nBegin = 0;
}
/*
** Prepare or reprepare the sqlite3 statement from the raw SQL text.
*/
static void reprepare(Stmt *pStmt){
sqlite3_stmt *pNew;
if( sqlite3_prepare(g.db, blob_buffer(&pStmt->sql), -1, &pNew, 0)!=0 ){
db_err("%s\n%s", blob_str(&pStmt->sql), sqlite3_errmsg(g.db));
|
|
|
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
}
void db_force_rollback(void){
if( nBegin ){
sqlite3_exec(g.db, "ROLLBACK", 0, 0, 0);
}
nBegin = 0;
}
/*
** Prepare or reprepare the sqlite3 statement from the raw SQL text.
*/
static void reprepare(Stmt *pStmt){
sqlite3_stmt *pNew;
if( sqlite3_prepare(g.db, blob_buffer(&pStmt->sql), -1, &pNew, 0)!=0 ){
db_err("%s\n%s", blob_str(&pStmt->sql), sqlite3_errmsg(g.db));
|
︙ | | | ︙ | |
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
|
}
/*
** 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.
**
** 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.
|
|
|
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
|
}
/*
** 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.
**
** 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.
|
︙ | | | ︙ | |
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
|
** not server and project codes are invented for this repository.
*/
void db_initial_setup (int makeInitialVersion, int makeServerCodes){
char *zDate;
const char *zUser;
Blob hash;
Blob manifest;
db_set("content-schema", CONTENT_SCHEMA, 0);
db_set("aux-schema", AUX_SCHEMA, 0);
if( makeServerCodes ){
db_multi_exec(
"INSERT INTO config(name,value)"
" VALUES('server-code', lower(hex(randomblob(20))));"
"INSERT INTO config(name,value)"
|
|
|
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
|
** not server and project codes are invented for this repository.
*/
void db_initial_setup (int makeInitialVersion, int makeServerCodes){
char *zDate;
const char *zUser;
Blob hash;
Blob manifest;
db_set("content-schema", CONTENT_SCHEMA, 0);
db_set("aux-schema", AUX_SCHEMA, 0);
if( makeServerCodes ){
db_multi_exec(
"INSERT INTO config(name,value)"
" VALUES('server-code', lower(hex(randomblob(20))));"
"INSERT INTO config(name,value)"
|
︙ | | | ︙ | |
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
|
globalFlag ? "global_" : "", zName, value);
if( globalFlag && g.repositoryOpen ){
db_multi_exec("DELETE FROM config WHERE name=%Q", zName);
}
db_end_transaction(0);
}
char *db_lget(const char *zName, char *zDefault){
return db_text((char*)zDefault,
"SELECT value FROM vvar WHERE name=%Q", zName);
}
void db_lset(const char *zName, const char *zValue){
db_multi_exec("REPLACE INTO vvar(name,value) VALUES(%Q,%Q)", zName, zValue);
}
int db_lget_int(const char *zName, int dflt){
return db_int(dflt, "SELECT value FROM vvar WHERE name=%Q", zName);
|
|
|
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
|
globalFlag ? "global_" : "", zName, value);
if( globalFlag && g.repositoryOpen ){
db_multi_exec("DELETE FROM config WHERE name=%Q", zName);
}
db_end_transaction(0);
}
char *db_lget(const char *zName, char *zDefault){
return db_text((char*)zDefault,
"SELECT value FROM vvar WHERE name=%Q", zName);
}
void db_lset(const char *zName, const char *zValue){
db_multi_exec("REPLACE INTO vvar(name,value) VALUES(%Q,%Q)", zName, zValue);
}
int db_lget_int(const char *zName, int dflt){
return db_int(dflt, "SELECT value FROM vvar WHERE name=%Q", zName);
|
︙ | | | ︙ | |
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
|
}
/*
** Print the value of a setting named zName
*/
static void print_setting(const char *zName){
Stmt q;
db_prepare(&q,
"SELECT '(local)', value FROM config WHERE name=%Q"
" UNION ALL "
"SELECT '(global)', value FROM global_config WHERE name=%Q",
zName, zName
);
if( db_step(&q)==SQLITE_ROW ){
printf("%-20s %-8s %s\n", zName, db_column_text(&q, 0),
|
|
|
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
|
}
/*
** Print the value of a setting named zName
*/
static void print_setting(const char *zName){
Stmt q;
db_prepare(&q,
"SELECT '(local)', value FROM config WHERE name=%Q"
" UNION ALL "
"SELECT '(global)', value FROM global_config WHERE name=%Q",
zName, zName
);
if( db_step(&q)==SQLITE_ROW ){
printf("%-20s %-8s %s\n", zName, db_column_text(&q, 0),
|
︙ | | | ︙ | |
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
|
**
** omitsign When enabled, fossil will not attempt to sign any
** commit with gpg. All commits will be unsigned.
**
** safemerge If enabled, when commit will cause a fork, the
** commit will not abort with warning. Also update
** will not be allowed if local changes exist.
*/
void setting_cmd(void){
static const char *azName[] = {
"autosync",
"clearsign",
"editor",
"localauth",
"omitsign",
"safemerge",
};
int i;
int globalFlag = find_option("global","g",0)!=0;
db_find_and_open_repository();
if( g.argc==2 ){
for(i=0; i<sizeof(azName)/sizeof(azName[0]); i++){
print_setting(azName[i]);
|
>
>
>
>
>
>
>
>
|
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
|
**
** omitsign When enabled, fossil will not attempt to sign any
** commit with gpg. All commits will be unsigned.
**
** safemerge If enabled, when commit will cause a fork, the
** commit will not abort with warning. Also update
** will not be allowed if local changes exist.
**
** diff-command External command to run when performing a diff.
** If undefined, the internal text diff will be used.
**
** gdiff-command External command to run when performing a graphical
** diff. If undefined, text diff will be used.
*/
void setting_cmd(void){
static const char *azName[] = {
"autosync",
"clearsign",
"editor",
"localauth",
"omitsign",
"safemerge",
"diff-command",
"gdiff-command",
};
int i;
int globalFlag = find_option("global","g",0)!=0;
db_find_and_open_repository();
if( g.argc==2 ){
for(i=0; i<sizeof(azName)/sizeof(azName[0]); i++){
print_setting(azName[i]);
|
︙ | | | ︙ | |