Diff
Not logged in

Differences From:

File src/db.c part of check-in [e00a5de0f1] - Improvement to the error message issued when the HOME environment variable is missing. Ticket e3c34af10dd28 by drh on 2009-08-01 14:34:24. [view]

To:

File src/db.c part of check-in [8b630bb57a] - Provide --user-override option on the ci command and the --date-override option on the new command. Make a correction to the file format document. by drh on 2009-08-08 22:40:28. [view]

@@ -914,13 +914,14 @@
 ** repository. This function is shared between 'create_repository_cmd'
 ** ('new') and 'reconstruct_cmd' ('reconstruct'), both of which create
 ** new repositories.
 **
-** The makeInitialVersion flag determines whether or not an initial
-** manifest is created.  The makeServerCodes flag determines whether or
+** The zInitialDate parameter determines the date of the initial check-in
+** that is automatically created.  If zInitialDate is 0 then no initial
+** check-in is created. The makeServerCodes flag determines whether or
 ** not server and project codes are invented for this repository.
 */
-void db_initial_setup (int makeInitialVersion, int makeServerCodes){
+void db_initial_setup (const char *zInitialDate, int makeServerCodes){
   char *zDate;
   Blob hash;
   Blob manifest;
 
@@ -938,13 +939,13 @@
   if( !db_is_global("localauth") ) db_set_int("localauth", 0, 0);
   db_create_default_users(0);
   user_select();
 
-  if (makeInitialVersion){
+  if( zInitialDate ){
     int rid;
     blob_zero(&manifest);
     blob_appendf(&manifest, "C initial\\sempty\\scheck-in\n");
-    zDate = db_text(0, "SELECT datetime('now')");
+    zDate = db_text(0, "SELECT datetime(%Q)", zInitialDate);
     zDate[10]='T';
     blob_appendf(&manifest, "D %s\n", zDate);
     blob_appendf(&manifest, "P\n");
     md5sum_init();
@@ -970,16 +971,20 @@
 ** a copy of an existing project.  This command starts a new project.
 */
 void create_repository_cmd(void){
   char *zPassword;
+  const char *zDate;          /* Date of the initial check-in */
+
+  zDate = find_option("date-override",0,1);
+  if( zDate==0 ) zDate = "now";
   if( g.argc!=3 ){
     usage("REPOSITORY-NAME");
   }
   db_create_repository(g.argv[2]);
   db_open_repository(g.argv[2]);
   db_open_config();
   db_begin_transaction();
-  db_initial_setup(1, 1);
+  db_initial_setup(zDate, 1);
   db_end_transaction(0);
   printf("project-id: %s\n", db_get("project-code", 0));
   printf("server-id:  %s\n", db_get("server-code", 0));
   zPassword = db_text(0, "SELECT pw FROM user WHERE login=%Q", g.zLogin);