Fossil

Check-in [d57bddaa]
Login

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

Overview
Comment:rebase
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | pending-review
Files: files | file ages | folders
SHA1:d57bddaa37adfead0818b45d071f0a4965d6615e
User & Date: jan.nijtmans 2013-07-01 09:08:03
Context
2013-07-01
09:08
rebase Closed-Leaf check-in: d57bddaa user: jan.nijtmans tags: pending-review
2013-06-29
15:41
Fix the build on windows by using "_pclose" instead of "pclose". check-in: 07463fbf user: drh tags: trunk
2013-06-24
09:53
rebase check-in: 50d466dc user: jan.nijtmans tags: pending-review
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/checkin.c.

504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
...
522
523
524
525
526
527
528


529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
...
549
550
551
552
553
554
555







556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573

574
575
576
577
578
579

580
581
582
583
584
585
586
*/
void clean_cmd(void){
  int allFlag, dryRunFlag, verboseFlag;
  unsigned scanFlags = 0;
  const char *zIgnoreFlag, *zKeepFlag, *zCleanFlag;
  Blob repo;
  Stmt q;
  Glob *pIgnore, *pKeep, *pClean;
  int nRoot;

  dryRunFlag = find_option("dry-run","n",0)!=0;
  if( !dryRunFlag ){
    dryRunFlag = find_option("test",0,0)!=0; /* deprecated */
  }
  allFlag = find_option("force","f",0)!=0;
................................................................................
  verboseFlag = find_option("verbose","v",0)!=0;
  zKeepFlag = find_option("keep",0,1);
  zCleanFlag = find_option("clean",0,1);
  capture_case_sensitive_option();
  db_must_be_within_tree();
  if( zIgnoreFlag==0 ){
    zIgnoreFlag = db_get("ignore-glob", 0);


  }
  if( zKeepFlag==0 ){
    zKeepFlag = db_get("keep-glob", 0);
  }
  if( zCleanFlag==0 ){
    zCleanFlag = db_get("clean-glob", 0);
  }
  verify_all_options();
  pIgnore = glob_create(zIgnoreFlag);
  pKeep = glob_create(zKeepFlag);
  pClean = glob_create(zCleanFlag);
  locate_unmanaged_files(g.argc-2, g.argv+2, scanFlags, pIgnore, pKeep);
  glob_free(pKeep);
  glob_free(pIgnore);
  db_prepare(&q,
      "SELECT %Q || x FROM sfile"
      " WHERE x NOT IN (%s)"
      " ORDER BY 1",
      g.zLocalRoot, fossil_all_reserved_names(0)
  );
................................................................................
  if( file_tree_name(g.zRepositoryName, &repo, 0) ){
    db_multi_exec("DELETE FROM sfile WHERE x=%B", &repo);
  }
  db_multi_exec("DELETE FROM sfile WHERE x IN (SELECT pathname FROM vfile)");
  nRoot = (int)strlen(g.zLocalRoot);
  while( db_step(&q)==SQLITE_ROW ){
    const char *zName = db_column_text(&q, 0);







    if( !allFlag && !dryRunFlag && !glob_match(pClean, zName+nRoot) ){
      Blob ans;
      char cReply;
      char *prompt = mprintf("Remove unmanaged file \"%s\" (a=all/y/N)? ",
                             zName+nRoot);
      blob_zero(&ans);
      prompt_user(prompt, &ans);
      cReply = blob_str(&ans)[0];
      if( cReply=='a' || cReply=='A' ){
        allFlag = 1;
      }else if( cReply!='y' && cReply!='Y' ){
        blob_reset(&ans);
        continue;
      }
      blob_reset(&ans);
    }
    if( verboseFlag || dryRunFlag ){
      fossil_print("Removed unmanaged file: %s\n", zName+nRoot);

    }
    if( !dryRunFlag ){
      file_delete(zName);
    }
  }
  glob_free(pClean);

  db_finalize(&q);
}

