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

Overview
Comment:reconstruct handles subdirectories
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | wolfgangFormat2CSS_2
Files: files | file ages | folders
SHA1:6759e00eb89fcf3d6cbac66aa1028ce6508a0975
User & Date: wolfgang 2010-09-28 14:48:03
Context
2010-09-28
15:45
more formats to css check-in: e05f750a user: wolfgang tags: wolfgangFormat2CSS_2
14:48
reconstruct handles subdirectories check-in: 6759e00e user: wolfgang tags: wolfgangFormat2CSS_2
09:02
solved ticket [1b41304d8b]: moved style clear: both from code for content to css, adding the corresponding div only, if a sidebox wass used check-in: 26fc585e user: Ratte tags: wolfgangFormat2CSS_2
Changes

Changes to src/rebuild.c.

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
...
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
...
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
    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. Subdirectories are ignored.

**
*/
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);
      blob_reset(&path);
      blob_reset(&aContent);
    }
  }
  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);
................................................................................
**
** This command exports all artifacts of o given repository and
** writes all artifacts to the file system. The DESTINATION directory
** will be populated with subdirectories AA and files AA/BBBBBBBBB.., where
** AABBBBBBBBB.. is the 40 character artifact ID, AA the first 2 characters.
** If -L|--prefixlength is given, the length (default 2) of the directory
** prefix can be set to 0,1,..,9 characters.
**
** To use use the deconstructed artifacts with reconstruct, -L 0 should be used.
*/
void deconstruct_cmd(void){
  const char *zDestDir;
  const char *zPrefixOpt;
  int         prefixLength;
  char       *zAFileOutFormat;
  Stmt        q;
................................................................................
    fossil_panic("DESTINATION(%s) is not a directory!",zDestDir);
  }
  /* get and check prefix length argument and build format string */
  zPrefixOpt=find_option("prefixlength","L",1);
  if (!zPrefixOpt){
    prefixLength = 2;
  }else{
    switch(*zPrefixOpt){
      case '0': prefixLength = 0;break;
      case '1': prefixLength = 1;break;
      case '2': prefixLength = 2;break;
      case '3': prefixLength = 3;break;
      case '4': prefixLength = 4;break;
      case '5': prefixLength = 5;break;
      case '6': prefixLength = 6;break;
      case '7': prefixLength = 7;break;
      case '8': prefixLength = 8;break;
      case '9': prefixLength = 9;break;
      default:  fossil_panic("N(%s) is not a a valid prefix length!",zPrefixOpt);
    }
  }
  if (prefixLength){
    zAFileOutFormat = mprintf("%%s/%%.%ds/%%s",prefixLength);
  }else{
    zAFileOutFormat = mprintf("%%s/%%s");
  }







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>








|
>




<
<
<













|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







 







<
<







 







|
|
|
<
<
<
<
<
<
<
<
|







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
465
466
467
468
469
470
471






















472
473
474
475
476
477
478
...
486
487
488
489
490
491
492


493
494
495
496
497
498
499
...
508
509
510
511
512
513
514
515
516
517








518
519
520
521
522
523
524
525
    db_end_transaction(0);
    db_multi_exec("VACUUM;");
  }else{
    rebuild_db(0, 1);
    db_end_transaction(0);
  }
}

/* 
** help function for reconstruct for recursiv directory
** reading.
*/
void recon_read_dir(char * zPath){
  DIR *d;
  struct dirent *pEntry;
  Blob aContent; /* content of the just read artifact */

  d = opendir(zPath);
  if( d ){
    while( (pEntry=readdir(d))!=0 ){
      Blob path;
      char *zSubpath;

      if( pEntry->d_name[0]=='.' ){
        continue;
      }
      zSubpath = mprintf("%s/%s",zPath,pEntry->d_name);
      if( file_isdir(zSubpath)==1 ){
        recon_read_dir(zSubpath);
      }
      blob_init(&path, 0, 0);
      blob_appendf(&path, "%s", zSubpath);
      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);
      blob_reset(&path);
      blob_reset(&aContent);
      free(zSubpath);
    }
  }
  else {
    fossil_panic("Encountered error %d while trying to open \"%s\".", errno, g.argv[3]);
  }
}

/*
** 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. Subdirectories are read, files
** with leading `. in the filename are ignored.
**
*/
void reconstruct_cmd(void) {
  char *zPassword;



  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);

  recon_read_dir(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);
................................................................................
**
** This command exports all artifacts of o given repository and
** writes all artifacts to the file system. The DESTINATION directory
** will be populated with subdirectories AA and files AA/BBBBBBBBB.., where
** AABBBBBBBBB.. is the 40 character artifact ID, AA the first 2 characters.
** If -L|--prefixlength is given, the length (default 2) of the directory
** prefix can be set to 0,1,..,9 characters.


*/
void deconstruct_cmd(void){
  const char *zDestDir;
  const char *zPrefixOpt;
  int         prefixLength;
  char       *zAFileOutFormat;
  Stmt        q;
................................................................................
    fossil_panic("DESTINATION(%s) is not a directory!",zDestDir);
  }
  /* get and check prefix length argument and build format string */
  zPrefixOpt=find_option("prefixlength","L",1);
  if (!zPrefixOpt){
    prefixLength = 2;
  }else{
    if (zPrefixOpt[0]>='0' && zPrefixOpt[0]<='9' && !zPrefixOpt[1]){
      prefixLength = (int)(*zPrefixOpt-'0');
    }else{








      fossil_panic("N(%s) is not a a valid prefix length!",zPrefixOpt);
    }
  }
  if (prefixLength){
    zAFileOutFormat = mprintf("%%s/%%.%ds/%%s",prefixLength);
  }else{
    zAFileOutFormat = mprintf("%%s/%%s");
  }