50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
+
+
+
+
+
+
+
|
@ isPrivate BOOLEAN, -- True if artifact was originally private
@ sz INT NOT NULL, -- Uncompressed size of the purged artifact
@ desc TEXT, -- Brief description of this artifact
@ data BLOB -- Compressed artifact content
@ );
;
/*
** Flags for the purge_artifact_list() function.
*/
#if INTERFACE
#define PURGE_MOVETO_GRAVEYARD 0x0001 /* Move artifacts in graveyard */
#endif
/*
** This routine purges multiple artifacts from the repository, transfering
** those artifacts into the PURGEITEM table.
**
** Prior to invoking this routine, the caller must create a (TEMP) table
** named zTab that contains the RID of every artifact to be purged.
**
|
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
|
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
|
-
+
|
content_undelta(rid);
verify_before_commit(rid);
}
db_finalize(&q);
/* Construct the graveyard and copy the artifacts to be purged into the
** graveyard */
if( moveToGraveyard ){
if( purgeFlags & PURGE_MOVETO_GRAVEYARD ){
db_multi_exec(zPurgeInit /*works-like:"%w%w"*/,
db_name("repository"), db_name("repository"));
db_multi_exec(
"INSERT INTO purgeevent(ctime,pnotes) VALUES(now(),%Q)", zNote
);
peid = db_last_insert_rowid();
db_prepare(&q, "SELECT rid FROM delta WHERE rid IN \"%w\""
|
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
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
|
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
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
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
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
|
+
+
+
+
-
+
-
-
+
+
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
+
+
+
+
+
+
-
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
/*
** COMMAND: purge
**
** The purge command removes content from a repository and stores that content
** in a "graveyard". The graveyard exists so that content can be recovered
** using the "fossil purge undo" command.
**
** fossil purge artifact UUID... ?OPTIONS?
**
** TBD...
**
** fossil purge cat UUID...
**
** Write the content of one or more artifacts in the graveyard onto
** standard output.
**
** fossil purge ?checkins? TAGS... ?OPTIONS?
** fossil purge checkins TAGS... ?OPTIONS?
**
** Move the check-ins identified by TAGS and all of their descendants
** out of the repository and into the graveyard. The "checkins"
** Move the check-ins or branches identified by TAGS and all of
** their descendants out of the repository and into the graveyard.
** subcommand keyword is optional and can be omitted as long as TAGS
** does not conflict with any other subcommand.
**
** If TAGS includes a branch name then it means all the check-ins
** on the most recent occurrence of that branch.
**
** --explain Make no changes, but show what would happen.
** --dry-run Make no changes.
**
** fossil purge files NAME ... ?OPTIONS?
**
** TBD...
**
** fossil purge list|ls ?-l?
**
** Show the graveyard of prior purges. The -l option gives more
** detail in the output.
**
** fossil purge obliterate ID...
**
** Remove one or more purge events from the graveyard. Once a purge
** event is obliterated, it can no longer be undone.
**
** fossil purge tickets NAME ... ?OPTIONS?
**
** TBD...
**
** fossil purge undo ID
**
** Restore the content previously removed by purge ID.
**
** fossil purge wiki NAME ... ?OPTIONS?
**
** TBD...
**
** SUMMARY:
** fossil purge cat UUID...
** fossil purge [checkins] TAGS... [--explain]
** fossil purge artifacts UUID.. [OPTIONS]
** fossil purge cat UUID...
** fossil purge checkins TAGS... [OPTIONS]
** fossil purge files FILENAME... [OPTIONS]
** fossil purge list
** fossil purge obliterate ID...
** fossil purge tickets NAME... [OPTIONS]
** fossil purge undo ID
** fossil purge wiki NAME... [OPTIONS]
*/
void purge_cmd(void){
const char *zSubcmd;
int n;
Stmt q;
if( g.argc<3 ) usage("SUBCOMMAND ?ARGS?");
zSubcmd = g.argv[2];
db_find_and_open_repository(0,0);
n = (int)strlen(zSubcmd);
if( strncmp(zSubcmd, "artifacts", n)==0 ){
fossil_fatal("not yet implemented....");
if( strncmp(zSubcmd, "cat", n)==0 ){
}else if( strncmp(zSubcmd, "cat", n)==0 ){
int i, piid;
Blob content;
if( g.argc<4 ) usage("cat UUID...");
for(i=3; i<g.argc; i++){
piid = db_int(0, "SELECT piid FROM purgeitem WHERE uuid LIKE '%q%%'",
g.argv[i]);
if( piid==0 ) fossil_fatal("no such item: %s", g.argv[3]);
purge_extract_item(piid, &content);
blob_write_to_file(&content, "-");
blob_reset(&content);
}
/* The "checkins" subcommand goes here in alphabetical order, but it must
** be moved to the end since it is the default case */
}else if( strncmp(zSubcmd, "checkins", n)==0 ){
int explainOnly = find_option("explain",0,0)!=0;
int dryRun = find_option("dry-run",0,0)!=0;
int i;
int vid;
int nCkin;
int nArtifact;
verify_all_options();
db_begin_transaction();
if( g.argc<=3 ) usage("checkin TAGS... [OPTIONS]");
db_multi_exec("CREATE TEMP TABLE ok(rid INTEGER PRIMARY KEY)");
for(i=3; i<g.argc; i++){
int r = name_to_typed_rid(g.argv[i], "br");
compute_descendants(r, 1000000000);
}
vid = db_lget_int("checkout",0);
if( db_exists("SELECT 1 FROM ok WHERE rid=%d",vid) ){
fossil_fatal("cannot purge the current checkout");
}
nCkin = db_int(0, "SELECT count(*) FROM ok");
find_checkin_associates("ok", 1);
nArtifact = db_int(0, "SELECT count(*) FROM ok");
describe_artifacts_to_stdout("IN ok", 0);
if( !explainOnly ){
int peid = purge_artifact_list("ok","",PURGE_MOVETO_GRAVEYARD);
fossil_print("%d check-ins and %d artifacts purged.\n", nCkin, nArtifact);
fossil_print("undoable using \"%s purge undo %d\".\n",
g.nameOfExe, peid);
}
db_end_transaction(explainOnly||dryRun);
}else if( strncmp(zSubcmd, "files", n)==0 ){
fossil_fatal("not yet implemented....");
}else if( strncmp(zSubcmd, "list", n)==0 || strcmp(zSubcmd,"ls")==0 ){
int showDetail = find_option("l","l",0)!=0;
if( !db_table_exists("repository","purgeevent") ) return;
db_prepare(&q, "SELECT peid, datetime(ctime,'unixepoch',toLocal())"
" FROM purgeevent");
while( db_step(&q)==SQLITE_ROW ){
fossil_print("%4d on %s\n", db_column_int(&q,0), db_column_text(&q,1));
|
515
516
517
518
519
520
521
522
523
524
525
526
527
528
|
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
|
+
+
|
db_multi_exec(
"DELETE FROM purgeevent WHERE peid=%d;"
"DELETE FROM purgeitem WHERE peid=%d;",
peid, peid
);
}
db_end_transaction(0);
}else if( strncmp(zSubcmd, "tickets", n)==0 ){
fossil_fatal("not yet implemented....");
}else if( strncmp(zSubcmd, "undo", n)==0 ){
int peid;
if( g.argc!=4 ) usage("undo ID");
peid = atoi(g.argv[3]);
db_begin_transaction();
db_multi_exec(
"CREATE TEMP TABLE ix("
|
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
|
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
|
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
+
-
-
-
+
-
-
+
+
+
-
-
+
-
|
);
manifest_crosslink_begin();
purge_item_resurrect(0, 0);
manifest_crosslink_end(0);
db_multi_exec("DELETE FROM purgeevent WHERE peid=%d", peid);
db_multi_exec("DELETE FROM purgeitem WHERE peid=%d", peid);
db_end_transaction(0);
}else{
/* The "checkins" command is the default and so must occur last */
int explainOnly = find_option("explain",0,0)!=0;
int dryRun = find_option("dry-run",0,0)!=0;
int i;
int vid;
int nCkin;
int nArtifact;
verify_all_options();
db_begin_transaction();
i = strncmp(zSubcmd,"checkins",n)==0 ? 3 : 2;
}else if( strncmp(zSubcmd, "wiki", n)==0 ){
if( i>=g.argc ) usage("[checkin] TAGS... [--explain]");
db_multi_exec("CREATE TEMP TABLE ok(rid INTEGER PRIMARY KEY)");
for(; i<g.argc; i++){
int r = name_to_typed_rid(g.argv[i], "br");
compute_descendants(r, 1000000000);
}
vid = db_lget_int("checkout",0);
if( db_exists("SELECT 1 FROM ok WHERE rid=%d",vid) ){
fossil_fatal("cannot purge the current checkout");
fossil_fatal("not yet implemented....");
}
nCkin = db_int(0, "SELECT count(*) FROM ok");
find_checkin_associates("ok", 1);
nArtifact = db_int(0, "SELECT count(*) FROM ok");
if( explainOnly ){
describe_artifacts_to_stdout("IN ok", 0);
}else{
}else{
int peid = purge_artifact_list("ok","",1);
fossil_print("%d check-ins and %d artifacts purged.\n", nCkin, nArtifact);
fossil_print("undoable using \"%s purge undo %d\".\n",
fossil_fatal("unknown subcommand \"%s\".\n"
g.nameOfExe, peid);
}
"should be one of: cat, checkins, files, list, obliterate,"
" tickets, undo, wiki", zSubcmd);
}
db_end_transaction(explainOnly||dryRun);
}
}
}
|