Fossil

Check-in [6b85fd17]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Help message cleanup. Automatically delete cloned database files if the clone fails.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 6b85fd173e5c90ad0c24c4146249a28ff8d2ab18
User & Date: drh 2008-05-10 18:01:52.000
Context
2008-05-10
18:09
Comment changes to the pre-commit verification logic. No changes to code. ... (check-in: 2d581c03 user: drh tags: trunk)
18:01
Help message cleanup. Automatically delete cloned database files if the clone fails. ... (check-in: 6b85fd17 user: drh tags: trunk)
17:22
Add the "unset" command for clearing settings. ... (check-in: 41820798 user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/add.c.
29
30
31
32
33
34
35

36
37
38
39
40
41
42
43
44
#include <assert.h>


/*
** COMMAND: add
**
** Usage: %fossil add FILE...

** Add one or more files to the current checkout such that these files
** will be inserted into the repository at the next commit.
*/
void add_cmd(void){
  int i;
  int vid;

  db_must_be_within_tree();
  vid = db_lget_int("checkout",0);







>
|
|







29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include <assert.h>


/*
** COMMAND: add
**
** Usage: %fossil add FILE...
**
** Make arrangements to add one or more files to the current checkout 
** at the next commit.
*/
void add_cmd(void){
  int i;
  int vid;

  db_must_be_within_tree();
  vid = db_lget_int("checkout",0);
Changes to src/checkin.c.
73
74
75
76
77
78
79

80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95

96

97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114

115

116
117
118
119
120
121
122
  db_finalize(&q);
}

/*
** COMMAND: changes
**
** Usage: %fossil changes

** Report on the edit status of all files in the current checkout.
** See also the "status" and "extra" commands.
*/
void changes_cmd(void){
  Blob report;
  int vid;
  db_must_be_within_tree();
  blob_zero(&report);
  vid = db_lget_int("checkout", 0);
  vfile_check_signature(vid);
  status_report(&report, "");
  blob_write_to_file(&report, "-");
}

/*
** COMMAND: status

** Usage: %fossil status

** Report on the status of the current checkout.
*/
void status_cmd(void){
  int vid;
  db_must_be_within_tree();
       /* 012345678901234 */
  printf("repository:   %s\n", db_lget("repository",""));
  printf("local-root:   %s\n", g.zLocalRoot);
  printf("server-code:  %s\n", db_get("server-code", ""));
  vid = db_lget_int("checkout", 0);
  if( vid ){
    show_common_info(vid, "checkout:", 0);
  }
  changes_cmd();
}

/*
** COMMAND: ls

** Usage: %fossil ls

** Show the names of all files in the current checkout
*/
void ls_cmd(void){
  int vid;
  Stmt q;

  db_must_be_within_tree();







>
















>

>


















>

>







73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
  db_finalize(&q);
}

/*
** COMMAND: changes
**
** Usage: %fossil changes
**
** Report on the edit status of all files in the current checkout.
** See also the "status" and "extra" commands.
*/
void changes_cmd(void){
  Blob report;
  int vid;
  db_must_be_within_tree();
  blob_zero(&report);
  vid = db_lget_int("checkout", 0);
  vfile_check_signature(vid);
  status_report(&report, "");
  blob_write_to_file(&report, "-");
}

/*
** COMMAND: status
**
** Usage: %fossil status
**
** Report on the status of the current checkout.
*/
void status_cmd(void){
  int vid;
  db_must_be_within_tree();
       /* 012345678901234 */
  printf("repository:   %s\n", db_lget("repository",""));
  printf("local-root:   %s\n", g.zLocalRoot);
  printf("server-code:  %s\n", db_get("server-code", ""));
  vid = db_lget_int("checkout", 0);
  if( vid ){
    show_common_info(vid, "checkout:", 0);
  }
  changes_cmd();
}

/*
** COMMAND: ls
**
** Usage: %fossil ls
**
** Show the names of all files in the current checkout
*/
void ls_cmd(void){
  int vid;
  Stmt q;

  db_must_be_within_tree();
141
142
143
144
145
146
147

148
149
150
151
152
153
154
  }
  db_finalize(&q);
}

/*
** COMMAND: extra
** Usage: %fossil extra

** Print a list of all files in the source tree that are not part of
** the current checkout.  See also the "clean" command.
*/
void extra_cmd(void){
  Blob path;
  Stmt q;
  db_must_be_within_tree();







>







146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
  }
  db_finalize(&q);
}

/*
** COMMAND: extra
** Usage: %fossil extra
**
** Print a list of all files in the source tree that are not part of
** the current checkout.  See also the "clean" command.
*/
void extra_cmd(void){
  Blob path;
  Stmt q;
  db_must_be_within_tree();
164
165
166
167
168
169
170
171

172
173
174
175
176
177
178
    printf("%s\n", db_column_text(&q, 0));
  }
  db_finalize(&q);
}

