Check-in [6607844a01]
Not logged in

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

Overview
Comment:Added options to the "timeline" CLI command. Additional help comments.
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 6607844a0162db6d51c360aaaeead96c84477376
User & Date: drh 2007-08-18 11:42:24.000
Context
2007-08-19
11:06
Fix the "Leaves" computation on the vinfo web page. Improvements to the vinfo web page. check-in: 4ac16995e8 user: drh tags: trunk
2007-08-18
11:42
Added options to the "timeline" CLI command. Additional help comments. check-in: 6607844a01 user: drh tags: trunk
02:45
Add the "help" command and the "clean" command. More work is needed on the text for various help messages. check-in: c9fdb846fb user: drh tags: trunk
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/db.c.
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
  }
  db_open_or_attach(zDbName, "repository");
  g.repositoryOpen = 1;
  g.zRepositoryName = mprintf("%s", zDbName);
}

/*
** Try to find the repository and open it.  If we are in a local
** tree, then use the repository of the local tree.  Otherwise,
** fall back to the -R or --repository option.
**
** Error out if the repository cannot be opened.
*/
void db_find_and_open_repository(void){
  const char *zRep = find_option("repository", "R", 1);
  if( zRep==0 ){
    if( db_open_local()==0 ){







|
|
|







576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
  }
  db_open_or_attach(zDbName, "repository");
  g.repositoryOpen = 1;
  g.zRepositoryName = mprintf("%s", zDbName);
}

/*
** Try to find the repository and open it.  Use the -R or --repository
** option to locate the repository.  If no such option is available, then
** use the repository of the open checkout if there is one.
**
** Error out if the repository cannot be opened.
*/
void db_find_and_open_repository(void){
  const char *zRep = find_option("repository", "R", 1);
  if( zRep==0 ){
    if( db_open_local()==0 ){
822
823
824
825
826
827
828

829
830
831
832
833
834
835
  db_multi_exec("REPLACE INTO vvar(name,value) VALUES(%Q,%d)", zName, value);
}

/*
** COMMAND: open
**
** Usage: open FILENAME

** Open a connection to the local repository in FILENAME.  A checkout
** for the repository is created with its root at the working directory.
** See also the "close" command.
*/
void cmd_open(void){
  Blob path;
  if( g.argc!=3 ){







>







822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
  db_multi_exec("REPLACE INTO vvar(name,value) VALUES(%Q,%d)", zName, value);
}

/*
** COMMAND: open
**
** Usage: open FILENAME
**
** Open a connection to the local repository in FILENAME.  A checkout
** for the repository is created with its root at the working directory.
** See also the "close" command.
*/
void cmd_open(void){
  Blob path;
  if( g.argc!=3 ){
845
846
847
848
849
850
851


852










853
854
855
856
857
858
859
  db_lset("repository", blob_str(&path));
  db_lset_int("checkout", 1);
}

/*
** COMMAND: config
**


** List or change the global configuration settings.










*/
void cmd_config(void){
  db_open_config();
  if( g.argc>2 ){
    int i;
    db_begin_transaction();
    for(i=2; i<g.argc; i++){







>
>
|
>
>
>
>
>
>
>
>
>
>







846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
  db_lset("repository", blob_str(&path));
  db_lset_int("checkout", 1);
}

/*
** COMMAND: config
**
** Usage: %fossil config NAME=VALUE ...
**
** List or change the global configuration settings.  With no arguments,
** all settings are listed.  Arguments of simply NAME cause that setting
** to be displayed.  Arguments of the form NAME=VALUE change the value of
** a setting.  Arguments of the form NAME= delete a setting.
**
** Recognized settings include:
**
**   editor        Text editor command used for check-in comments.
**
**   clear-sign    Command used to clear-sign manifests at check-in.
**                 The default is "gpg --clearsign -o ".
*/
void cmd_config(void){
  db_open_config();
  if( g.argc>2 ){
    int i;
    db_begin_transaction();
    for(i=2; i<g.argc; i++){
Changes to src/info.c.
69
70
71
72
73
74
75


76
77
78
79
80
81
82
    free(zComment);
  }
}


/*
** COMMAND: info


**
** With no arguments, provide information about the current tree.
** If an argument is given, provide information about the record
** that the argument refers to.
*/
void info_cmd(void){
  if( g.argc!=2 && g.argc!=3 ){







>
>







69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
    free(zComment);
  }
}


/*
** COMMAND: info
**
** Usage: %fossil info ?UUID?
**
** With no arguments, provide information about the current tree.
** If an argument is given, provide information about the record
** that the argument refers to.
*/
void info_cmd(void){
  if( g.argc!=2 && g.argc!=3 ){
Changes to src/main.c.
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
** 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]);
    cmd_cmd_list();
    return;
  }
  rc = name_search(g.argv[2], aCommand, count(aCommand), &idx);
  if( rc==1 ){
    fossil_fatal("unknown command: %s", g.argv[2]);
  }else if( rc==2 ){







|







380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
** 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]);
    cmd_cmd_list();
    return;
  }
  rc = name_search(g.argv[2], aCommand, count(aCommand), &idx);
  if( rc==1 ){
    fossil_fatal("unknown command: %s", g.argv[2]);
  }else if( rc==2 ){
517
518
519
520
521
522
523


524



525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
  */
  cgi_reply();
}

/*
** COMMAND: cgi
**


** The single argument is the name of a file that is the CGI script



** that is being run.  This file should look something like this:
**
**      #!/usr/bin/fossil
**      repository: /home/somebody/project.db
**
** We are interested in the line that defines the name of the repository.
** Read the file, find the repository line.  Then open the respository
** database.
**
** Also do the usual CGI initialization stuff in the cgi.c module.
**
** After all of the above setup, call process_one_web_page() to do the
** web page processing and return the result.
*/
void cmd_cgi(void){
  const char *zFile;
  Blob config, line, key, value;
  if( g.argc==3 && strcmp(g.argv[1],"cgi")==0 ){
    zFile = g.argv[2];
  }else{







>
>
|
>
>
>
|




|
|
<
<
<
<
<
|







517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536





537
538
539
540
541
542
543
544
  */
  cgi_reply();
}

/*
** COMMAND: cgi
**
** Usage: %fossil ?cgi? SCRIPT
**
** The SCRIPT argument is the name of a file that is the CGI script
** that is being run.  The command name, "cgi", may be omitted if
** the GATEWAY_INTERFACE environment variable is set to "CGI" (which
** should always be the case for CGI scripts run by a webserver.)  The
** SCRIPT file should look something like this:
**
**      #!/usr/bin/fossil
**      repository: /home/somebody/project.db
**
** The second line defines the name of the repository.  After locating
** the repository, fossil will generate a webpage on stdout based on





** the values of standard CGI environment variables.
*/
void cmd_cgi(void){
  const char *zFile;
  Blob config, line, key, value;
  if( g.argc==3 && strcmp(g.argv[1],"cgi")==0 ){
    zFile = g.argv[2];
  }else{
572
573
574
575
576
577
578


579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605


606


607
608
609
610
611
612
613
  cgi_init();
  process_one_web_page();
}

/*
** COMMAND: http
**


** Handle a single HTTP request appearing on standard input.  This
** method is used to launch an HTTP request handler from INETD, for
** example.
**
** The argument is the name of the repository.
*/
void cmd_http(void){
  if( g.argc!=2 && g.argc!=3 ){
    cgi_panic("no repository specified");
  }
  g.cgiPanic = 1;
  if( g.argc==3 ){
    db_open_repository(g.argv[2]);
  }else{
    db_must_be_within_tree();
  }
  cgi_handle_http_request();
  process_one_web_page();
}

/*
** COMMAND: server
**
** Open a socket and begin listening for incoming HTTP requests.
** As each connection is received, fork a new child process to handle
** the request.
**


** The argument is the name of the repository.


*/
void cmd_webserver(void){
  int iPort;
  const char *zPort;

  zPort = find_option("port", "P", 1);
  if( zPort ){







>
>
|
|
|
<
|


















|
<
<

>
>
|
>
>







572
573
574
575
576
577
578
579
580
581
582
583

584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603


604
605
606
607
608
609
610
611
612
613
614
615
616
  cgi_init();
  process_one_web_page();
}

/*
** COMMAND: http
**
** Usage: %fossil http REPOSITORY
**
** Handle a single HTTP request appearing on stdin.  The resulting webpage
** is delivered on stdout.  This method is used to launch an HTTP request
** handler from inetd, for example.  The argument is the name of the 

** repository.
*/
void cmd_http(void){
  if( g.argc!=2 && g.argc!=3 ){
    cgi_panic("no repository specified");
  }
  g.cgiPanic = 1;
  if( g.argc==3 ){
    db_open_repository(g.argv[2]);
  }else{
    db_must_be_within_tree();
  }
  cgi_handle_http_request();
  process_one_web_page();
}

/*
** COMMAND: server
**
** Usage: %fossil server ?-P|--port TCPPORT? ?REPOSITORY?


**
** Open a socket and begin listening and responding to HTTP requests on
** TCP port 8080, or on any other TCP port defined by the -P or
** --port option.  The optional argument is the name of the repository.
** The repository argument may be omitted if the working directory is
** within an open checkout.
*/
void cmd_webserver(void){
  int iPort;
  const char *zPort;

  zPort = find_option("port", "P", 1);
  if( zPort ){
Changes to src/merge.c.
27
28
29
30
31
32
33


34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include "config.h"
#include "merge.h"
#include <assert.h>


/*
** COMMAND: merge


**
** The argument is a version that should be merged into the current
** checkout. 
**
** Only file content is merged.  The result continues to use the
** file and directory names from the current check-out even if those
** names might have been changed in the branch being merged in.
**
*/
void merge_cmd(void){
  int vid;              /* Current version */
  int mid;              /* Version we are merging against */
  int pid;              /* The pivot version - most recent common ancestor */
  Stmt q;








>
>







<







27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42

43
44
45
46
47
48
49
#include "config.h"
#include "merge.h"
#include <assert.h>


/*
** COMMAND: merge
**
** Usage: %fossil merge VERSION
**
** The argument is a version that should be merged into the current
** checkout. 
**
** Only file content is merged.  The result continues to use the
** file and directory names from the current check-out even if those
** names might have been changed in the branch being merged in.

*/
void merge_cmd(void){
  int vid;              /* Current version */
  int mid;              /* Version we are merging against */
  int pid;              /* The pivot version - most recent common ancestor */
  Stmt q;

Changes to src/rebuild.c.
27
28
29
30
31
32
33


34
35
36
37
38
39
40
41
#include "rebuild.h"
#include <assert.h>


/*
** COMMAND:  rebuild
**


** Reconstruct the entire repository database from the core
** records.  Run this command after updating the fossil
** executable in a way that changes the database schema.
*/
void rebuild_database(void){
  Stmt s;
  int errCnt;
  int forceFlag;







>
>
|







27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include "rebuild.h"
#include <assert.h>


/*
** COMMAND:  rebuild
**
** Usage: %fossil rebuild REPOSITORY
**
** Reconstruct the named repository database from the core
** records.  Run this command after updating the fossil
** executable in a way that changes the database schema.
*/
void rebuild_database(void){
  Stmt s;
  int errCnt;
  int forceFlag;
Changes to src/sync.c.
58
59
60
61
62
63
64


65















66
67
68
69
70
71
72
73
74


75

76
77
78
79
80
81
82
83
84
85


86


87
88
89
90
91
    }
  }
}

/*
** COMMAND: pull
**


** Pull changes in a remote repository into the local repository















*/
void pull_cmd(void){
  process_sync_args();
  client_sync(0,1,0);
}

/*
** COMMAND: push
**


** Push changes in the local repository over into a remote repository

*/
void push_cmd(void){
  process_sync_args();
  client_sync(1,0,0);
}


/*
** COMMAND: sync
**


** Synchronize the local repository with a remote repository


*/
void sync_cmd(void){
  process_sync_args();
  client_sync(1,1,0);
}







>
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>









>
>
|
>










>
>
|
>
>





58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
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
    }
  }
}

/*
** COMMAND: pull
**
** Usage: %fossil pull ?URL? ?-R|--respository REPOSITORY?
**
** Pull changes in a remote repository into the local repository.
** The repository is identified by the -R or --repository option.
** If there is no such option then the open repository is used.
** The URL of the remote server is specified on the command line
** If no URL is specified then the URL used by the most recent
** "pull", "push", or "sync" command is used.
**
** The URL is of the following form:
**
**      http://USER@HOST:PORT/PATH
**
** The "USER@" and ":PORT" substrings are optional.
** The "USER" substring specifies the login user.  You will be
** prompted for the password on the command-line.  The PORT
** specifies the TCP port of the server.  The default port is
** 80.
*/
void pull_cmd(void){
  process_sync_args();
  client_sync(0,1,0);
}

/*
** COMMAND: push
**
** Usage: %fossil push ?URL? ?-R|--repository REPOSITORY?
**
** Push changes in the local repository over into a remote repository.
** See the "pull" command for additional information.
*/
void push_cmd(void){
  process_sync_args();
  client_sync(1,0,0);
}


/*
** COMMAND: sync
**
** Usage: %fossil sync ?URL? ?-R|--repository REPOSITORY?
**
** Synchronize the local repository with a remote repository.  This is
** the equivalent of running both "push" and "pull" at the same time.
** See the "pull" command for additional information.
*/
void sync_cmd(void){
  process_sync_args();
  client_sync(1,1,0);
}
Changes to src/timeline.c.
182
183
184
185
186
187
188
189
190
191


192



193
194
195
196

















197
198
199
200
201

202
203
204
205
206
  }
}


/*
** COMMAND: timeline
**
** The timeline command works very much like the timeline webpage, but
** shows much less data and has fewer configuration options.  It is
** intended as a convenient shortcut for the common case of seeing


** recent changes.



*/
void timeline_cmd(void){
  Stmt q;
  db_must_be_within_tree();

















  db_prepare(&q,
    "SELECT uuid, datetime(event.mtime,'localtime'),"
    "       comment || ' (by ' || user || ')'"
    "  FROM event, blob"
    " WHERE event.type='ci' AND blob.rid=event.objid"

    " ORDER BY event.mtime DESC"
  );
  print_timeline(&q, 20);
  db_finalize(&q);
}







|
|
|
>
>
|
>
>
>



|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>





>
|

|


182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
  }
}


/*
** COMMAND: timeline
**
** Usage: %fossil timeline ?DATETIME? ?-n|--count N?
**
** Print a summary of activity going backwards in date and time
** specified or from the current date and time if no arguments
** are given.  Show as many as N (default 20) check-ins.
**
** The date and time should be in the ISO8601 format.  For
** examples: "2007-08-18 07:21:21".  The time may be omitted.
** Times are according to the local timezone.
*/
void timeline_cmd(void){
  Stmt q;
  int n;
  char *zCount;
  char *zDate;
  db_find_and_open_repository();
  zCount = find_option("n","count",1);
  if( zCount ){
    n = atoi(zCount);
  }else{
    n = 20;
  }
  if( g.argc!=2 && g.argc!=3 ){
    usage("YYYY-MM-DDtHH:MM:SS");
  }
  if( g.argc==3 ){
    zDate = g.argv[2];
  }else{
    zDate = "now";
  }
  db_prepare(&q,
    "SELECT uuid, datetime(event.mtime,'localtime'),"
    "       comment || ' (by ' || user || ')'"
    "  FROM event, blob"
    " WHERE event.type='ci' AND blob.rid=event.objid"
    "   AND event.mtime<=(SELECT julianday(%Q,'utc'))"
    " ORDER BY event.mtime DESC", zDate
  );
  print_timeline(&q, n);
  db_finalize(&q);
}
Changes to src/update.c.
26
27
28
29
30
31
32


33
34
35
36
37



38
39
40
41
42
43
44
*/
#include "config.h"
#include "update.h"
#include <assert.h>

/*
** COMMAND: update


**
** The optional argument is a version that should become the current
** version.  If the argument is omitted, then use the leaf of the
** version tree branch that begins with the current version, if there
** is only a single leaf.



**
*/
void update_cmd(void){
  int vid;              /* Current version */
  int tid;              /* Target version - version we are changing to */
  Stmt q;








>
>



|
|
>
>
>







26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
*/
#include "config.h"
#include "update.h"
#include <assert.h>

/*
** COMMAND: update
**
** Usage: %fossil update ?VERSION?
**
** The optional argument is a version that should become the current
** version.  If the argument is omitted, then use the leaf of the
** tree that begins with the current version, if there is only a 
** single leaf.  
**
** This command is different from the "checkout" in that edits are
** not overwritten.  Edits are merged into the new version.
**
*/
void update_cmd(void){
  int vid;              /* Current version */
  int tid;              /* Target version - version we are changing to */
  Stmt q;

Changes to src/user.c.
105
106
107
108
109
110
111


112
























113
114
115
116
117
118
119
  }
}


/*
** COMMAND:  user
**


** Dispatcher for various user subcommands.
























*/
void user_cmd(void){
  int n;
  db_find_and_open_repository();
  if( g.argc<3 ){
    usage("capabilities|default|list|new|password ...");
  }







>
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
  }
}


/*
** COMMAND:  user
**
** Usage: %fossil user SUBCOMMAND ...  ?-R|--repository FILE?
**
** Run various subcommands on users of the open repository or of
** the repository identified by the -R or --repository option.
**
**    %fossil user capabilities USERNAME ?STRING?
**
**        Query or set the capabilities for user USERNAME
**
**    %fossil user default ?USERNAME?
**
**        Query or set the default user.  The default user is the
**        user for command-line interaction.
**
**    %fossil user list
**
**        List all users known to the repository
**
**    %fossil user new
**
**        Create a new user in the repository.  Users can never be
**        deleted.  They can be denied all access but they must continue
**        to exist in the database.
**
**    %fossil user password USERNAME
**
**        Change the web access password for a user.
*/
void user_cmd(void){
  int n;
  db_find_and_open_repository();
  if( g.argc<3 ){
    usage("capabilities|default|list|new|password ...");
  }