/*
** Prompt the user for a check-in or stash comment (given in pPrompt),
** gather the response, then return the response in pComment.
**







|







 







>
>











|
<







 







>
>
>
>
>
>
>



|
|











|
|
>






>







504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
...
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542

543
544
545
546
547
548
549
...
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
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
*/
void clean_cmd(void){
  int allFlag, dryRunFlag, verboseFlag;
  unsigned scanFlags = 0;
  const char *zIgnoreFlag, *zKeepFlag, *zCleanFlag;
  Blob repo;
  Stmt q;
  Glob *pIgnore, *pIgnoreSetting = 0, *pKeep, *pClean;
  int nRoot;

  dryRunFlag = find_option("dry-run","n",0)!=0;
  if( !dryRunFlag ){
    dryRunFlag = find_option("test",0,0)!=0; /* deprecated */
  }
  allFlag = find_option("force","f",0)!=0;
................................................................................
  verboseFlag = find_option("verbose","v",0)!=0;
  zKeepFlag = find_option("keep",0,1);
  zCleanFlag = find_option("clean",0,1);
  capture_case_sensitive_option();
  db_must_be_within_tree();
  if( zIgnoreFlag==0 ){
    zIgnoreFlag = db_get("ignore-glob", 0);
  }else{
    pIgnoreSetting = glob_create(db_get("ignore-glob", 0));
  }
  if( zKeepFlag==0 ){
    zKeepFlag = db_get("keep-glob", 0);
  }
  if( zCleanFlag==0 ){
    zCleanFlag = db_get("clean-glob", 0);
  }
  verify_all_options();
  pIgnore = glob_create(zIgnoreFlag);
  pKeep = glob_create(zKeepFlag);
  pClean = glob_create(zCleanFlag);
  locate_unmanaged_files(g.argc-2, g.argv+2, scanFlags, pIgnore, 0);

  glob_free(pIgnore);
  db_prepare(&q,
      "SELECT %Q || x FROM sfile"
      " WHERE x NOT IN (%s)"
      " ORDER BY 1",
      g.zLocalRoot, fossil_all_reserved_names(0)
  );
................................................................................
  if( file_tree_name(g.zRepositoryName, &repo, 0) ){
    db_multi_exec("DELETE FROM sfile WHERE x=%B", &repo);
  }
  db_multi_exec("DELETE FROM sfile WHERE x IN (SELECT pathname FROM vfile)");
  nRoot = (int)strlen(g.zLocalRoot);
  while( db_step(&q)==SQLITE_ROW ){
    const char *zName = db_column_text(&q, 0);
    int isIgnored;

    if( glob_match(pKeep, zName+nRoot) ){
      fossil_print("WARNING: KEPT file \"%s\" not removed\n", zName+nRoot);
      continue;
    }
    isIgnored = glob_match(pIgnoreSetting, zName+nRoot);
    if( !allFlag && !dryRunFlag && !glob_match(pClean, zName+nRoot) ){
      Blob ans;
      char cReply;
      char *prompt = mprintf("Remove %s file \"%s\" (a=all/y/N)? ",
                             isIgnored ? "ignored" : "unmanaged", zName+nRoot);
      blob_zero(&ans);
      prompt_user(prompt, &ans);
      cReply = blob_str(&ans)[0];
      if( cReply=='a' || cReply=='A' ){
        allFlag = 1;
      }else if( cReply!='y' && cReply!='Y' ){
        blob_reset(&ans);
        continue;
      }
      blob_reset(&ans);
    }
    if( verboseFlag || dryRunFlag || isIgnored ){
      fossil_print("Removed %s file: %s\n",
                   isIgnored ? "ignored" : "unmanaged", zName+nRoot);
    }
    if( !dryRunFlag ){
      file_delete(zName);
    }
  }
  glob_free(pClean);
  glob_free(pKeep);
  db_finalize(&q);
}

/*
** Prompt the user for a check-in or stash comment (given in pPrompt),
** gather the response, then return the response in pComment.
**