Fossil

Check-in [3332895d]
Login

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

Overview
Comment:Reimplement the reconstruct command that was removed in the GPL to BSD license change. This resolves ticket [dfe1fc608a].
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:3332895df8fa173cb0a2c0586c7b8cad4bd300a1
User & Date: bcsmith 2010-08-12 19:39:41
Original Comment: Reimplement the reconstruct command that was removed in the GPL to BSD license change.
References
2010-08-12
19:49 Fixed ticket [dfe1fc60]: Reconstruct command that went away plus 2 other changes artifact: d5777fbb user: bcsmith
Context
2010-08-15
19:34
Recognize the HTTPS line in the HTTP header. Ticket [d83227cdda3d786d3743b2] check-in: 3dc62d54 user: drh tags: trunk
2010-08-13
03:49
Merged with trunk. Leaf check-in: 861a885c user: michael tags: ttmrichter
03:26
Merged with trunk. check-in: 7f61175d user: michael tags: ttmrichter
2010-08-12
19:39
Reimplement the reconstruct command that was removed in the GPL to BSD license change. This resolves ticket [dfe1fc608a]. check-in: 3332895d user: bcsmith tags: trunk
2010-08-11
07:00
Allow a checkin to be checked out again even if one of the files in that checkin has been shunned. check-in: 7e23178b user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/rebuild.c.

16
17
18
19
20
21
22


23
24
25
26
27
28
29
...
397
398
399
400
401
402
403



























































*******************************************************************************
**
** This file contains code used to rebuild the database.
*/
#include "config.h"
#include "rebuild.h"
#include <assert.h>



/*
** Schema changes
*/
static const char zSchemaUpdates[] =
@ -- Index on the delta table
@ --
................................................................................
    db_end_transaction(0);
    db_multi_exec("VACUUM;");
  }else{
    rebuild_db(0, 1);
    db_end_transaction(0);
  }
}


































































>
>







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
...
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
*******************************************************************************
**
** This file contains code used to rebuild the database.
*/
#include "config.h"
#include "rebuild.h"
#include <assert.h>
#include <dirent.h>
#include <errno.h>

/*
** Schema changes
*/
static const char zSchemaUpdates[] =
@ -- Index on the delta table
@ --
................................................................................
    db_end_transaction(0);
    db_multi_exec("VACUUM;");
  }else{
    rebuild_db(0, 1);
    db_end_transaction(0);
  }
}

/*
** COMMAND: reconstruct
**
** Usage: %fossil reconstruct FILENAME DIRECTORY
**
** This command studies the artifacts (files) in DIRECTORY and
** reconstructs the fossil record from them. It places the new
** fossil repository in FILENAME
**
*/
void reconstruct_cmd(void) {
  char *zPassword;
  DIR *d;
  struct dirent *pEntry;
  Blob aContent; /* content of the just read artifact */
  if( g.argc!=4 ){
    usage("FILENAME DIRECTORY");
  }
  if( file_isdir(g.argv[3])!=1 ){
    printf("\"%s\" is not a directory\n\n", g.argv[3]);
    usage("FILENAME DIRECTORY");
  }
  db_create_repository(g.argv[2]);
  db_open_repository(g.argv[2]);
  db_open_config(0);
  db_begin_transaction();
  db_initial_setup(0, 0, 1);

  d = opendir(g.argv[3]);
  if( d ){
    while( (pEntry=readdir(d))!=0 ){
      Blob path;
      blob_init(&path, 0, 0);
      if( pEntry->d_name[0]=='.' ){
        continue;
      }
      if( file_isdir(pEntry->d_name)==1 ){
        continue;
      }
      blob_appendf(&path, "%s/%s", g.argv[3], pEntry->d_name);
      if( blob_read_from_file(&aContent, blob_str(&path))==-1 ){
        fossil_panic("Some unknown error occurred while reading \"%s\"", blob_str(&path));
      }
      content_put(&aContent, 0, 0);
    }
  }
  else {
    fossil_panic("Encountered error %d while trying to open \"%s\".", errno, g.argv[3]);
  }

  rebuild_db(0, 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);
  printf("admin-user: %s (initial password is \"%s\")\n", g.zLogin, zPassword);
}