/*
** COMMAND: clean
** Usage: %fossil clean ?-all

** Delete all "extra" files in the source tree.  "Extra" files are
** files that are not officially part of the checkout.  See also
** the "extra" command. This operation cannot be undone. 
**
** You will be prompted before removing each file. If you are
** sure you wish to remove all "extra" files you can specify the
** optional -all flag.







|
>







170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
    printf("%s\n", db_column_text(&q, 0));
  }
  db_finalize(&q);
}

/*
** COMMAND: clean
** Usage: %fossil clean ?-all?
**
** Delete all "extra" files in the source tree.  "Extra" files are
** files that are not officially part of the checkout.  See also
** the "extra" command. This operation cannot be undone. 
**
** You will be prompted before removing each file. If you are
** sure you wish to remove all "extra" files you can specify the
** optional -all flag.
Changes to src/checkout.c.
132
133
134
135
136
137
138

139
140
141
142
143
144
145
  manifest_clear(&m);
}

/*
** COMMAND: checkout
**
** Usage: %fossil checkout VERSION ?-f|--force?

** Check out a version specified on the command-line.  This command
** will not overwrite edited files in the current checkout unless
** the --force option appears on the command-line.
**
** See also the "update" command.
*/
void checkout_cmd(void){







>







132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
  manifest_clear(&m);
}

/*
** COMMAND: checkout
**
** Usage: %fossil checkout VERSION ?-f|--force?
**
** Check out a version specified on the command-line.  This command
** will not overwrite edited files in the current checkout unless
** the --force option appears on the command-line.
**
** See also the "update" command.
*/
void checkout_cmd(void){
188
189
190
191
192
193
194

195
196
197
198
199
200
201
  db_end_transaction(0);
}

/*
** COMMAND: close
**
** Usage: %fossil close ?-f|--force?

** The opposite of "open".  Close the current database connection.
** Require a -f or --force flag if there are unsaved changed in the
** current check-out.
*/
void close_cmd(void){
  int forceFlag = find_option("force","f",0)!=0;
  db_must_be_within_tree();







>







189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
  db_end_transaction(0);
}

/*
** COMMAND: close
**
** Usage: %fossil close ?-f|--force?
**
** The opposite of "open".  Close the current database connection.
** Require a -f or --force flag if there are unsaved changed in the
** current check-out.
*/
void close_cmd(void){
  int forceFlag = find_option("force","f",0)!=0;
  db_must_be_within_tree();
Changes to src/db.c.
73
74
75
76
77
78
79

80
81
82
83
84
85
86
    fprintf(stderr, "%s: %s\n", g.argv[0], z);
  }
  db_force_rollback();
  exit(1);
}

static int nBegin = 0;      /* Nesting depth of BEGIN */

static int doRollback = 0;  /* True to force a rollback */
static int nCommitHook = 0; /* Number of commit hooks */
static struct sCommitHook {
  int (*xHook)(void);  /* Functions to call at db_end_transaction() */
  int sequence;        /* Call functions in sequence order */
} aHook[5];








>







73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
    fprintf(stderr, "%s: %s\n", g.argv[0], z);
  }
  db_force_rollback();
  exit(1);
}

static int nBegin = 0;      /* Nesting depth of BEGIN */
static int isNewRepo = 0;   /* True if the repository is newly created */
static int doRollback = 0;  /* True to force a rollback */
static int nCommitHook = 0; /* Number of commit hooks */
static struct sCommitHook {
  int (*xHook)(void);  /* Functions to call at db_end_transaction() */
  int sequence;        /* Call functions in sequence order */
} aHook[5];

122
123
124
125
126
127
128




129
130
131
132
133
134
135
    db_multi_exec(doRollback ? "ROLLBACK" : "COMMIT");
    doRollback = 0;
  }
}
void db_force_rollback(void){
  if( nBegin ){
    sqlite3_exec(g.db, "ROLLBACK", 0, 0, 0);




  }
  nBegin = 0;
}

/*
** Install a commit hook.  Hooks are installed in sequence order.
** It is an error to install the same commit hook more than once.







>
>
>
>







123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
    db_multi_exec(doRollback ? "ROLLBACK" : "COMMIT");
    doRollback = 0;
  }
}
void db_force_rollback(void){
  if( nBegin ){
    sqlite3_exec(g.db, "ROLLBACK", 0, 0, 0);
    if( isNewRepo ){
      db_close();
      unlink(g.zRepositoryName);
    }
  }
  nBegin = 0;
}

/*
** Install a commit hook.  Hooks are installed in sequence order.
** It is an error to install the same commit hook more than once.
728
729
730
731
732
733
734

735
736
737
738
739
740
741
void db_create_repository(const char *zFilename){
  db_init_database(
     zFilename,
     zRepositorySchema1,
     zRepositorySchema2,
     (char*)0
  );

}

/*
** Fill an empty repository database with the basic information for a
** repository. This function is shared between 'create_repository_cmd'
** ('new') and 'reconstruct_cmd' ('reconstruct'), both of which create
** new repositories.







>







733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
void db_create_repository(const char *zFilename){
  db_init_database(
     zFilename,
     zRepositorySchema1,
     zRepositorySchema2,
     (char*)0
  );
  isNewRepo = 1;
}

/*
** Fill an empty repository database with the basic information for a
** repository. This function is shared between 'create_repository_cmd'
** ('new') and 'reconstruct_cmd' ('reconstruct'), both of which create
** new repositories.
802
803
804
805
806
807
808

809
810
811
812
813
814
815
  }
}

/*
** COMMAND: new
**
** Usage: %fossil new FILENAME

** Create a repository for a new project in the file named FILENAME.
** This command is distinct from "clone".  The "clone" command makes
** a copy of an existing project.  This command starts a new project.
*/
void create_repository_cmd(void){
  if( g.argc!=3 ){
    usage("REPOSITORY-NAME");







>







808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
  }
}

/*
** COMMAND: new
**
** Usage: %fossil new FILENAME
**
** Create a repository for a new project in the file named FILENAME.
** This command is distinct from "clone".  The "clone" command makes
** a copy of an existing project.  This command starts a new project.
*/
void create_repository_cmd(void){
  if( g.argc!=3 ){
    usage("REPOSITORY-NAME");
1111
1112
1113
1114
1115
1116
1117
1118
1119

1120
1121

1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
**
**    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",
    "pgp-command",
    "editor",

    "localauth",
    "omitsign",

    "proxy",
    "diff-command",
    "gdiff-command",
  };
  int i;
  int globalFlag = find_option("global","g",0)!=0;
  int unsetFlag = g.argv[1][0]=='u';
  db_find_and_open_repository(0);
  if( !g.repositoryOpen ){
    db_open_config();







|

>


>

<
<







1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131


1132
1133
1134
1135
1136
1137
1138
**
**    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",
    "diff-command",
    "editor",
    "gdiff-command",
    "localauth",
    "omitsign",
    "pgp-command",
    "proxy",


  };
  int i;
  int globalFlag = find_option("global","g",0)!=0;
  int unsetFlag = g.argv[1][0]=='u';
  db_find_and_open_repository(0);
  if( !g.repositoryOpen ){
    db_open_config();
Changes to src/descendents.c.
129
130
131
132
133
134
135

136
137
138
139
140
141
142
  pqueue_clear(&queue);
}

/*
** COMMAND:  descendents
**
** Usage: %fossil descendents ?UUID?

** Find all leaf descendents of the current version or of the
** specified version.
*/
void descendents_cmd(void){
  Stmt q;
  int base;








>







129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
  pqueue_clear(&queue);
}

/*
** COMMAND:  descendents
**
** Usage: %fossil descendents ?UUID?
**
** Find all leaf descendents of the current version or of the
** specified version.
*/
void descendents_cmd(void){
  Stmt q;
  int base;

158
159
160
161
162
163
164

165
166
167
168
169
170
171
  db_finalize(&q);
}

/*
** COMMAND:  leaves
**
** Usage: %fossil leaves

** Find leaves of all branches.
*/
void branches_cmd(void){
  Stmt q;

  db_must_be_within_tree();
  db_prepare(&q,







>







159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
  db_finalize(&q);
}

/*
** COMMAND:  leaves
**
** Usage: %fossil leaves
**
** Find leaves of all branches.
*/
void branches_cmd(void){
  Stmt q;

  db_must_be_within_tree();
  db_prepare(&q,
Changes to src/main.c.
362
363
364
365
366
367
368

369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386

387
388
389
390
391
392
393
  multi_column_list(aCmd, nCmd);
}

/*
** COMMAND: test-commands
**
** Usage: %fossil test-commands

** List all commands used for testing and debugging.
*/
void cmd_test_cmd_list(void){
  int i, nCmd;
  const char *aCmd[count(aCommand)];
  for(i=nCmd=0; i<count(aCommand); i++){
    if( strncmp(aCommand[i].zName,"test",4)!=0 ) continue;
    /* if( strcmp(aCommand[i].zName, g.argv[1])==0 ) continue; */
    aCmd[nCmd++] = aCommand[i].zName;
  }
  multi_column_list(aCmd, nCmd);
}


/*
** COMMAND: help
**
** Usage: %fossil help COMMAND

** Display information on how to use COMMAND
*/
void help_cmd(void){
  int rc, idx;
  const char *z;
  if( g.argc!=3 ){
    printf("Usage: %s help COMMAND.\nAvailable COMMANDs:\n", g.argv[0]);







>


















>







362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
  multi_column_list(aCmd, nCmd);
}

/*
** COMMAND: test-commands
**
** Usage: %fossil test-commands
**
** List all commands used for testing and debugging.
*/
void cmd_test_cmd_list(void){
  int i, nCmd;
  const char *aCmd[count(aCommand)];
  for(i=nCmd=0; i<count(aCommand); i++){
    if( strncmp(aCommand[i].zName,"test",4)!=0 ) continue;
    /* if( strcmp(aCommand[i].zName, g.argv[1])==0 ) continue; */
    aCmd[nCmd++] = aCommand[i].zName;
  }
  multi_column_list(aCmd, nCmd);
}


/*
** COMMAND: help
**
** Usage: %fossil help COMMAND
**
** Display information on how to use COMMAND
*/
void help_cmd(void){
  int rc, idx;
  const char *z;
  if( g.argc!=3 ){
    printf("Usage: %s help COMMAND.\nAvailable COMMANDs:\n", g.argv[0]);