ADDED src/bundle.c
Index: src/bundle.c
==================================================================
--- /dev/null
+++ src/bundle.c
@@ -0,0 +1,816 @@
+/*
+** Copyright (c) 2014 D. Richard Hipp
+**
+** This program is free software; you can redistribute it and/or
+** modify it under the terms of the Simplified BSD License (also
+** known as the "2-Clause License" or "FreeBSD License".)
+
+** This program is distributed in the hope that it will be useful,
+** but without any warranty; without even the implied warranty of
+** merchantability or fitness for a particular purpose.
+**
+** Author contact information:
+** drh@hwaci.com
+** http://www.hwaci.com/drh/
+**
+*******************************************************************************
+**
+** This file contains code used to implement and manage a "bundle" file.
+*/
+#include "config.h"
+#include "bundle.h"
+#include
+
+/*
+** SQL code used to initialize the schema of a bundle.
+**
+** The bblob.delta field can be an integer, a text string, or NULL.
+** If an integer, then the corresponding blobid is the delta basis.
+** If a text string, then that string is a SHA1 hash for the delta
+** basis, which is presumably in the master repository. If NULL, then
+** data contains contain without delta compression.
+*/
+static const char zBundleInit[] =
+@ CREATE TABLE IF NOT EXISTS "%w".bconfig(
+@ bcname TEXT,
+@ bcvalue ANY
+@ );
+@ CREATE TABLE IF NOT EXISTS "%w".bblob(
+@ blobid INTEGER PRIMARY KEY, -- Blob ID
+@ uuid TEXT NOT NULL, -- SHA1 hash of expanded blob
+@ sz INT NOT NULL, -- Size of blob after expansion
+@ delta ANY, -- Delta compression basis, or NULL
+@ notes TEXT, -- Description of content
+@ data BLOB -- compressed content
+@ );
+;
+
+/*
+** Attach a bundle file to the current database connection using the
+** attachment name zBName.
+*/
+static void bundle_attach_file(
+ const char *zFile, /* Name of the file that contains the bundle */
+ const char *zBName, /* Attachment name */
+ int doInit /* Initialize a new bundle, if true */
+){
+ int rc;
+ char *zErrMsg = 0;
+ char *zSql;
+ if( !doInit && file_size(zFile)<0 ){
+ fossil_fatal("no such file: %s", zFile);
+ }
+ assert( g.db );
+ zSql = sqlite3_mprintf("ATTACH %Q AS %Q", zFile, zBName);
+ if( zSql==0 ) fossil_fatal("out of memory");
+ rc = sqlite3_exec(g.db, zSql, 0, 0, &zErrMsg);
+ sqlite3_free(zSql);
+ if( rc!=SQLITE_OK || zErrMsg ){
+ if( zErrMsg==0 ) zErrMsg = sqlite3_errmsg(g.db);
+ fossil_fatal("not a valid bundle: %s", zFile);
+ }
+ if( doInit ){
+ db_multi_exec(zBundleInit /*works-like:"%w%w"*/, zBName, zBName);
+ }else{
+ sqlite3_stmt *pStmt;
+ zSql = sqlite3_mprintf("SELECT bcname, bcvalue"
+ " FROM \"%w\".bconfig", zBName);
+ if( zSql==0 ) fossil_fatal("out of memory");
+ rc = sqlite3_prepare(g.db, zSql, -1, &pStmt, 0);
+ if( rc ) fossil_fatal("not a valid bundle: %s", zFile);
+ sqlite3_free(zSql);
+ sqlite3_finalize(pStmt);
+ zSql = sqlite3_mprintf("SELECT blobid, uuid, sz, delta, notes, data"
+ " FROM \"%w\".bblob", zBName);
+ if( zSql==0 ) fossil_fatal("out of memory");
+ rc = sqlite3_prepare(g.db, zSql, -1, &pStmt, 0);
+ if( rc ) fossil_fatal("not a valid bundle: %s", zFile);
+ sqlite3_free(zSql);
+ sqlite3_finalize(pStmt);
+ }
+}
+
+/*
+** fossil bundle ls BUNDLE ?OPTIONS?
+**
+** Display the content of a bundle in human-readable form.
+*/
+static void bundle_ls_cmd(void){
+ Stmt q;
+ sqlite3_int64 sumSz = 0;
+ sqlite3_int64 sumLen = 0;
+ int bDetails = find_option("details","l",0)!=0;
+ verify_all_options();
+ if( g.argc!=4 ) usage("ls BUNDLE ?OPTIONS?");
+ bundle_attach_file(g.argv[3], "b1", 0);
+ db_prepare(&q,
+ "SELECT bcname, bcvalue FROM bconfig"
+ " WHERE typeof(bcvalue)='text'"
+ " AND bcvalue NOT GLOB char(0x2a,0x0a,0x2a);"
+ );
+ while( db_step(&q)==SQLITE_ROW ){
+ fossil_print("%s: %s\n", db_column_text(&q,0), db_column_text(&q,1));
+ }
+ db_finalize(&q);
+ fossil_print("%.78c\n",'-');
+ if( bDetails ){
+ db_prepare(&q,
+ "SELECT blobid, substr(uuid,1,10), coalesce(substr(delta,1,10),''),"
+ " sz, length(data), notes"
+ " FROM bblob"
+ );
+ while( db_step(&q)==SQLITE_ROW ){
+ fossil_print("%4d %10s %10s %8d %8d %s\n",
+ db_column_int(&q,0),
+ db_column_text(&q,1),
+ db_column_text(&q,2),
+ db_column_int(&q,3),
+ db_column_int(&q,4),
+ db_column_text(&q,5));
+ sumSz += db_column_int(&q,3);
+ sumLen += db_column_int(&q,4);
+ }
+ db_finalize(&q);
+ fossil_print("%27s %8lld %8lld\n", "Total:", sumSz, sumLen);
+ }else{
+ db_prepare(&q,
+ "SELECT substr(uuid,1,16), notes FROM bblob"
+ );
+ while( db_step(&q)==SQLITE_ROW ){
+ fossil_print("%16s %s\n",
+ db_column_text(&q,0),
+ db_column_text(&q,1));
+ }
+ db_finalize(&q);
+ }
+}
+
+/*
+** Implement the "fossil bundle append BUNDLE FILE..." command. Add
+** the named files into the BUNDLE. Create the BUNDLE if it does not
+** alraedy exist.
+*/
+static void bundle_append_cmd(void){
+ Blob content, hash;
+ int i;
+ Stmt q;
+
+ verify_all_options();
+ bundle_attach_file(g.argv[3], "b1", 1);
+ db_prepare(&q,
+ "INSERT INTO bblob(blobid, uuid, sz, delta, data, notes) "
+ "VALUES(NULL, $uuid, $sz, NULL, $data, $filename)");
+ db_begin_transaction();
+ for(i=4; i0 ){
+ double endTime = db_double(0.0, "SELECT mtime FROM event WHERE objid=%d",
+ endRid);
+ blob_appendf(&sql,
+ " AND child.rid!=%d"
+ " AND (SELECT mtime FROM event WHERE objid=plink.cid)<=%.17g",
+ endRid, endTime
+ );
+ }
+ if( zBr ){
+ blob_appendf(&sql,
+ " AND EXISTS(SELECT 1 FROM tagxref"
+ " WHERE tagid=%d AND tagtype>0"
+ " AND value=%Q and rid=plink.cid)",
+ TAG_BRANCH, zBr);
+ }
+ blob_appendf(&sql, ") INSERT OR IGNORE INTO \"%w\" SELECT rid FROM child;",
+ zTab);
+ db_multi_exec("%s", blob_str(&sql)/*safe-for-%s*/);
+ }
+}
+
+/*
+** COMMAND: test-subtree
+**
+** Usage: %fossil test-subtree ?OPTIONS?
+**
+** Show the subset of checkins that match the supplied options. This
+** command is used to test the subtree_from_options() subroutine in the
+** implementation and does not really have any other practical use that
+** we know of.
+**
+** Options:
+** --branch BRANCH Include only checkins on BRANCH
+** --from TAG Start the subtree at TAG
+** --to TAG End the subtree at TAG
+** --checkin TAG The subtree is the single checkin TAG
+** --all Include FILE and TAG artifacts
+** --exclusive Include FILES exclusively on checkins
+*/
+void test_subtree_cmd(void){
+ int bAll = find_option("all",0,0)!=0;
+ int bExcl = find_option("exclusive",0,0)!=0;
+ db_find_and_open_repository(0,0);
+ db_begin_transaction();
+ db_multi_exec("CREATE TEMP TABLE tobundle(rid INTEGER PRIMARY KEY);");
+ subtree_from_arguments("tobundle");
+ verify_all_options();
+ if( bAll ) find_checkin_associates("tobundle",bExcl);
+ describe_artifacts_to_stdout("IN tobundle", 0);
+ db_end_transaction(1);
+}
+
+/* fossil bundle export BUNDLE ?OPTIONS?
+**
+** OPTIONS:
+** --branch BRANCH --from TAG --to TAG
+** --checkin TAG
+** --standalone
+*/
+static void bundle_export_cmd(void){
+ int bStandalone = find_option("standalone",0,0)!=0;
+ int mnToBundle; /* Minimum RID in the bundle */
+ Stmt q;
+
+ /* Decode the arguments (like --branch) that specify which artifacts
+ ** should be in the bundle */
+ db_multi_exec("CREATE TEMP TABLE tobundle(rid INTEGER PRIMARY KEY);");
+ subtree_from_arguments("tobundle");
+ find_checkin_associates("tobundle", 0);
+ verify_all_options();
+ describe_artifacts("IN tobundle");
+
+ if( g.argc!=4 ) usage("export BUNDLE ?OPTIONS?");
+ /* Create the new bundle */
+ bundle_attach_file(g.argv[3], "b1", 1);
+ db_begin_transaction();
+
+ /* Add 'mtime' and 'project-code' entries to the bconfig table */
+ db_multi_exec(
+ "INSERT INTO bconfig(bcname,bcvalue)"
+ " VALUES('mtime',datetime('now'));"
+ );
+ db_multi_exec(
+ "INSERT INTO bconfig(bcname,bcvalue)"
+ " SELECT name, value FROM config"
+ " WHERE name IN ('project-code');"
+ );
+
+ /* Directly copy content from the repository into the bundle as long
+ ** as the repository content is a delta from some other artifact that
+ ** is also in the bundle.
+ */
+ db_multi_exec(
+ "REPLACE INTO bblob(blobid,uuid,sz,delta,data,notes) "
+ " SELECT"
+ " tobundle.rid,"
+ " blob.uuid,"
+ " blob.size,"
+ " delta.srcid,"
+ " blob.content,"
+ " (SELECT summary FROM description WHERE rid=blob.rid)"
+ " FROM tobundle, blob, delta"
+ " WHERE blob.rid=tobundle.rid"
+ " AND delta.rid=tobundle.rid"
+ " AND delta.srcid IN tobundle;"
+ );
+
+ /* For all the remaining artifacts, we need to construct their deltas
+ ** manually.
+ */
+ mnToBundle = db_int(0,"SELECT min(rid) FROM tobundle");
+ db_prepare(&q,
+ "SELECT rid FROM tobundle"
+ " WHERE rid NOT IN (SELECT blobid FROM bblob)"
+ " ORDER BY +rid;"
+ );
+ while( db_step(&q)==SQLITE_ROW ){
+ Blob content;
+ int rid = db_column_int(&q,0);
+ int deltaFrom = 0;
+
+ /* Get the raw, uncompressed content of the artifact into content */
+ content_get(rid, &content);
+
+ /* Try to find another artifact, not within the bundle, that is a
+ ** plausible candidate for being a delta basis for the content. Set
+ ** deltaFrom to the RID of that other artifact. Leave deltaFrom set
+ ** to zero if the content should not be delta-compressed
+ */
+ if( !bStandalone ){
+ if( db_exists("SELECT 1 FROM plink WHERE cid=%d",rid) ){
+ deltaFrom = db_int(0,
+ "SELECT max(cid) FROM plink"
+ " WHERE cid<%d", mnToBundle);
+ }else{
+ deltaFrom = db_int(0,
+ "SELECT max(fid) FROM mlink"
+ " WHERE fnid=(SELECT fnid FROM mlink WHERE fid=%d)"
+ " AND fid<%d", rid, mnToBundle);
+ }
+ }
+
+ /* Try to insert the insert the artifact as a delta
+ */
+ if( deltaFrom ){
+ Blob basis, delta;
+ content_get(deltaFrom, &basis);
+ blob_delta_create(&basis, &content, &delta);
+ if( blob_size(&delta)>0.9*blob_size(&content) ){
+ deltaFrom = 0;
+ }else{
+ Stmt ins;
+ blob_compress(&delta, &delta);
+ db_prepare(&ins,
+ "REPLACE INTO bblob(blobid,uuid,sz,delta,data,notes)"
+ " SELECT %d, uuid, size, (SELECT uuid FROM blob WHERE rid=%d),"
+ " :delta, (SELECT summary FROM description WHERE rid=blob.rid)"
+ " FROM blob WHERE rid=%d", rid, deltaFrom, rid);
+ db_bind_blob(&ins, ":delta", &delta);
+ db_step(&ins);
+ db_finalize(&ins);
+ }
+ blob_reset(&basis);
+ blob_reset(&delta);
+ }
+
+ /* If unable to insert the artifact as a delta, insert full-text */
+ if( deltaFrom==0 ){
+ Stmt ins;
+ blob_compress(&content, &content);
+ db_prepare(&ins,
+ "REPLACE INTO bblob(blobid,uuid,sz,delta,data,notes)"
+ " SELECT rid, uuid, size, NULL, :content,"
+ " (SELECT summary FROM description WHERE rid=blob.rid)"
+ " FROM blob WHERE rid=%d", rid);
+ db_bind_blob(&ins, ":content", &content);
+ db_step(&ins);
+ db_finalize(&ins);
+ }
+ blob_reset(&content);
+ }
+ db_finalize(&q);
+
+ db_end_transaction(0);
+}
+
+
+/*
+** There is a TEMP table bix(blobid,delta) containing a set of purgeitems
+** that need to be transferred to the BLOB table. This routine does
+** all items that have srcid=iSrc. The pBasis blob holds the content
+** of the source document if iSrc>0.
+*/
+static void bundle_import_elements(int iSrc, Blob *pBasis, int isPriv){
+ Stmt q;
+ static Bag busy;
+ assert( pBasis!=0 || iSrc==0 );
+ if( iSrc>0 ){
+ if( bag_find(&busy, iSrc) ){
+ fossil_fatal("delta loop while uncompressing bundle artifacts");
+ }
+ bag_insert(&busy, iSrc);
+ }
+ db_prepare(&q,
+ "SELECT uuid, data, bblob.delta, bix.blobid"
+ " FROM bix, bblob"
+ " WHERE bix.delta=%d"
+ " AND bix.blobid=bblob.blobid;",
+ iSrc
+ );
+ while( db_step(&q)==SQLITE_ROW ){
+ Blob h1, h2, c1, c2;
+ int rid;
+ blob_zero(&h1);
+ db_column_blob(&q, 0, &h1);
+ blob_zero(&c1);
+ db_column_blob(&q, 1, &c1);
+ blob_uncompress(&c1, &c1);
+ blob_zero(&c2);
+ if( db_column_type(&q,2)==SQLITE_TEXT && db_column_bytes(&q,2)==40 ){
+ Blob basis;
+ rid = db_int(0,"SELECT rid FROM blob WHERE uuid=%Q",
+ db_column_text(&q,2));
+ content_get(rid, &basis);
+ blob_delta_apply(&basis, &c1, &c2);
+ blob_reset(&basis);
+ blob_reset(&c1);
+ }else if( pBasis ){
+ blob_delta_apply(pBasis, &c1, &c2);
+ blob_reset(&c1);
+ }else{
+ c2 = c1;
+ }
+ sha1sum_blob(&c2, &h2);
+ if( blob_compare(&h1, &h2)!=0 ){
+ fossil_fatal("SHA1 hash mismatch - wanted %s, got %s",
+ blob_str(&h1), blob_str(&h2));
+ }
+ blob_reset(&h2);
+ rid = content_put_ex(&c2, blob_str(&h1), 0, 0, isPriv);
+ if( rid==0 ){
+ fossil_fatal("%s", g.zErrMsg);
+ }else{
+ if( !isPriv ) content_make_public(rid);
+ content_get(rid, &c1);
+ manifest_crosslink(rid, &c1, MC_NO_ERRORS);
+ db_multi_exec("INSERT INTO got(rid) VALUES(%d)",rid);
+ }
+ bundle_import_elements(db_column_int(&q,3), &c2, isPriv);
+ blob_reset(&c2);
+ }
+ db_finalize(&q);
+ if( iSrc>0 ) bag_remove(&busy, iSrc);
+}
+
+/*
+** Extract an item from content from the bundle
+*/
+static void bundle_extract_item(
+ int blobid, /* ID of the item to extract */
+ Blob *pOut /* Write the content into this blob */
+){
+ Stmt q;
+ Blob x, basis, h1, h2;
+ static Bag busy;
+
+ db_prepare(&q, "SELECT uuid, delta, data FROM bblob"
+ " WHERE blobid=%d", blobid);
+ if( db_step(&q)!=SQLITE_ROW ){
+ db_finalize(&q);
+ fossil_fatal("no such item: %d", blobid);
+ }
+ if( bag_find(&busy, blobid) ) fossil_fatal("delta loop");
+ blob_zero(&x);
+ db_column_blob(&q, 2, &x);
+ blob_uncompress(&x, &x);
+ if( db_column_type(&q,1)==SQLITE_INTEGER ){
+ bundle_extract_item(db_column_int(&q,1), &basis);
+ blob_delta_apply(&basis, &x, pOut);
+ blob_reset(&basis);
+ blob_reset(&x);
+ }else if( db_column_type(&q,1)==SQLITE_TEXT ){
+ int rid = db_int(0, "SELECT rid FROM blob WHERE uuid=%Q",
+ db_column_text(&q,1));
+ if( rid==0 ){
+ fossil_fatal("cannot find delta basis %s", db_column_text(&q,1));
+ }
+ content_get(rid, &basis);
+ db_column_blob(&q, 2, &x);
+ blob_delta_apply(&basis, &x, pOut);
+ blob_reset(&basis);
+ blob_reset(&x);
+ }else{
+ *pOut = x;
+ }
+ blob_zero(&h1);
+ db_column_blob(&q, 0, &h1);
+ sha1sum_blob(pOut, &h2);
+ if( blob_compare(&h1, &h2)!=0 ){
+ fossil_fatal("SHA1 hash mismatch - wanted %s, got %s",
+ blob_str(&h1), blob_str(&h2));
+ }
+ blob_reset(&h1);
+ blob_reset(&h2);
+ bag_remove(&busy, blobid);
+ db_finalize(&q);
+}
+
+/* fossil bundle cat BUNDLE UUID...
+**
+** Write elements of a bundle on standard output
+*/
+static void bundle_cat_cmd(void){
+ int i;
+ Blob x;
+ verify_all_options();
+ if( g.argc<5 ) usage("cat BUNDLE UUID...");
+ bundle_attach_file(g.argv[3], "b1", 1);
+ blob_zero(&x);
+ for(i=4; i=0);"
+ "CREATE TEMP TABLE got(rid INTEGER PRIMARY KEY ON CONFLICT IGNORE);"
+ );
+ manifest_crosslink_begin();
+ bundle_import_elements(0, 0, isPriv);
+ manifest_crosslink_end(0);
+ describe_artifacts_to_stdout("IN got", "Imported content:");
+ db_end_transaction(0);
+}
+
+/* fossil bundle purge BUNDLE
+**
+** Try to undo a prior "bundle import BUNDLE".
+**
+** If the --force option is omitted, then this will only work if
+** there have been no checkins or tags added that use the import.
+**
+** This routine never removes content that is not already in the bundle
+** so the bundle serves as a backup. The purge can be undone using
+** "fossil bundle import BUNDLE".
+*/
+static void bundle_purge_cmd(void){
+ int bForce = find_option("force",0,0)!=0;
+ int bTest = find_option("test",0,0)!=0; /* Undocumented --test option */
+ const char *zFile = g.argv[3];
+ verify_all_options();
+ if ( g.argc!=4 ) usage("purge BUNDLE ?OPTIONS?");
+ bundle_attach_file(zFile, "b1", 0);
+ db_begin_transaction();
+
+ /* Find all checkins of the bundle */
+ db_multi_exec(
+ "CREATE TEMP TABLE ok(rid INTEGER PRIMARY KEY);"
+ "INSERT OR IGNORE INTO ok SELECT blob.rid FROM bblob, blob, plink"
+ " WHERE bblob.uuid=blob.uuid"
+ " AND plink.cid=blob.rid;"
+ );
+
+ /* Check to see if new checkins have been committed to checkins in
+ ** the bundle. Do not allow the purge if that is true and if --force
+ ** is omitted.
+ */
+ if( !bForce ){
+ Stmt q;
+ int n = 0;
+ db_prepare(&q,
+ "SELECT cid FROM plink WHERE pid IN ok AND cid NOT IN ok"
+ );
+ while( db_step(&q)==SQLITE_ROW ){
+ whatis_rid(db_column_int(&q,0),0);
+ fossil_print("%.78c\n", '-');
+ n++;
+ }
+ db_finalize(&q);
+ if( n>0 ){
+ fossil_fatal("checkins above are derived from checkins in the bundle.");
+ }
+ }
+
+ /* Find all files associated with those check-ins that are used
+ ** nowhere else. */
+ find_checkin_associates("ok", 1);
+
+ /* Check to see if any associated files are not in the bundle. Issue
+ ** an error if there are any, unless --force is used.
+ */
+ if( !bForce ){
+ db_multi_exec(
+ "CREATE TEMP TABLE err1(rid INTEGER PRIMARY KEY);"
+ "INSERT INTO err1 "
+ " SELECT blob.rid FROM ok CROSS JOIN blob"
+ " WHERE blob.rid=ok.rid"
+ " AND blob.uuid NOT IN (SELECT uuid FROM bblob);"
+ );
+ if( db_changes() ){
+ describe_artifacts_to_stdout("IN err1", 0);
+ fossil_fatal("artifacts above associated with bundle checkins "
+ " are not in the bundle");
+ }else{
+ db_multi_exec("DROP TABLE err1;");
+ }
+ }
+
+ if( bTest ){
+ describe_artifacts_to_stdout(
+ "IN (SELECT blob.rid FROM ok, blob, bblob"
+ " WHERE blob.rid=ok.rid AND blob.uuid=bblob.uuid)",
+ "Purged artifacts found in the bundle:");
+ describe_artifacts_to_stdout(
+ "IN (SELECT blob.rid FROM ok, blob"
+ " WHERE blob.rid=ok.rid "
+ " AND blob.uuid NOT IN (SELECT uuid FROM bblob))",
+ "Purged artifacts NOT in the bundle:");
+ describe_artifacts_to_stdout(
+ "IN (SELECT blob.rid FROM bblob, blob"
+ " WHERE blob.uuid=bblob.uuid "
+ " AND blob.rid NOT IN ok)",
+ "Artifacts in the bundle but not purged:");
+ }else{
+ purge_artifact_list("ok",0,0);
+ }
+ db_end_transaction(0);
+}
+
+/*
+** COMMAND: bundle
+**
+** Usage: %fossil bundle SUBCOMMAND ARGS...
+**
+** fossil bundle append BUNDLE FILE...
+**
+** Add files named on the command line to BUNDLE. This subcommand has
+** little practical use and is mostly intended for testing.
+**
+** fossil bundle cat BUNDLE UUID...
+**
+** Extract one or more artifacts from the bundle and write them
+** consecutively on standard output. This subcommand was designed
+** for testing and introspection of bundles and is not something
+** commonly used.
+**
+** fossil bundle export BUNDLE ?OPTIONS?
+**
+** Generate a new bundle, in the file named BUNDLE, that contains a
+** subset of the checkins in the repository (usually a single branch)
+** described by the --branch, --from, --to, and/or --checkin options,
+** at least one of which is required. If BUNDLE already exists, the
+** specified content is added to the bundle.
+**
+** --branch BRANCH Package all check-ins on BRANCH.
+** --from TAG1 --to TAG2 Package checkins between TAG1 and TAG2.
+** --checkin TAG Package the single checkin TAG
+** --standalone Do no use delta-encoding against
+** artifacts not in the bundle
+**
+** fossil bundle extend BUNDLE
+**
+** The BUNDLE must already exist. This subcommand adds to the bundle
+** any checkins that are descendants of checkins already in the bundle,
+** and any tags that apply to artifacts in the bundle.
+**
+** fossil bundle import BUNDLE ?--publish?
+**
+** Import all content from BUNDLE into the repository. By default, the
+** imported files are private and will not sync. Use the --publish
+** option makes the import public.
+**
+** fossil bundle ls BUNDLE
+**
+** List the contents of BUNDLE on standard output
+**
+** fossil bundle purge BUNDLE
+**
+** Remove from the repository all files that are used exclusively
+** by checkins in BUNDLE. This has the effect of undoing a
+** "fossil bundle import".
+**
+** SUMMARY:
+** fossil bundle append BUNDLE FILE... Add files to BUNDLE
+** fossil bundle cat BUNDLE UUID... Extract file from BUNDLE
+** fossil bundle export BUNDLE ?OPTIONS? Create a new BUNDLE
+** --branch BRANCH --from TAG1 --to TAG2 Checkins to include
+** --checkin TAG Use only checkin TAG
+** --standalone Omit dependencies
+** fossil bundle extend BUNDLE Update with newer content
+** fossil bundle import BUNDLE ?OPTIONS? Import a bundle
+** --publish Publish the import
+** --force Cross-repo import
+** fossil bundle ls BUNDLE List content of a bundle
+** fossil bundle purge BUNDLE Undo an import
+*/
+void bundle_cmd(void){
+ const char *zSubcmd;
+ int n;
+ if( g.argc<4 ) usage("SUBCOMMAND BUNDLE ?OPTIONS?");
+ zSubcmd = g.argv[2];
+ db_find_and_open_repository(0,0);
+ n = (int)strlen(zSubcmd);
+ if( strncmp(zSubcmd, "append", n)==0 ){
+ bundle_append_cmd();
+ }else if( strncmp(zSubcmd, "cat", n)==0 ){
+ bundle_cat_cmd();
+ }else if( strncmp(zSubcmd, "export", n)==0 ){
+ bundle_export_cmd();
+ }else if( strncmp(zSubcmd, "extend", n)==0 ){
+ fossil_fatal("not yet implemented");
+ }else if( strncmp(zSubcmd, "import", n)==0 ){
+ bundle_import_cmd();
+ }else if( strncmp(zSubcmd, "ls", n)==0 ){
+ bundle_ls_cmd();
+ }else if( strncmp(zSubcmd, "purge", n)==0 ){
+ bundle_purge_cmd();
+ }else{
+ fossil_fatal("unknown subcommand for bundle: %s", zSubcmd);
+ }
+}
Index: src/content.c
==================================================================
--- src/content.c
+++ src/content.c
@@ -567,14 +567,14 @@
db_exec(&s1);
rid = db_last_insert_rowid();
if( !pBlob ){
db_multi_exec("INSERT OR IGNORE INTO phantom VALUES(%d)", rid);
}
- if( g.markPrivate || isPrivate ){
- db_multi_exec("INSERT INTO private VALUES(%d)", rid);
- markAsUnclustered = 0;
- }
+ }
+ if( g.markPrivate || isPrivate ){
+ db_multi_exec("INSERT INTO private VALUES(%d)", rid);
+ markAsUnclustered = 0;
}
if( nBlob==0 ) blob_reset(&cmpr);
/* If the srcId is specified, then the data we just added is
** really a delta. Record this fact in the delta table.
Index: src/db.c
==================================================================
--- src/db.c
+++ src/db.c
@@ -424,10 +424,13 @@
/*
** Extract text, integer, or blob values from the N-th column of the
** current row.
*/
+int db_column_type(Stmt *pStmt, int N){
+ return sqlite3_column_type(pStmt->pStmt, N);
+}
int db_column_bytes(Stmt *pStmt, int N){
return sqlite3_column_bytes(pStmt->pStmt, N);
}
int db_column_int(Stmt *pStmt, int N){
return sqlite3_column_int(pStmt->pStmt, N);
@@ -486,10 +489,50 @@
while( (rc = db_step(pStmt))==SQLITE_ROW ){}
rc = db_reset(pStmt);
db_check_result(rc);
return rc;
}
+
+/*
+** Print the output of one or more SQL queries on standard output.
+** This routine is used for debugging purposes only.
+*/
+int db_debug(const char *zSql, ...){
+ Blob sql;
+ int rc = SQLITE_OK;
+ va_list ap;
+ const char *z, *zEnd;
+ sqlite3_stmt *pStmt;
+ blob_init(&sql, 0, 0);
+ va_start(ap, zSql);
+ blob_vappendf(&sql, zSql, ap);
+ va_end(ap);
+ z = blob_str(&sql);
+ while( rc==SQLITE_OK && z[0] ){
+ pStmt = 0;
+ rc = sqlite3_prepare_v2(g.db, z, -1, &pStmt, &zEnd);
+ if( rc!=SQLITE_OK ) break;
+ if( pStmt ){
+ int nRow = 0;
+ db.nPrepare++;
+ while( sqlite3_step(pStmt)==SQLITE_ROW ){
+ int i, n;
+ if( nRow++ > 0 ) fossil_print("\n");
+ n = sqlite3_column_count(pStmt);
+ for(i=0; i Width of lines (default is to auto-detect).
** Must be >20 or 0 (= no limit, resulting in a
@@ -334,11 +334,11 @@
"%s"
" AND event.objid IN (SELECT rid FROM leaves)"
" ORDER BY event.mtime DESC",
timeline_query_for_tty()
);
- print_timeline(&q, -20, width, 0);
+ print_timeline(&q, 0, width, 0);
db_finalize(&q);
}
/*
** COMMAND: leaves*
Index: src/finfo.c
==================================================================
--- src/finfo.c
+++ src/finfo.c
@@ -495,10 +495,11 @@
@
fid=%d(frid) pid=%d(fpid) mid=%d(fmid) sz=%d(sz)
if( srcid ){
@ srcid=%d(srcid)
}
}
+ tag_private_status(frid);
@
}
db_finalize(&q);
if( pGraph ){
graph_finish(pGraph, 0);
Index: src/foci.c
==================================================================
--- src/foci.c
+++ src/foci.c
@@ -104,14 +104,11 @@
/*
** Open a new focivfs cursor.
*/
static int fociOpen(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCursor){
- FociTable *pTab = (FociTable *)pVTab;
FociCursor *pCsr;
- int rc;
-
pCsr = (FociCursor *)sqlite3_malloc(sizeof(FociCursor));
memset(pCsr, 0, sizeof(FociCursor));
pCsr->base.pVtab = pVTab;
*ppCursor = (sqlite3_vtab_cursor *)pCsr;
return SQLITE_OK;
Index: src/info.c
==================================================================
--- src/info.c
+++ src/info.c
@@ -931,10 +931,11 @@
}else{
@ tags: %h(zTagList),
}
@ date:
hyperlink_to_date(zDate, ")");
+ tag_private_status(rid);
}
db_finalize(&q);
}
@@ -1203,19 +1204,20 @@
}else{
@ File
}
objType |= OBJTYPE_CONTENT;
@ %z(href("%R/finfo?name=%T",zName))%h(zName)
+ tag_private_status(rid);
if( showDetail ){
@
}
prevName = fossil_strdup(zName);
}
if( showDetail ){
@ -
hyperlink_to_date(zDate,"");
- @ — part of check-in
+ @ — part of checkin
hyperlink_to_uuid(zVers);
}else{
@ — part of checkin
hyperlink_to_uuid(zVers);
@ at
@@ -1314,10 +1316,11 @@
hyperlink_to_user(zUser,zDate," on");
hyperlink_to_date(zDate, ".");
if( pDownloadName && blob_size(pDownloadName)==0 ){
blob_appendf(pDownloadName, "%.10s.txt", zUuid);
}
+ tag_private_status(rid);
cnt++;
}
db_finalize(&q);
}
db_prepare(&q,
@@ -1357,17 +1360,19 @@
hyperlink_to_date(zDate,".");
cnt++;
if( pDownloadName && blob_size(pDownloadName)==0 ){
blob_append(pDownloadName, zFilename, -1);
}
+ tag_private_status(rid);
}
db_finalize(&q);
if( cnt==0 ){
@ Control artifact.
if( pDownloadName && blob_size(pDownloadName)==0 ){
blob_appendf(pDownloadName, "%.10s.txt", zUuid);
}
+ tag_private_status(rid);
}
return objType;
}
Index: src/main.mk
==================================================================
--- src/main.mk
+++ src/main.mk
@@ -21,10 +21,11 @@
$(SRCDIR)/bisect.c \
$(SRCDIR)/blob.c \
$(SRCDIR)/branch.c \
$(SRCDIR)/browse.c \
$(SRCDIR)/builtin.c \
+ $(SRCDIR)/bundle.c \
$(SRCDIR)/cache.c \
$(SRCDIR)/captcha.c \
$(SRCDIR)/cgi.c \
$(SRCDIR)/checkin.c \
$(SRCDIR)/checkout.c \
@@ -87,10 +88,12 @@
$(SRCDIR)/path.c \
$(SRCDIR)/pivot.c \
$(SRCDIR)/popen.c \
$(SRCDIR)/pqueue.c \
$(SRCDIR)/printf.c \
+ $(SRCDIR)/publish.c \
+ $(SRCDIR)/purge.c \
$(SRCDIR)/rebuild.c \
$(SRCDIR)/regexp.c \
$(SRCDIR)/report.c \
$(SRCDIR)/rss.c \
$(SRCDIR)/schema.c \
@@ -139,10 +142,11 @@
$(OBJDIR)/bisect_.c \
$(OBJDIR)/blob_.c \
$(OBJDIR)/branch_.c \
$(OBJDIR)/browse_.c \
$(OBJDIR)/builtin_.c \
+ $(OBJDIR)/bundle_.c \
$(OBJDIR)/cache_.c \
$(OBJDIR)/captcha_.c \
$(OBJDIR)/cgi_.c \
$(OBJDIR)/checkin_.c \
$(OBJDIR)/checkout_.c \
@@ -205,10 +209,12 @@
$(OBJDIR)/path_.c \
$(OBJDIR)/pivot_.c \
$(OBJDIR)/popen_.c \
$(OBJDIR)/pqueue_.c \
$(OBJDIR)/printf_.c \
+ $(OBJDIR)/publish_.c \
+ $(OBJDIR)/purge_.c \
$(OBJDIR)/rebuild_.c \
$(OBJDIR)/regexp_.c \
$(OBJDIR)/report_.c \
$(OBJDIR)/rss_.c \
$(OBJDIR)/schema_.c \
@@ -254,10 +260,11 @@
$(OBJDIR)/bisect.o \
$(OBJDIR)/blob.o \
$(OBJDIR)/branch.o \
$(OBJDIR)/browse.o \
$(OBJDIR)/builtin.o \
+ $(OBJDIR)/bundle.o \
$(OBJDIR)/cache.o \
$(OBJDIR)/captcha.o \
$(OBJDIR)/cgi.o \
$(OBJDIR)/checkin.o \
$(OBJDIR)/checkout.o \
@@ -320,10 +327,12 @@
$(OBJDIR)/path.o \
$(OBJDIR)/pivot.o \
$(OBJDIR)/popen.o \
$(OBJDIR)/pqueue.o \
$(OBJDIR)/printf.o \
+ $(OBJDIR)/publish.o \
+ $(OBJDIR)/purge.o \
$(OBJDIR)/rebuild.o \
$(OBJDIR)/regexp.o \
$(OBJDIR)/report.o \
$(OBJDIR)/rss.o \
$(OBJDIR)/schema.o \
@@ -478,10 +487,11 @@
$(OBJDIR)/bisect_.c:$(OBJDIR)/bisect.h \
$(OBJDIR)/blob_.c:$(OBJDIR)/blob.h \
$(OBJDIR)/branch_.c:$(OBJDIR)/branch.h \
$(OBJDIR)/browse_.c:$(OBJDIR)/browse.h \
$(OBJDIR)/builtin_.c:$(OBJDIR)/builtin.h \
+ $(OBJDIR)/bundle_.c:$(OBJDIR)/bundle.h \
$(OBJDIR)/cache_.c:$(OBJDIR)/cache.h \
$(OBJDIR)/captcha_.c:$(OBJDIR)/captcha.h \
$(OBJDIR)/cgi_.c:$(OBJDIR)/cgi.h \
$(OBJDIR)/checkin_.c:$(OBJDIR)/checkin.h \
$(OBJDIR)/checkout_.c:$(OBJDIR)/checkout.h \
@@ -544,10 +554,12 @@
$(OBJDIR)/path_.c:$(OBJDIR)/path.h \
$(OBJDIR)/pivot_.c:$(OBJDIR)/pivot.h \
$(OBJDIR)/popen_.c:$(OBJDIR)/popen.h \
$(OBJDIR)/pqueue_.c:$(OBJDIR)/pqueue.h \
$(OBJDIR)/printf_.c:$(OBJDIR)/printf.h \
+ $(OBJDIR)/publish_.c:$(OBJDIR)/publish.h \
+ $(OBJDIR)/purge_.c:$(OBJDIR)/purge.h \
$(OBJDIR)/rebuild_.c:$(OBJDIR)/rebuild.h \
$(OBJDIR)/regexp_.c:$(OBJDIR)/regexp.h \
$(OBJDIR)/report_.c:$(OBJDIR)/report.h \
$(OBJDIR)/rss_.c:$(OBJDIR)/rss.h \
$(OBJDIR)/schema_.c:$(OBJDIR)/schema.h \
@@ -660,10 +672,18 @@
$(OBJDIR)/builtin.o: $(OBJDIR)/builtin_.c $(OBJDIR)/builtin.h $(OBJDIR)/builtin_data.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/builtin.o -c $(OBJDIR)/builtin_.c
$(OBJDIR)/builtin.h: $(OBJDIR)/headers
+
+$(OBJDIR)/bundle_.c: $(SRCDIR)/bundle.c $(OBJDIR)/translate
+ $(OBJDIR)/translate $(SRCDIR)/bundle.c >$@
+
+$(OBJDIR)/bundle.o: $(OBJDIR)/bundle_.c $(OBJDIR)/bundle.h $(SRCDIR)/config.h
+ $(XTCC) -o $(OBJDIR)/bundle.o -c $(OBJDIR)/bundle_.c
+
+$(OBJDIR)/bundle.h: $(OBJDIR)/headers
$(OBJDIR)/cache_.c: $(SRCDIR)/cache.c $(OBJDIR)/translate
$(OBJDIR)/translate $(SRCDIR)/cache.c >$@
$(OBJDIR)/cache.o: $(OBJDIR)/cache_.c $(OBJDIR)/cache.h $(SRCDIR)/config.h
@@ -1188,10 +1208,26 @@
$(OBJDIR)/printf.o: $(OBJDIR)/printf_.c $(OBJDIR)/printf.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/printf.o -c $(OBJDIR)/printf_.c
$(OBJDIR)/printf.h: $(OBJDIR)/headers
+
+$(OBJDIR)/publish_.c: $(SRCDIR)/publish.c $(OBJDIR)/translate
+ $(OBJDIR)/translate $(SRCDIR)/publish.c >$@
+
+$(OBJDIR)/publish.o: $(OBJDIR)/publish_.c $(OBJDIR)/publish.h $(SRCDIR)/config.h
+ $(XTCC) -o $(OBJDIR)/publish.o -c $(OBJDIR)/publish_.c
+
+$(OBJDIR)/publish.h: $(OBJDIR)/headers
+
+$(OBJDIR)/purge_.c: $(SRCDIR)/purge.c $(OBJDIR)/translate
+ $(OBJDIR)/translate $(SRCDIR)/purge.c >$@
+
+$(OBJDIR)/purge.o: $(OBJDIR)/purge_.c $(OBJDIR)/purge.h $(SRCDIR)/config.h
+ $(XTCC) -o $(OBJDIR)/purge.o -c $(OBJDIR)/purge_.c
+
+$(OBJDIR)/purge.h: $(OBJDIR)/headers
$(OBJDIR)/rebuild_.c: $(SRCDIR)/rebuild.c $(OBJDIR)/translate
$(OBJDIR)/translate $(SRCDIR)/rebuild.c >$@
$(OBJDIR)/rebuild.o: $(OBJDIR)/rebuild_.c $(OBJDIR)/rebuild.h $(SRCDIR)/config.h
Index: src/makemake.tcl
==================================================================
--- src/makemake.tcl
+++ src/makemake.tcl
@@ -28,10 +28,11 @@
bisect
blob
branch
browse
builtin
+ bundle
cache
captcha
cgi
checkin
checkout
@@ -93,10 +94,12 @@
path
pivot
popen
pqueue
printf
+ publish
+ purge
rebuild
regexp
report
rss
schema
Index: src/mkversion.c
==================================================================
--- src/mkversion.c
+++ src/mkversion.c
@@ -7,10 +7,11 @@
**
** Note that the manifest.uuid and manifest files are generated by Fossil.
*/
#include
#include
+#include
int main(int argc, char *argv[]){
FILE *m,*u,*v;
char *z;
int i, x, d;
@@ -17,11 +18,14 @@
char b[1000];
char vx[1000];
memset(b,0,sizeof(b));
memset(vx,0,sizeof(vx));
u = fopen(argv[1],"r");
- fgets(b, sizeof(b)-1,u);
+ if( fgets(b, sizeof(b)-1,u)==0 ){
+ fprintf(stderr, "malformed manifest.uuid file: %s\n", argv[1]);
+ exit(1);
+ }
fclose(u);
for(z=b; z[0] && z[0]!='\r' && z[0]!='\n'; z++){}
*z = 0;
printf("#define MANIFEST_UUID \"%s\"\n",b);
printf("#define MANIFEST_VERSION \"[%10.10s]\"\n",b);
@@ -32,11 +36,14 @@
printf("#define MANIFEST_YEAR \"%.4s\"\n",b+2);
}
}
fclose(m);
v = fopen(argv[3],"r");
- fgets(b, sizeof(b)-1,v);
+ if( fgets(b, sizeof(b)-1,v)==0 ){
+ fprintf(stderr, "malformed VERSION file: %s\n", argv[3]);
+ exit(1);
+ }
fclose(v);
for(z=b; z[0] && z[0]!='\r' && z[0]!='\n'; z++){}
*z = 0;
printf("#define RELEASE_VERSION \"%s\"\n", b);
x=0;
Index: src/name.c
==================================================================
--- src/name.c
+++ src/name.c
@@ -42,10 +42,44 @@
if( z[7]!='-') return 0;
if( !fossil_isdigit(z[8]) ) return 0;
if( !fossil_isdigit(z[9]) ) return 0;
return 1;
}
+
+/*
+** Return the RID that is the "root" of the branch that contains
+** check-in "rid" if inBranch==0 or the first check-in in the branch
+** if inBranch==1.
+*/
+int start_of_branch(int rid, int inBranch){
+ Stmt q;
+ int rc;
+ char *zBr;
+ zBr = db_text("trunk","SELECT value FROM tagxref"
+ " WHERE rid=%d AND tagid=%d"
+ " AND tagtype>0",
+ rid, TAG_BRANCH);
+ db_prepare(&q,
+ "SELECT pid, EXISTS(SELECT 1 FROM tagxref"
+ " WHERE tagid=%d AND tagtype>0"
+ " AND value=%Q AND rid=plink.pid)"
+ " FROM plink"
+ " WHERE cid=:cid AND isprim",
+ TAG_BRANCH, zBr
+ );
+ fossil_free(zBr);
+ do{
+ db_reset(&q);
+ db_bind_int(&q, ":cid", rid);
+ rc = db_step(&q);
+ if( rc!=SQLITE_ROW ) break;
+ if( inBranch && db_column_int(&q,1)==0 ) break;
+ rid = db_column_int(&q, 0);
+ }while( db_column_int(&q, 1)==1 && rid>0 );
+ db_finalize(&q);
+ return rid;
+}
/*
** Convert a symbolic name into a RID. Acceptable forms:
**
** * SHA1 hash
@@ -66,20 +100,28 @@
** Return the RID of the matching artifact. Or return 0 if the name does not
** match any known object. Or return -1 if the name is ambiguous.
**
** The zType parameter specifies the type of artifact: ci, t, w, e, g.
** If zType is NULL or "" or "*" then any type of artifact will serve.
+** If zType is "br" then find the first check-in of the named branch
+** rather than the last.
** zType is "ci" in most use cases since we are usually searching for
** a check-in.
*/
int symbolic_name_to_rid(const char *zTag, const char *zType){
int vid;
int rid = 0;
int nTag;
int i;
+ int startOfBranch = 0;
- if( zType==0 || zType[0]==0 ) zType = "*";
+ if( zType==0 || zType[0]==0 ){
+ zType = "*";
+ }else if( zType[0]=='b' ){
+ zType = "ci";
+ startOfBranch = 1;
+ }
if( zTag==0 || zTag[0]==0 ) return 0;
/* special keyword: "tip" */
if( fossil_strcmp(zTag, "tip")==0 && (zType[0]=='*' || zType[0]=='c') ){
rid = db_int(0,
@@ -151,41 +193,18 @@
" AND tagxref.tagid=tag.tagid AND tagxref.tagtype>0 "
" AND event.objid=tagxref.rid "
" AND event.type GLOB '%q'",
&zTag[4], zType
);
+ if( startOfBranch ) rid = start_of_branch(rid,1);
return rid;
}
/* root:TAG -> The origin of the branch */
if( memcmp(zTag, "root:", 5)==0 ){
- Stmt q;
- int rc;
- char *zBr;
rid = symbolic_name_to_rid(zTag+5, zType);
- zBr = db_text("trunk","SELECT value FROM tagxref"
- " WHERE rid=%d AND tagid=%d"
- " AND tagtype>0",
- rid, TAG_BRANCH);
- db_prepare(&q,
- "SELECT pid, EXISTS(SELECT 1 FROM tagxref"
- " WHERE tagid=%d AND tagtype>0"
- " AND value=%Q AND rid=plink.pid)"
- " FROM plink"
- " WHERE cid=:cid AND isprim",
- TAG_BRANCH, zBr
- );
- fossil_free(zBr);
- do{
- db_reset(&q);
- db_bind_int(&q, ":cid", rid);
- rc = db_step(&q);
- if( rc!=SQLITE_ROW ) break;
- rid = db_column_int(&q, 0);
- }while( db_column_int(&q, 1)==1 && rid>0 );
- db_finalize(&q);
- return rid;
+ return start_of_branch(rid, 0);
}
/* symbolic-name ":" date-time */
nTag = strlen(zTag);
for(i=0; i0 "
" AND event.objid=tagxref.rid "
" AND event.type GLOB '%q'",
zTag, zType
);
- if( rid>0 ) return rid;
+ if( rid>0 ){
+ if( startOfBranch ) rid = start_of_branch(rid,1);
+ return rid;
+ }
/* Undocumented: numeric tags get translated directly into the RID */
if( memcmp(zTag, "rid:", 4)==0 ){
zTag += 4;
for(i=0; fossil_isdigit(zTag[i]); i++){}
@@ -391,18 +413,15 @@
int rid;
if( zName==0 || zName[0]==0 ) return 0;
rid = symbolic_name_to_rid(zName, zType);
if( rid<0 ){
- fossil_error(1, "ambiguous name: %s", zName);
- return 0;
+ fossil_fatal("ambiguous name: %s", zName);
}else if( rid==0 ){
- fossil_error(1, "not found: %s", zName);
- return 0;
- }else{
- return rid;
+ fossil_fatal("not found: %s", zName);
}
+ return rid;
}
int name_to_rid(const char *zName){
return name_to_typed_rid(zName, "*");
}
@@ -505,11 +524,11 @@
}
/*
** Generate a description of artifact "rid"
*/
-static void whatis_rid(int rid, int verboseFlag){
+void whatis_rid(int rid, int verboseFlag){
Stmt q;
int cnt;
/* Basic information about the object. */
db_prepare(&q,
@@ -657,21 +676,23 @@
void whatis_cmd(void){
int rid;
const char *zName;
int verboseFlag;
int i;
+ const char *zType = 0;
db_find_and_open_repository(0,0);
verboseFlag = find_option("verbose","v",0)!=0;
+ zType = find_option("type",0,1);
/* We should be done with options.. */
verify_all_options();
if( g.argc<3 ) usage("whatis NAME ...");
for(i=2; i2 ) fossil_print("%.79c\n",'-');
- rid = symbolic_name_to_rid(zName, 0);
+ rid = symbolic_name_to_rid(zName, zType);
if( rid<0 ){
Stmt q;
int cnt = 0;
fossil_print("name: %s (ambiguous)\n", zName);
db_prepare(&q,
@@ -757,5 +778,214 @@
while( db_step(&q)==SQLITE_ROW ){
fossil_print("%s\n", db_column_text(&q, 0));
}
db_finalize(&q);
}
+
+/*
+** Schema for the description table
+*/
+static const char zDescTab[] =
+@ CREATE TEMP TABLE IF NOT EXISTS description(
+@ rid INTEGER PRIMARY KEY, -- RID of the object
+@ uuid TEXT, -- SHA1 hash of the object
+@ ctime DATETIME, -- Time of creation
+@ isPrivate BOOLEAN DEFAULT 0, -- True for unpublished artifacts
+@ type TEXT, -- file, checkin, wiki, ticket, etc.
+@ summary TEXT, -- Summary comment for the object
+@ detail TEXT -- filename, checkin comment, etc
+@ );
+;
+
+/*
+** Create the description table if it does not already exists.
+** Populate fields of this table with descriptions for all artifacts
+** whose RID matches the SQL expression in zWhere.
+*/
+void describe_artifacts(const char *zWhere){
+ db_multi_exec("%s", zDescTab/*safe-for-%s*/);
+
+ /* Describe checkins */
+ db_multi_exec(
+ "INSERT OR IGNORE INTO description(rid,uuid,ctime,type,summary)\n"
+ "SELECT blob.rid, blob.uuid, event.mtime, 'checkin',\n"
+ " 'checkin on ' || strftime('%%Y-%%m-%%d %%H:%%M',event.mtime)\n"
+ " FROM event, blob\n"
+ " WHERE event.objid %s AND event.type='ci'\n"
+ " AND event.objid=blob.rid;",
+ zWhere /*safe-for-%s*/
+ );
+
+ /* Describe files */
+ db_multi_exec(
+ "INSERT OR IGNORE INTO description(rid,uuid,ctime,type,summary)\n"
+ "SELECT blob.rid, blob.uuid, event.mtime, 'file', 'file '||filename.name\n"
+ " FROM mlink, blob, event, filename\n"
+ " WHERE mlink.fid %s\n"
+ " AND mlink.mid=event.objid\n"
+ " AND filename.fnid=mlink.fnid\n"
+ " AND mlink.fid=blob.rid;",
+ zWhere /*safe-for-%s*/
+ );
+
+ /* Describe tags */
+ db_multi_exec(
+ "INSERT OR IGNORE INTO description(rid,uuid,ctime,type,summary)\n"
+ "SELECT blob.rid, blob.uuid, tagxref.mtime, 'tag',\n"
+ " 'tag '||substr((SELECT uuid FROM blob WHERE rid=tagxref.rid),1,16)\n"
+ " FROM tagxref, blob\n"
+ " WHERE tagxref.srcid %s AND tagxref.srcid!=tagxref.rid\n"
+ " AND tagxref.srcid=blob.rid;",
+ zWhere /*safe-for-%s*/
+ );
+
+ /* Cluster artifacts */
+ db_multi_exec(
+ "INSERT OR IGNORE INTO description(rid,uuid,ctime,type,summary)\n"
+ "SELECT blob.rid, blob.uuid, tagxref.mtime, 'cluster', 'cluster'\n"
+ " FROM tagxref, blob\n"
+ " WHERE tagxref.rid %s\n"
+ " AND tagxref.tagid=(SELECT tagid FROM tag WHERE tagname='cluster')\n"
+ " AND blob.rid=tagxref.rid;",
+ zWhere /*safe-for-%s*/
+ );
+
+ /* Ticket change artifacts */
+ db_multi_exec(
+ "INSERT OR IGNORE INTO description(rid,uuid,ctime,type,summary)\n"
+ "SELECT blob.rid, blob.uuid, tagxref.mtime, 'ticket',\n"
+ " 'ticket '||substr(tag.tagname,5,21)\n"
+ " FROM tagxref, tag, blob\n"
+ " WHERE tagxref.rid %s\n"
+ " AND tag.tagid=tagxref.tagid\n"
+ " AND tag.tagname GLOB 'tkt-*'"
+ " AND blob.rid=tagxref.rid;",
+ zWhere /*safe-for-%s*/
+ );
+
+ /* Wiki edit artifacts */
+ db_multi_exec(
+ "INSERT OR IGNORE INTO description(rid,uuid,ctime,type,summary)\n"
+ "SELECT blob.rid, blob.uuid, tagxref.mtime, 'wiki',\n"
+ " printf('wiki \"%%s\"',substr(tag.tagname,6))\n"
+ " FROM tagxref, tag, blob\n"
+ " WHERE tagxref.rid %s\n"
+ " AND tag.tagid=tagxref.tagid\n"
+ " AND tag.tagname GLOB 'wiki-*'"
+ " AND blob.rid=tagxref.rid;",
+ zWhere /*safe-for-%s*/
+ );
+
+ /* Event edit artifacts */
+ db_multi_exec(
+ "INSERT OR IGNORE INTO description(rid,uuid,ctime,type,summary)\n"
+ "SELECT blob.rid, blob.uuid, tagxref.mtime, 'event',\n"
+ " 'event '||substr(tag.tagname,7)\n"
+ " FROM tagxref, tag, blob\n"
+ " WHERE tagxref.rid %s\n"
+ " AND tag.tagid=tagxref.tagid\n"
+ " AND tag.tagname GLOB 'event-*'"
+ " AND blob.rid=tagxref.rid;",
+ zWhere /*safe-for-%s*/
+ );
+
+ /* Attachments */
+ db_multi_exec(
+ "INSERT OR IGNORE INTO description(rid,uuid,ctime,type,detail)\n"
+ "SELECT blob.rid, blob.uuid, attachment.mtime, 'attachment',\n"
+ " 'attachment '||attachment.filename\n"
+ " FROM attachment, blob\n"
+ " WHERE attachment.src %s\n"
+ " AND blob.rid=attachment.src;",
+ zWhere /*safe-for-%s*/
+ );
+
+ /* Everything else */
+ db_multi_exec(
+ "INSERT OR IGNORE INTO description(rid,uuid,type,summary)\n"
+ "SELECT blob.rid, blob.uuid,"
+ " CASE WHEN blob.size<0 THEN 'phantom' ELSE '' END,\n"
+ " 'unknown'\n"
+ " FROM blob WHERE blob.rid %s;",
+ zWhere /*safe-for-%s*/
+ );
+
+ /* Mark private elements */
+ db_multi_exec(
+ "UPDATE description SET isPrivate=1 WHERE rid IN private"
+ );
+}
+
+/*
+** Print the content of the description table on stdout
+*/
+int describe_artifacts_to_stdout(const char *zWhere, const char *zLabel){
+ Stmt q;
+ int cnt = 0;
+ describe_artifacts(zWhere);
+ db_prepare(&q,
+ "SELECT uuid, summary, isPrivate\n"
+ " FROM description\n"
+ " ORDER BY ctime, type;"
+ );
+ while( db_step(&q)==SQLITE_ROW ){
+ if( zLabel ){
+ fossil_print("%s\n", zLabel);
+ zLabel = 0;
+ }
+ fossil_print(" %.16s %s", db_column_text(&q,0), db_column_text(&q,1));
+ if( db_column_int(&q,2) ) fossil_print(" (unpublished)");
+ fossil_print("\n");
+ cnt++;
+ }
+ db_finalize(&q);
+ db_multi_exec("DELETE FROM description;");
+ return cnt;
+}
+
+/*
+** COMMAND: test-describe-artifacts
+**
+** Usage: %fossil test-describe-artifacts
+**
+** Display a one-line description of every artifact.
+*/
+void test_describe_artifacts_cmd(void){
+ db_find_and_open_repository(0,0);
+ describe_artifacts_to_stdout("IN (SELECT rid FROM blob)", 0);
+}
+
+/*
+** COMMAND: test-unsent
+**
+** Usage: %fossil test-unsent
+**
+** Show all artifacts in the unsent table
+*/
+void test_unsent_cmd(void){
+ db_find_and_open_repository(0,0);
+ describe_artifacts_to_stdout("IN unsent", 0);
+}
+
+/*
+** COMMAND: test-unclustered
+**
+** Usage: %fossil test-unclustered
+**
+** Show all artifacts in the unclustered table
+*/
+void test_unclusterd_cmd(void){
+ db_find_and_open_repository(0,0);
+ describe_artifacts_to_stdout("IN unclustered", 0);
+}
+
+/*
+** COMMAND: test-phantoms
+**
+** Usage: %fossil test-phantoms
+**
+** Show all phantom artifacts
+*/
+void test_phatoms_cmd(void){
+ db_find_and_open_repository(0,0);
+ describe_artifacts_to_stdout("IN (SELECT rid FROM blob WHERE size<0)", 0);
+}
ADDED src/publish.c
Index: src/publish.c
==================================================================
--- /dev/null
+++ src/publish.c
@@ -0,0 +1,118 @@
+/*
+** Copyright (c) 2014 D. Richard Hipp
+**
+** This program is free software; you can redistribute it and/or
+** modify it under the terms of the Simplified BSD License (also
+** known as the "2-Clause License" or "FreeBSD License".)
+
+** This program is distributed in the hope that it will be useful,
+** but without any warranty; without even the implied warranty of
+** merchantability or fitness for a particular purpose.
+**
+** Author contact information:
+** drh@hwaci.com
+** http://www.hwaci.com/drh/
+**
+*******************************************************************************
+**
+** This file contains code used to implement the "publish" and
+** "unpublished" commands.
+*/
+#include "config.h"
+#include "publish.h"
+#include
+
+/*
+** COMMAND: unpublished
+**
+** Usage: %fossil unpublished ?OPTIONS?
+**
+** Show a list of unpublished or "private" artifacts. Unpublished artifacts
+** will never push and hence will not be shared with collaborators.
+**
+** By default, this command only shows unpublished checkins. To show
+** all unpublished artifacts, use the --all command-line option.
+**
+** OPTIONS:
+** --all Show all artifacts, not just checkins
+*/
+void unpublished_cmd(void){
+ int bAll = find_option("all",0,0)!=0;
+
+ db_find_and_open_repository(0,0);
+ verify_all_options();
+ if( bAll ){
+ describe_artifacts_to_stdout("IN private", 0);
+ }else{
+ describe_artifacts_to_stdout(
+ "IN (SELECT rid FROM private CROSS JOIN event"
+ " WHERE private.rid=event.objid"
+ " AND event.type='ci')", 0);
+ }
+}
+
+/*
+** COMMAND: publish
+**
+** Usage: %fossil publish ?--only? TAGS...
+**
+** Cause artifacts identified by TAGS... to be published (made non-private).
+** This can be used (for example) to convert a private branch into a public
+** branch, or to publish a bundle that was imported privately.
+**
+** If any of TAGS names a branch, then all checkins on that most recent
+** instance of that branch are included, not just the most recent checkin.
+**
+** If any of TAGS name checkins then all files and tags associated with
+** those checkins are also published automatically. Except if the --only
+** option is used, then only the specific artifacts identified by TAGS
+** are published.
+**
+** If a TAG is already public, this command is a harmless no-op.
+*/
+void publish_cmd(void){
+ int bOnly = find_option("only",0,0)!=0;
+ int bTest = find_option("test",0,0)!=0; /* Undocumented --test option */
+ int bExclusive = find_option("exclusive",0,0)!=0; /* undocumented */
+ int i;
+
+ db_find_and_open_repository(0,0);
+ verify_all_options();
+ if( g.argc<3 ) usage("?--only? TAGS...");
+ db_begin_transaction();
+ db_multi_exec("CREATE TEMP TABLE ok(rid INTEGER PRIMARY KEY);");
+ for(i=2; i0 AND value=%Q",
+ rid,TAG_BRANCH,g.argv[i]) ){
+ rid = start_of_branch(rid, 1);
+ compute_descendants(rid, 1000000000);
+ }else{
+ db_multi_exec("INSERT OR IGNORE INTO ok VALUES(%d)", rid);
+ }
+ }
+ if( !bOnly ){
+ find_checkin_associates("ok", bExclusive);
+ }
+ if( bTest ){
+ /* If the --test option is used, then do not actually publish any
+ ** artifacts. Instead, just list the artifact information on standard
+ ** output. The --test option is useful for verifying correct operation
+ ** of the logic that figures out which artifacts to publish, such as
+ ** the find_checkin_associates() routine
+ */
+ describe_artifacts_to_stdout("IN ok", 0);
+ }else{
+ /* Standard behavior is simply to remove the published documents from
+ ** the PRIVATE table */
+ db_multi_exec(
+ "DELETE FROM ok WHERE rid NOT IN private;"
+ "DELETE FROM private WHERE rid IN ok;"
+ "INSERT OR IGNORE INTO unsent SELECT rid FROM ok;"
+ "INSERT OR IGNORE INTO unclustered SELECT rid FROM ok;"
+ );
+ }
+ db_end_transaction(0);
+}
ADDED src/purge.c
Index: src/purge.c
==================================================================
--- /dev/null
+++ src/purge.c
@@ -0,0 +1,583 @@
+/*
+** Copyright (c) 2014 D. Richard Hipp
+**
+** This program is free software; you can redistribute it and/or
+** modify it under the terms of the Simplified BSD License (also
+** known as the "2-Clause License" or "FreeBSD License".)
+
+** This program is distributed in the hope that it will be useful,
+** but without any warranty; without even the implied warranty of
+** merchantability or fitness for a particular purpose.
+**
+** Author contact information:
+** drh@hwaci.com
+** http://www.hwaci.com/drh/
+**
+*******************************************************************************
+**
+** This file contains code used to implement the "purge" command and
+** related functionality for removing checkins from a repository. It also
+** manages the graveyard of purged content.
+*/
+#include "config.h"
+#include "purge.h"
+#include
+
+/*
+** SQL code used to initialize the schema of a bundle.
+**
+** The purgeevent table contains one entry for each purge event. For each
+** purge event, multiple artifacts might have been removed. Each removed
+** artifact is stored as an entry in the purgeitem table.
+**
+** The purgeevent and purgeitem tables are not synced, even by the
+** "fossil config" command. They exist only as a backup in case of a
+** mistaken purge or for content recovery in case there is a bug in the
+** purge command.
+*/
+static const char zPurgeInit[] =
+@ CREATE TABLE IF NOT EXISTS "%w".purgeevent(
+@ peid INTEGER PRIMARY KEY, -- Unique ID for the purge event
+@ ctime DATETIME, -- When purge occurred. Seconds since 1970.
+@ pnotes TEXT -- Human-readable notes about the purge event
+@ );
+@ CREATE TABLE IF NOT EXISTS "%w".purgeitem(
+@ piid INTEGER PRIMARY KEY, -- ID for the purge item
+@ peid INTEGER REFERENCES purgeevent ON DELETE CASCADE, -- Purge event
+@ orid INTEGER, -- Original RID before purged
+@ uuid TEXT NOT NULL, -- SHA1 hash of the purged artifact
+@ srcid INTEGER, -- Basis purgeitem for delta compression
+@ 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
+@ );
+;
+
+/*
+** 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.
+**
+** This routine does the following:
+**
+** (1) Create the purgeevent and purgeitem tables, if required
+** (2) Create a new purgeevent
+** (3) Make sure no DELTA table entries depend on purged artifacts
+** (4) Create new purgeitem entries for each purged artifact
+** (5) Remove purged artifacts from the BLOB table
+** (6) Remove references to purged artifacts in the following tables:
+** (a) EVENT
+** (b) PRIVATE
+** (c) MLINK
+** (d) PLINK
+** (e) LEAF
+** (f) UNCLUSTERED
+** (g) UNSENT
+** (h) BACKLINK
+** (i) ATTACHMENT
+** (j) TICKETCHNG
+** (7) If any ticket artifacts were removed (6j) then rebuild the
+** corresponding ticket entries. Possibly remove entries from
+** the ticket table.
+**
+** Stops 1-4 (saving the purged artifacts into the graveyard) are only
+** undertaken if the moveToGraveyard flag is true.
+*/
+int purge_artifact_list(
+ const char *zTab, /* TEMP table containing list of RIDS to be purged */
+ const char *zNote, /* Text of the purgeevent.pnotes field */
+ int moveToGraveyard /* Move purged artifacts into the graveyard */
+){
+ int peid = 0; /* New purgeevent ID */
+ Stmt q; /* General-use prepared statement */
+ char *z;
+
+ assert( g.repositoryOpen ); /* Main database must already be open */
+ db_begin_transaction();
+ z = sqlite3_mprintf("IN \"%w\"", zTab);
+ describe_artifacts(z);
+ sqlite3_free(z);
+
+ /* Make sure we are not removing a manifest that is the baseline of some
+ ** manifest that is being left behind. This step is not strictly necessary.
+ ** is is just a safety check. */
+ if( purge_baseline_out_from_under_delta(zTab) ){
+ fossil_fatal("attempt to purge a baseline manifest without also purging "
+ "all of its deltas");
+ }
+
+ /* Make sure that no delta that is left behind requires a purged artifact
+ ** as its basis. If such artifacts exist, go ahead and undelta them now.
+ */
+ db_prepare(&q, "SELECT rid FROM delta WHERE srcid IN \"%w\""
+ " AND rid NOT IN \"%w\"", zTab, zTab);
+ while( db_step(&q)==SQLITE_ROW ){
+ int rid = db_column_int(&q, 0);
+ 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 ){
+ 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\""
+ " AND srcid NOT IN \"%w\"", zTab, zTab);
+ while( db_step(&q)==SQLITE_ROW ){
+ int rid = db_column_int(&q, 0);
+ content_undelta(rid);
+ }
+ db_finalize(&q);
+ db_multi_exec(
+ "INSERT INTO purgeitem(peid,orid,uuid,sz,isPrivate,desc,data)"
+ " SELECT %d, rid, uuid, size,"
+ " EXISTS(SELECT 1 FROM private WHERE private.rid=blob.rid),"
+ " (SELECT summary FROM description WHERE rid=blob.rid),"
+ " content"
+ " FROM blob WHERE rid IN \"%w\"",
+ peid, zTab
+ );
+ db_multi_exec(
+ "UPDATE purgeitem"
+ " SET srcid=(SELECT piid FROM purgeitem px, delta"
+ " WHERE px.orid=delta.srcid"
+ " AND delta.rid=purgeitem.orid)"
+ " WHERE peid=%d",
+ peid
+ );
+ }
+
+ /* Remove the artifacts being purged. Also remove all references to those
+ ** artifacts from the secondary tables. */
+ db_multi_exec("DELETE FROM blob WHERE rid IN \"%w\"", zTab);
+ db_multi_exec("DELETE FROM delta WHERE rid IN \"%w\"", zTab);
+ db_multi_exec("DELETE FROM delta WHERE srcid IN \"%w\"", zTab);
+ db_multi_exec("DELETE FROM event WHERE objid IN \"%w\"", zTab);
+ db_multi_exec("DELETE FROM private WHERE rid IN \"%w\"", zTab);
+ db_multi_exec("DELETE FROM mlink WHERE mid IN \"%w\"", zTab);
+ db_multi_exec("DELETE FROM plink WHERE pid IN \"%w\"", zTab);
+ db_multi_exec("DELETE FROM plink WHERE cid IN \"%w\"", zTab);
+ db_multi_exec("DELETE FROM leaf WHERE rid IN \"%w\"", zTab);
+ db_multi_exec("DELETE FROM phantom WHERE rid IN \"%w\"", zTab);
+ db_multi_exec("DELETE FROM unclustered WHERE rid IN \"%w\"", zTab);
+ db_multi_exec("DELETE FROM unsent WHERE rid IN \"%w\"", zTab);
+ db_multi_exec("DELETE FROM tagxref"
+ " WHERE rid IN \"%w\""
+ " OR srcid IN \"%w\""
+ " OR origid IN \"%w\"", zTab, zTab, zTab);
+ db_multi_exec("DELETE FROM backlink WHERE srctype=0 AND srcid IN \"%w\"",
+ zTab);
+ db_multi_exec(
+ "CREATE TEMP TABLE \"%w_tickets\" AS"
+ " SELECT DISTINCT tkt_uuid FROM ticket WHERE tkt_id IN"
+ " (SELECT tkt_id FROM ticketchng WHERE tkt_rid IN \"%w\")",
+ zTab, zTab);
+ db_multi_exec("DELETE FROM ticketchng WHERE tkt_rid IN \"%w\"", zTab);
+ db_prepare(&q, "SELECT tkt_uuid FROM \"%w_tickets\"", zTab);
+ while( db_step(&q)==SQLITE_ROW ){
+ ticket_rebuild_entry(db_column_text(&q, 0));
+ }
+ db_finalize(&q);
+ /* db_multi_exec("DROP TABLE \"%w_tickets\"", zTab); */
+
+ /* Mission accomplished */
+ db_end_transaction(0);
+ return peid;
+}
+
+/*
+** The TEMP table named zTab contains RIDs for a set of checkins.
+**
+** Check to see if any checkin in zTab is a baseline manifest for some
+** delta manifest that is not in zTab. Return true if zTab contains a
+** baseline for a delta that is not in zTab.
+**
+** This is a database integrity preservation check. The checkins in zTab
+** are about to be deleted or otherwise made inaccessible. This routine
+** is checking to ensure that purging the checkins in zTab will not delete
+** a baseline manifest out from under a delta.
+*/
+int purge_baseline_out_from_under_delta(const char *zTab){
+ if( !db_exists("SELECT 1 FROM %s.sqlite_master WHERE name='plink'"
+ " AND sql GLOB '* baseid *'", db_name("repository")) ){
+ /* Skip this check if the current database is an older schema that
+ ** does not contain the PLINK.BASEID field. */
+ return 0;
+ }else{
+ return db_int(0,
+ "SELECT 1 FROM plink WHERE baseid IN \"%w\" AND cid NOT IN \"%w\"",
+ zTab, zTab);
+ }
+}
+
+
+/*
+** The TEMP table named zTab contains the RIDs for a set of checkin
+** artifacts. Expand this set (by adding new entries to zTab) to include
+** all other artifacts that are used the set of checkins in
+** the original list.
+**
+** If the bExclusive flag is true, then the set is only expanded by
+** artifacts that are used exclusively by the checkins in the set.
+** When bExclusive is false, then all artifacts used by the checkins
+** are added even if those artifacts are also used by other checkins
+** not in the set.
+**
+** The "fossil publish" command with the (undocumented) --test and
+** --exclusive options can be used for interactiving testing of this
+** function.
+*/
+void find_checkin_associates(const char *zTab, int bExclusive){
+ db_begin_transaction();
+
+ /* Compute the set of files that need to be added to zTab */
+ db_multi_exec("CREATE TEMP TABLE \"%w_files\"(fid INTEGER PRIMARY KEY)",zTab);
+ db_multi_exec(
+ "INSERT OR IGNORE INTO \"%w_files\"(fid)"
+ " SELECT fid FROM mlink WHERE fid!=0 AND mid IN \"%w\"",
+ zTab, zTab
+ );
+ if( bExclusive ){
+ /* But take out all files that are referenced by check-ins not in zTab */
+ db_multi_exec(
+ "DELETE FROM \"%w_files\""
+ " WHERE fid IN (SELECT fid FROM mlink"
+ " WHERE fid IN \"%w_files\""
+ " AND mid NOT IN \"%w\")",
+ zTab, zTab, zTab
+ );
+ }
+
+ /* Compute the set of tags that need to be added to zTag */
+ db_multi_exec("CREATE TEMP TABLE \"%w_tags\"(tid INTEGER PRIMARY KEY)",zTab);
+ db_multi_exec(
+ "INSERT OR IGNORE INTO \"%w_tags\"(tid)"
+ " SELECT DISTINCT srcid FROM tagxref WHERE rid in \"%w\" AND srcid!=0",
+ zTab, zTab
+ );
+ if( bExclusive ){
+ /* But take out tags that references some check-ins in zTab and other
+ ** check-ins not in zTab. The current Fossil implementation never creates
+ ** such tags, so the following should usually be a no-op. But the file
+ ** format specification allows such tags, so we should check for them.
+ */
+ db_multi_exec(
+ "DELETE FROM \"%w_tags\""
+ " WHERE tid IN (SELECT srcid FROM tagxref"
+ " WHERE srcid IN \"%w_tags\""
+ " AND rid NOT IN \"%w\")",
+ zTab, zTab, zTab
+ );
+ }
+
+ /* Transfer the extra artifacts into zTab */
+ db_multi_exec(
+ "INSERT OR IGNORE INTO \"%w\" SELECT fid FROM \"%w_files\";"
+ "INSERT OR IGNORE INTO \"%w\" SELECT tid FROM \"%w_tags\";"
+ "DROP TABLE \"%w_files\";"
+ "DROP TABLE \"%w_tags\";",
+ zTab, zTab, zTab, zTab, zTab, zTab
+ );
+
+ db_end_transaction(0);
+}
+
+/*
+** Display the content of a single purge event.
+*/
+static void purge_list_event_content(int peid){
+ Stmt q;
+ sqlite3_int64 sz = 0;
+ db_prepare(&q, "SELECT piid, substr(uuid,1,16), srcid, isPrivate,"
+ " length(data), desc"
+ " FROM purgeitem WHERE peid=%d", peid);
+ while( db_step(&q)==SQLITE_ROW ){
+ fossil_print(" %5d %s %4s %c %10d %s\n",
+ db_column_int(&q,0),
+ db_column_text(&q,1),
+ db_column_text(&q,2),
+ db_column_int(&q,3) ? 'P' : ' ',
+ db_column_int(&q,4),
+ db_column_text(&q,5));
+ sz += db_column_int(&q,4);
+ }
+ db_finalize(&q);
+ fossil_print("%.11c%16s%.8c%10lld\n", ' ', "Total:", ' ', sz);
+}
+
+/*
+** Extract the content for purgeitem number piid into a Blob. Return
+** the number of errors.
+*/
+static int purge_extract_item(
+ int piid, /* ID of the item to extract */
+ Blob *pOut /* Write the content into this blob */
+){
+ Stmt q;
+ int srcid;
+ Blob h1, h2, x;
+ static Bag busy;
+
+ db_prepare(&q, "SELECT uuid, srcid, data FROM purgeitem"
+ " WHERE piid=%d", piid);
+ if( db_step(&q)!=SQLITE_ROW ){
+ db_finalize(&q);
+ fossil_fatal("missing purge-item %d", piid);
+ }
+ if( bag_find(&busy, piid) ) return 1;
+ srcid = db_column_int(&q, 1);
+ blob_zero(pOut);
+ blob_zero(&x);
+ db_column_blob(&q, 2, &x);
+ blob_uncompress(&x, pOut);
+ blob_reset(&x);
+ if( srcid>0 ){
+ Blob baseline, out;
+ bag_insert(&busy, piid);
+ purge_extract_item(srcid, &baseline);
+ blob_zero(&out);
+ blob_delta_apply(&baseline, pOut, &out);
+ blob_reset(pOut);
+ *pOut = out;
+ blob_reset(&baseline);
+ }
+ bag_remove(&busy, piid);
+ blob_zero(&h1);
+ db_column_blob(&q, 0, &h1);
+ sha1sum_blob(pOut, &h2);
+ if( blob_compare(&h1, &h2)!=0 ){
+ fossil_fatal("SHA1 hash mismatch - wanted %s, got %s",
+ blob_str(&h1), blob_str(&h2));
+ }
+ blob_reset(&h1);
+ blob_reset(&h2);
+ db_finalize(&q);
+ return 0;
+}
+
+/*
+** There is a TEMP table ix(piid,srcid) containing a set of purgeitems
+** that need to be transferred to the BLOB table. This routine does
+** all items that have srcid=iSrc. The pBasis blob holds the content
+** of the source document if iSrc>0.
+*/
+static void purge_item_resurrect(int iSrc, Blob *pBasis){
+ Stmt q;
+ static Bag busy;
+ assert( pBasis!=0 || iSrc==0 );
+ if( iSrc>0 ){
+ if( bag_find(&busy, iSrc) ){
+ fossil_fatal("delta loop while uncompressing purged artifacts");
+ }
+ bag_insert(&busy, iSrc);
+ }
+ db_prepare(&q,
+ "SELECT uuid, data, isPrivate, ix.piid"
+ " FROM ix, purgeitem"
+ " WHERE ix.srcid=%d"
+ " AND ix.piid=purgeitem.piid;",
+ iSrc
+ );
+ while( db_step(&q)==SQLITE_ROW ){
+ Blob h1, h2, c1, c2;
+ int isPriv, rid;
+ blob_zero(&h1);
+ db_column_blob(&q, 0, &h1);
+ blob_zero(&c1);
+ db_column_blob(&q, 1, &c1);
+ blob_uncompress(&c1, &c1);
+ blob_zero(&c2);
+ if( pBasis ){
+ blob_delta_apply(pBasis, &c1, &c2);
+ blob_reset(&c1);
+ }else{
+ c2 = c1;
+ }
+ sha1sum_blob(&c2, &h2);
+ if( blob_compare(&h1, &h2)!=0 ){
+ fossil_fatal("SHA1 hash mismatch - wanted %s, got %s",
+ blob_str(&h1), blob_str(&h2));
+ }
+ blob_reset(&h2);
+ isPriv = db_column_int(&q, 2);
+ rid = content_put_ex(&c2, blob_str(&h1), 0, 0, isPriv);
+ if( rid==0 ){
+ fossil_fatal("%s", g.zErrMsg);
+ }else{
+ if( !isPriv ) content_make_public(rid);
+ content_get(rid, &c1);
+ manifest_crosslink(rid, &c1, MC_NO_ERRORS);
+ }
+ purge_item_resurrect(db_column_int(&q,3), &c2);
+ blob_reset(&c2);
+ }
+ db_finalize(&q);
+ if( iSrc>0 ) bag_remove(&busy, iSrc);
+}
+
+/*
+** 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 cat UUID...
+**
+** Write the content of one or more artifacts in the graveyard onto
+** standard output.
+**
+** fossil purge ?checkins? TAGS... ?OPTIONS?
+**
+** Move the checkins identified by TAGS and all of their descendants
+** out of the repository and into the graveyard. The "checkins"
+** subcommand keyword is option and can be omitted as long as TAGS
+** does not conflict with any other subcommand.
+**
+** If a TAGS includes a branch name then it means all the checkins
+** on the most recent occurrance of that branch.
+**
+** --explain Make no changes, but show what would happen.
+** --dry-run Make no chances.
+**
+** 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 undo ID
+**
+** Restore the content previously removed by purge ID.
+**
+** SUMMARY:
+** fossil purge cat UUID...
+** fossil purge [checkins] TAGS... [--explain]
+** fossil purge list
+** fossil purge obliterate ID...
+** fossil purge undo ID
+*/
+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, "cat", n)==0 ){
+ int i, piid;
+ Blob content;
+ if( g.argc<4 ) usage("cat UUID...");
+ for(i=3; i=g.argc ) usage("[checkin] TAGS... [--explain]");
+ db_multi_exec("CREATE TEMP TABLE ok(rid INTEGER PRIMARY KEY)");
+ for(; i0 )
@ );
@ CREATE TABLE delta(
-@ rid INTEGER PRIMARY KEY, -- Record ID
-@ srcid INTEGER NOT NULL REFERENCES blob -- Record holding source document
+@ rid INTEGER PRIMARY KEY, -- BLOB that is delta-compressed
+@ srcid INTEGER NOT NULL REFERENCES blob -- Baseline for delta-compression
@ );
@ CREATE INDEX delta_i1 ON delta(srcid);
@
@ -------------------------------------------------------------------------
@ -- The BLOB and DELTA tables above hold the "global state" of a Fossil
Index: src/setup.c
==================================================================
--- src/setup.c
+++ src/setup.c
@@ -105,15 +105,15 @@
"Edit HTML text for an ad unit inserted after the menu bar");
setup_menu_entry("Logo", "setup_logo",
"Change the logo and background images for the server");
setup_menu_entry("Shunned", "shun",
"Show artifacts that are shunned by this repository");
- setup_menu_entry("Log", "rcvfromlist",
+ setup_menu_entry("Artifact Receipts Log", "rcvfromlist",
"A record of received artifacts and their sources");
- setup_menu_entry("User-Log", "access_log",
+ setup_menu_entry("User Log", "access_log",
"A record of login attempts");
- setup_menu_entry("Admin-Log", "admin_log",
+ setup_menu_entry("Administrative Log", "admin_log",
"View the admin_log entries");
setup_menu_entry("Stats", "stat",
"Display repository statistics");
setup_menu_entry("SQL", "admin_sql",
"Enter raw SQL commands");
Index: src/shun.c
==================================================================
--- src/shun.c
+++ src/shun.c
@@ -295,37 +295,50 @@
**
** Show a listing of RCVFROM table entries.
*/
void rcvfromlist_page(void){
int ofst = atoi(PD("ofst","0"));
+ int showAll = P("all")!=0;
int cnt;
Stmt q;
login_check_credentials();
if( !g.perm.Admin ){
login_needed();
}
- style_header("Content Sources");
+ style_header("Artifact Receipts");
+ if( showAll ){
+ ofst = 0;
+ }else{
+ style_submenu_element("All", "All", "rcvfromlist?all=1");
+ }
if( ofst>0 ){
style_submenu_element("Newer", "Newer", "rcvfromlist?ofst=%d",
ofst>30 ? ofst-30 : 0);
}
+ db_multi_exec(
+ "CREATE TEMP TABLE rcvidUsed(x INTEGER PRIMARY KEY);"
+ "INSERT OR IGNORE INTO rcvidUsed(x) SELECT rcvid FROM blob;"
+ );
db_prepare(&q,
- "SELECT rcvid, login, datetime(rcvfrom.mtime), rcvfrom.ipaddr"
+ "SELECT rcvid, login, datetime(rcvfrom.mtime), rcvfrom.ipaddr,"
+ " EXISTS(SELECT 1 FROM rcvidUsed WHERE x=rcvfrom.rcvid)"
" FROM rcvfrom LEFT JOIN user USING(uid)"
- " ORDER BY rcvid DESC LIMIT 31 OFFSET %d",
- ofst
+ " ORDER BY rcvid DESC LIMIT %d OFFSET %d",
+ showAll ? -1 : 31, ofst
);
@
Whenever new artifacts are added to the repository, either by
@ push or using the web interface, an entry is made in the RCVFROM table
@ to record the source of that artifact. This log facilitates
@ finding and fixing attempts to inject illicit content into the
@ repository.
@
@ Click on the "rcvid" to show a list of specific artifacts received
@ by a transaction. After identifying illicit artifacts, remove them
- @ using the "Shun" feature.
+ @ using the "Shun" button. If an "rcvid" is not hyperlinked, that means
+ @ all artifacts associated with that rcvid have already been shunned
+ @ or purged.
@
@
@ | rcvid |
@ Date |
@ User |
@@ -334,17 +347,22 @@
while( db_step(&q)==SQLITE_ROW ){
int rcvid = db_column_int(&q, 0);
const char *zUser = db_column_text(&q, 1);
const char *zDate = db_column_text(&q, 2);
const char *zIpAddr = db_column_text(&q, 3);
- if( cnt==30 ){
+ if( cnt==30 && !showAll ){
style_submenu_element("Older", "Older",
"rcvfromlist?ofst=%d", ofst+30);
}else{
cnt++;
@
|---|
- @ | %d(rcvid) |
+ if( db_column_int(&q,4) ){
+ @
+ @ %d(rcvid) |
+ }else{
+ @ %d(rcvid) |
+ }
@ %s(zDate) |
@ %h(zUser) |
@ %s(zIpAddr) |
@
}
@@ -365,22 +383,24 @@
login_check_credentials();
if( !g.perm.Admin ){
login_needed();
}
- style_header("Content Source %d", rcvid);
+ style_header("Artifact Receipt %d", rcvid);
if( db_exists(
"SELECT 1 FROM blob WHERE rcvid=%d AND"
" NOT EXISTS (SELECT 1 FROM shun WHERE shun.uuid=blob.uuid)", rcvid)
){
- style_submenu_element("Shun All", "Shun All", "shun?shun&rcvid=%d#addshun", rcvid);
+ style_submenu_element("Shun All", "Shun All",
+ "shun?shun&rcvid=%d#addshun", rcvid);
}
if( db_exists(
"SELECT 1 FROM blob WHERE rcvid=%d AND"
" EXISTS (SELECT 1 FROM shun WHERE shun.uuid=blob.uuid)", rcvid)
){
- style_submenu_element("Unshun All", "Unshun All", "shun?accept&rcvid=%d#delshun", rcvid);
+ style_submenu_element("Unshun All", "Unshun All",
+ "shun?accept&rcvid=%d#delshun", rcvid);
}
db_prepare(&q,
"SELECT login, datetime(rcvfrom.mtime), rcvfrom.ipaddr"
" FROM rcvfrom LEFT JOIN user USING(uid)"
" WHERE rcvid=%d",
@@ -399,22 +419,30 @@
@ %s(zDate) |
@ | IP Address: |
@ %s(zIpAddr) |
}
db_finalize(&q);
+ db_multi_exec(
+ "CREATE TEMP TABLE toshow(rid INTEGER PRIMARY KEY);"
+ "INSERT INTO toshow SELECT rid FROM blob WHERE rcvid=%d", rcvid
+ );
+ describe_artifacts("IN toshow");
db_prepare(&q,
- "SELECT rid, uuid, size FROM blob WHERE rcvid=%d", rcvid
+ "SELECT blob.rid, blob.uuid, blob.size, description.summary\n"
+ " FROM blob LEFT JOIN description ON (blob.rid=description.rid)"
+ " WHERE blob.rcvid=%d", rcvid
);
@ | Artifacts: |
@
while( db_step(&q)==SQLITE_ROW ){
- int rid = db_column_int(&q, 0);
const char *zUuid = db_column_text(&q, 1);
int size = db_column_int(&q, 2);
+ const char *zDesc = db_column_text(&q, 3);
+ if( zDesc==0 ) zDesc = "";
@ %s(zUuid)
- @ (rid: %d(rid), size: %d(size))
+ @ %h(zDesc) (size: %d(size))
}
@ |
@
db_finalize(&q);
style_footer();
}
Index: src/sqlcmd.c
==================================================================
--- src/sqlcmd.c
+++ src/sqlcmd.c
@@ -106,10 +106,24 @@
sqlite3_result_blob(context, pOut, nOut, sqlite3_free);
}else{
sqlite3_result_error(context, "input is not zlib compressed", -1);
}
}
+
+/*
+** Add the content(), compress(), and decompress() SQL functions to
+** database connection db.
+*/
+int add_content_sql_commands(sqlite3 *db){
+ sqlite3_create_function(db, "content", 1, SQLITE_UTF8, 0,
+ sqlcmd_content, 0, 0);
+ sqlite3_create_function(db, "compress", 1, SQLITE_UTF8, 0,
+ sqlcmd_compress, 0, 0);
+ sqlite3_create_function(db, "decompress", 1, SQLITE_UTF8, 0,
+ sqlcmd_decompress, 0, 0);
+ return SQLITE_OK;
+}
/*
** This is the "automatic extension" initializer that runs right after
** the connection to the repository database is opened. Set up the
** database connection to be more useful to the human operator.
@@ -117,40 +131,27 @@
static int sqlcmd_autoinit(
sqlite3 *db,
const char **pzErrMsg,
const void *notUsed
){
- char *zSql;
- int rc = SQLITE_OK;
- sqlite3_create_function(db, "content", 1, SQLITE_UTF8, 0,
- sqlcmd_content, 0, 0);
- sqlite3_create_function(db, "compress", 1, SQLITE_UTF8, 0,
- sqlcmd_compress, 0, 0);
- sqlite3_create_function(db, "decompress", 1, SQLITE_UTF8, 0,
- sqlcmd_decompress, 0, 0);
+ add_content_sql_commands(db);
re_add_sql_func(db);
- foci_register(db);
g.zMainDbType = "repository";
+ foci_register(db);
g.repositoryOpen = 1;
g.db = db;
- db_open_config(1);
- if( g.zLocalDbName ){
- zSql = sqlite3_mprintf("ATTACH %Q AS localdb;", g.zLocalDbName);
- rc = sqlite3_exec(db, zSql, 0, 0, 0);
- sqlite3_free(zSql);
- }
- return rc;
+ return SQLITE_OK;
}
/*
** COMMAND: sqlite3
**
-** Usage: %fossil sqlite3 ?SQL-COMMANDS? ?OPTIONS?
+** Usage: %fossil sqlite3 ?DATABASE? ?OPTIONS?
**
-** Run the standalone sqlite3 command-line shell on the repository database
-** for the current checkout, or whatever repository is specified by the
-** -R command-line option.
+** Run the standalone sqlite3 command-line shell on DATABASE with OPTIONS.
+** If DATABASE is omitted, then the repository that serves the working
+** directory is opened.
**
** WARNING: Careless use of this command can corrupt a Fossil repository
** in ways that are unrecoverable. Be sure you know what you are doing before
** running any SQL commands that modifies the repository database.
*/
Index: src/sqlite3.c
==================================================================
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -231,11 +231,11 @@
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
** [sqlite_version()] and [sqlite_source_id()].
*/
#define SQLITE_VERSION "3.8.8"
#define SQLITE_VERSION_NUMBER 3008008
-#define SQLITE_SOURCE_ID "2014-11-28 13:35:03 24fa2e9832daaa5d68ee28a00c56c55f97a4da9e"
+#define SQLITE_SOURCE_ID "2014-11-27 11:36:36 f095cde579e7417306e11b5c1d2dd90b6bb547d5"
/*
** CAPI3REF: Run-Time Library Version Numbers
** KEYWORDS: sqlite3_version, sqlite3_sourceid
**
Index: src/sqlite3.h
==================================================================
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -107,11 +107,11 @@
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
** [sqlite_version()] and [sqlite_source_id()].
*/
#define SQLITE_VERSION "3.8.8"
#define SQLITE_VERSION_NUMBER 3008008
-#define SQLITE_SOURCE_ID "2014-11-28 13:35:03 24fa2e9832daaa5d68ee28a00c56c55f97a4da9e"
+#define SQLITE_SOURCE_ID "2014-11-27 11:36:36 f095cde579e7417306e11b5c1d2dd90b6bb547d5"
/*
** CAPI3REF: Run-Time Library Version Numbers
** KEYWORDS: sqlite3_version, sqlite3_sourceid
**
Index: src/timeline.c
==================================================================
--- src/timeline.c
+++ src/timeline.c
@@ -20,10 +20,20 @@
*/
#include "config.h"
#include
#include
#include "timeline.h"
+
+/*
+** Add an appropriate tag to the output if "rid" is unpublished (private)
+*/
+#define UNPUB_TAG "(unpublished)"
+void tag_private_status(int rid){
+ if( content_is_private(rid) ){
+ cgi_printf("%s", UNPUB_TAG);
+ }
+}
/*
** Generate a hyperlink to a version.
*/
void hyperlink_to_uuid(const char *zUuid){
@@ -456,11 +466,11 @@
blob_reset(&links);
}else{
@ tags: %h(zTagList))
}
}
-
+ tag_private_status(rid);
/* Generate extra hyperlinks at the end of the comment */
if( xExtra ){
xExtra(rid);
}
@@ -471,11 +481,11 @@
){
int inUl = 0;
if( !fchngQueryInit ){
db_prepare(&fchngQuery,
"SELECT (pid==0) AS isnew,"
- " (fid==0) AS isdel,"
+ " fid,"
" (SELECT name FROM filename WHERE fnid=mlink.fnid) AS name,"
" (SELECT uuid FROM blob WHERE rid=fid),"
" (SELECT uuid FROM blob WHERE rid=pid),"
" (SELECT name FROM filename WHERE fnid=mlink.pfnid) AS oldnm"
" FROM mlink"
@@ -488,14 +498,16 @@
}
db_bind_int(&fchngQuery, ":mid", rid);
while( db_step(&fchngQuery)==SQLITE_ROW ){
const char *zFilename = db_column_text(&fchngQuery, 2);
int isNew = db_column_int(&fchngQuery, 0);
- int isDel = db_column_int(&fchngQuery, 1);
+ int fid = db_column_int(&fchngQuery, 1);
+ int isDel = fid==0;
const char *zOldName = db_column_text(&fchngQuery, 5);
const char *zOld = db_column_text(&fchngQuery, 4);
const char *zNew = db_column_text(&fchngQuery, 3);
+ const char *zUnpubTag = "";
if( !inUl ){
@
inUl = 1;
}
if( (tmFlags & TIMELINE_FRENAMES)!=0 ){
@@ -502,23 +514,26 @@
if( !isNew && !isDel && zOldName!=0 ){
@ - %h(zOldName) → %h(zFilename)
}
continue;
}
+ if( content_is_private(fid) ){
+ zUnpubTag = UNPUB_TAG;
+ }
if( isNew ){
- @
- %h(zFilename) (new file)
+ @
- %h(zFilename) %s(zUnpubTag) (new file)
@ %z(href("%R/artifact/%s",zNew))[view]
}else if( isDel ){
@ - %h(zFilename) (deleted)
}else if( fossil_strcmp(zOld,zNew)==0 && zOldName!=0 ){
- @ - %h(zOldName) → %h(zFilename)
+ @
- %h(zOldName) → %h(zFilename) %s(zUnpubTag)
@ %z(href("%R/artifact/%s",zNew))[view]
}else{
if( zOldName!=0 ){
- @ - %h(zOldName) → %h(zFilename)
+ @
- %h(zOldName) → %h(zFilename) %s(zUnpubTag)
}else{
- @
- %h(zFilename)
+ @
- %h(zFilename) %s(zUnpubTag)
}
@ %z(href("%R/fdiff?sbs=1&v1=%s&v2=%s",zOld,zNew))[diff]
}
}
db_reset(&fchngQuery);
@@ -1617,11 +1632,15 @@
sqlite3_snprintf(sizeof(zPrefix)-n, &zPrefix[n], zBrType);
n = strlen(zPrefix);
}
if( fossil_strcmp(zCurrentUuid,zId)==0 ){
sqlite3_snprintf(sizeof(zPrefix)-n, &zPrefix[n], "*CURRENT* ");
- n += strlen(zPrefix);
+ n += strlen(zPrefix+n);
+ }
+ if( content_is_private(rid) ){
+ sqlite3_snprintf(sizeof(zPrefix)-n, &zPrefix[n], "*UNPUBLISHED* ");
+ n += strlen(zPrefix+n);
}
zFree = mprintf("[%S] %s%s", zId, zPrefix, zCom);
/* record another X lines */
nLine += comment_print(zFree, zCom, 9, width, g.comFmtFlags);
fossil_free(zFree);
Index: win/Makefile.dmc
==================================================================
--- win/Makefile.dmc
+++ win/Makefile.dmc
@@ -28,13 +28,13 @@
SQLITE_OPTIONS = -DNDEBUG=1 -DSQLITE_OMIT_LOAD_EXTENSION=1 -DSQLITE_ENABLE_LOCKING_STYLE=0 -DSQLITE_THREADSAFE=0 -DSQLITE_DEFAULT_FILE_FORMAT=4 -DSQLITE_OMIT_DEPRECATED -DSQLITE_ENABLE_EXPLAIN_COMMENTS
SHELL_OPTIONS = -Dmain=sqlite3_shell -DSQLITE_OMIT_LOAD_EXTENSION=1 -DUSE_SYSTEM_SQLITE=$(USE_SYSTEM_SQLITE) -DSQLITE_SHELL_DBNAME_PROC=fossil_open -Daccess=file_access -Dsystem=fossil_system -Dgetenv=fossil_getenv -Dfopen=fossil_fopen
-SRC = add_.c allrepo_.c attach_.c bag_.c bisect_.c blob_.c branch_.c browse_.c builtin_.c cache_.c captcha_.c cgi_.c checkin_.c checkout_.c clearsign_.c clone_.c comformat_.c configure_.c content_.c db_.c delta_.c deltacmd_.c descendants_.c diff_.c diffcmd_.c doc_.c encode_.c event_.c export_.c file_.c finfo_.c foci_.c fusefs_.c glob_.c graph_.c gzip_.c http_.c http_socket_.c http_ssl_.c http_transport_.c import_.c info_.c json_.c json_artifact_.c json_branch_.c json_config_.c json_diff_.c json_dir_.c json_finfo_.c json_login_.c json_query_.c json_report_.c json_status_.c json_tag_.c json_timeline_.c json_user_.c json_wiki_.c leaf_.c loadctrl_.c login_.c lookslike_.c main_.c manifest_.c markdown_.c markdown_html_.c md5_.c merge_.c merge3_.c moderate_.c name_.c path_.c pivot_.c popen_.c pqueue_.c printf_.c rebuild_.c regexp_.c report_.c rss_.c schema_.c search_.c setup_.c sha1_.c shun_.c skins_.c sqlcmd_.c stash_.c stat_.c style_.c sync_.c tag_.c tar_.c th_main_.c timeline_.c tkt_.c tktsetup_.c undo_.c unicode_.c update_.c url_.c user_.c utf8_.c util_.c verify_.c vfile_.c wiki_.c wikiformat_.c winfile_.c winhttp_.c wysiwyg_.c xfer_.c xfersetup_.c zip_.c
+SRC = add_.c allrepo_.c attach_.c bag_.c bisect_.c blob_.c branch_.c browse_.c builtin_.c bundle_.c cache_.c captcha_.c cgi_.c checkin_.c checkout_.c clearsign_.c clone_.c comformat_.c configure_.c content_.c db_.c delta_.c deltacmd_.c descendants_.c diff_.c diffcmd_.c doc_.c encode_.c event_.c export_.c file_.c finfo_.c foci_.c fusefs_.c glob_.c graph_.c gzip_.c http_.c http_socket_.c http_ssl_.c http_transport_.c import_.c info_.c json_.c json_artifact_.c json_branch_.c json_config_.c json_diff_.c json_dir_.c json_finfo_.c json_login_.c json_query_.c json_report_.c json_status_.c json_tag_.c json_timeline_.c json_user_.c json_wiki_.c leaf_.c loadctrl_.c login_.c lookslike_.c main_.c manifest_.c markdown_.c markdown_html_.c md5_.c merge_.c merge3_.c moderate_.c name_.c path_.c pivot_.c popen_.c pqueue_.c printf_.c publish_.c purge_.c rebuild_.c regexp_.c report_.c rss_.c schema_.c search_.c setup_.c sha1_.c shun_.c skins_.c sqlcmd_.c stash_.c stat_.c style_.c sync_.c tag_.c tar_.c th_main_.c timeline_.c tkt_.c tktsetup_.c undo_.c unicode_.c update_.c url_.c user_.c utf8_.c util_.c verify_.c vfile_.c wiki_.c wikiformat_.c winfile_.c winhttp_.c wysiwyg_.c xfer_.c xfersetup_.c zip_.c
-OBJ = $(OBJDIR)\add$O $(OBJDIR)\allrepo$O $(OBJDIR)\attach$O $(OBJDIR)\bag$O $(OBJDIR)\bisect$O $(OBJDIR)\blob$O $(OBJDIR)\branch$O $(OBJDIR)\browse$O $(OBJDIR)\builtin$O $(OBJDIR)\cache$O $(OBJDIR)\captcha$O $(OBJDIR)\cgi$O $(OBJDIR)\checkin$O $(OBJDIR)\checkout$O $(OBJDIR)\clearsign$O $(OBJDIR)\clone$O $(OBJDIR)\comformat$O $(OBJDIR)\configure$O $(OBJDIR)\content$O $(OBJDIR)\db$O $(OBJDIR)\delta$O $(OBJDIR)\deltacmd$O $(OBJDIR)\descendants$O $(OBJDIR)\diff$O $(OBJDIR)\diffcmd$O $(OBJDIR)\doc$O $(OBJDIR)\encode$O $(OBJDIR)\event$O $(OBJDIR)\export$O $(OBJDIR)\file$O $(OBJDIR)\finfo$O $(OBJDIR)\foci$O $(OBJDIR)\fusefs$O $(OBJDIR)\glob$O $(OBJDIR)\graph$O $(OBJDIR)\gzip$O $(OBJDIR)\http$O $(OBJDIR)\http_socket$O $(OBJDIR)\http_ssl$O $(OBJDIR)\http_transport$O $(OBJDIR)\import$O $(OBJDIR)\info$O $(OBJDIR)\json$O $(OBJDIR)\json_artifact$O $(OBJDIR)\json_branch$O $(OBJDIR)\json_config$O $(OBJDIR)\json_diff$O $(OBJDIR)\json_dir$O $(OBJDIR)\json_finfo$O $(OBJDIR)\json_login$O $(OBJDIR)\json_query$O $(OBJDIR)\json_report$O $(OBJDIR)\json_status$O $(OBJDIR)\json_tag$O $(OBJDIR)\json_timeline$O $(OBJDIR)\json_user$O $(OBJDIR)\json_wiki$O $(OBJDIR)\leaf$O $(OBJDIR)\loadctrl$O $(OBJDIR)\login$O $(OBJDIR)\lookslike$O $(OBJDIR)\main$O $(OBJDIR)\manifest$O $(OBJDIR)\markdown$O $(OBJDIR)\markdown_html$O $(OBJDIR)\md5$O $(OBJDIR)\merge$O $(OBJDIR)\merge3$O $(OBJDIR)\moderate$O $(OBJDIR)\name$O $(OBJDIR)\path$O $(OBJDIR)\pivot$O $(OBJDIR)\popen$O $(OBJDIR)\pqueue$O $(OBJDIR)\printf$O $(OBJDIR)\rebuild$O $(OBJDIR)\regexp$O $(OBJDIR)\report$O $(OBJDIR)\rss$O $(OBJDIR)\schema$O $(OBJDIR)\search$O $(OBJDIR)\setup$O $(OBJDIR)\sha1$O $(OBJDIR)\shun$O $(OBJDIR)\skins$O $(OBJDIR)\sqlcmd$O $(OBJDIR)\stash$O $(OBJDIR)\stat$O $(OBJDIR)\style$O $(OBJDIR)\sync$O $(OBJDIR)\tag$O $(OBJDIR)\tar$O $(OBJDIR)\th_main$O $(OBJDIR)\timeline$O $(OBJDIR)\tkt$O $(OBJDIR)\tktsetup$O $(OBJDIR)\undo$O $(OBJDIR)\unicode$O $(OBJDIR)\update$O $(OBJDIR)\url$O $(OBJDIR)\user$O $(OBJDIR)\utf8$O $(OBJDIR)\util$O $(OBJDIR)\verify$O $(OBJDIR)\vfile$O $(OBJDIR)\wiki$O $(OBJDIR)\wikiformat$O $(OBJDIR)\winfile$O $(OBJDIR)\winhttp$O $(OBJDIR)\wysiwyg$O $(OBJDIR)\xfer$O $(OBJDIR)\xfersetup$O $(OBJDIR)\zip$O $(OBJDIR)\shell$O $(OBJDIR)\sqlite3$O $(OBJDIR)\th$O $(OBJDIR)\th_lang$O
+OBJ = $(OBJDIR)\add$O $(OBJDIR)\allrepo$O $(OBJDIR)\attach$O $(OBJDIR)\bag$O $(OBJDIR)\bisect$O $(OBJDIR)\blob$O $(OBJDIR)\branch$O $(OBJDIR)\browse$O $(OBJDIR)\builtin$O $(OBJDIR)\bundle$O $(OBJDIR)\cache$O $(OBJDIR)\captcha$O $(OBJDIR)\cgi$O $(OBJDIR)\checkin$O $(OBJDIR)\checkout$O $(OBJDIR)\clearsign$O $(OBJDIR)\clone$O $(OBJDIR)\comformat$O $(OBJDIR)\configure$O $(OBJDIR)\content$O $(OBJDIR)\db$O $(OBJDIR)\delta$O $(OBJDIR)\deltacmd$O $(OBJDIR)\descendants$O $(OBJDIR)\diff$O $(OBJDIR)\diffcmd$O $(OBJDIR)\doc$O $(OBJDIR)\encode$O $(OBJDIR)\event$O $(OBJDIR)\export$O $(OBJDIR)\file$O $(OBJDIR)\finfo$O $(OBJDIR)\foci$O $(OBJDIR)\fusefs$O $(OBJDIR)\glob$O $(OBJDIR)\graph$O $(OBJDIR)\gzip$O $(OBJDIR)\http$O $(OBJDIR)\http_socket$O $(OBJDIR)\http_ssl$O $(OBJDIR)\http_transport$O $(OBJDIR)\import$O $(OBJDIR)\info$O $(OBJDIR)\json$O $(OBJDIR)\json_artifact$O $(OBJDIR)\json_branch$O $(OBJDIR)\json_config$O $(OBJDIR)\json_diff$O $(OBJDIR)\json_dir$O $(OBJDIR)\json_finfo$O $(OBJDIR)\json_login$O $(OBJDIR)\json_query$O $(OBJDIR)\json_report$O $(OBJDIR)\json_status$O $(OBJDIR)\json_tag$O $(OBJDIR)\json_timeline$O $(OBJDIR)\json_user$O $(OBJDIR)\json_wiki$O $(OBJDIR)\leaf$O $(OBJDIR)\loadctrl$O $(OBJDIR)\login$O $(OBJDIR)\lookslike$O $(OBJDIR)\main$O $(OBJDIR)\manifest$O $(OBJDIR)\markdown$O $(OBJDIR)\markdown_html$O $(OBJDIR)\md5$O $(OBJDIR)\merge$O $(OBJDIR)\merge3$O $(OBJDIR)\moderate$O $(OBJDIR)\name$O $(OBJDIR)\path$O $(OBJDIR)\pivot$O $(OBJDIR)\popen$O $(OBJDIR)\pqueue$O $(OBJDIR)\printf$O $(OBJDIR)\publish$O $(OBJDIR)\purge$O $(OBJDIR)\rebuild$O $(OBJDIR)\regexp$O $(OBJDIR)\report$O $(OBJDIR)\rss$O $(OBJDIR)\schema$O $(OBJDIR)\search$O $(OBJDIR)\setup$O $(OBJDIR)\sha1$O $(OBJDIR)\shun$O $(OBJDIR)\skins$O $(OBJDIR)\sqlcmd$O $(OBJDIR)\stash$O $(OBJDIR)\stat$O $(OBJDIR)\style$O $(OBJDIR)\sync$O $(OBJDIR)\tag$O $(OBJDIR)\tar$O $(OBJDIR)\th_main$O $(OBJDIR)\timeline$O $(OBJDIR)\tkt$O $(OBJDIR)\tktsetup$O $(OBJDIR)\undo$O $(OBJDIR)\unicode$O $(OBJDIR)\update$O $(OBJDIR)\url$O $(OBJDIR)\user$O $(OBJDIR)\utf8$O $(OBJDIR)\util$O $(OBJDIR)\verify$O $(OBJDIR)\vfile$O $(OBJDIR)\wiki$O $(OBJDIR)\wikiformat$O $(OBJDIR)\winfile$O $(OBJDIR)\winhttp$O $(OBJDIR)\wysiwyg$O $(OBJDIR)\xfer$O $(OBJDIR)\xfersetup$O $(OBJDIR)\zip$O $(OBJDIR)\shell$O $(OBJDIR)\sqlite3$O $(OBJDIR)\th$O $(OBJDIR)\th_lang$O
RC=$(DMDIR)\bin\rcc
RCFLAGS=-32 -w1 -I$(SRCDIR) /D__DMC__
@@ -49,11 +49,11 @@
$(OBJDIR)\fossil.res: $B\win\fossil.rc
$(RC) $(RCFLAGS) -o$@ $**
$(OBJDIR)\link: $B\win\Makefile.dmc $(OBJDIR)\fossil.res
- +echo add allrepo attach bag bisect blob branch browse builtin cache captcha cgi checkin checkout clearsign clone comformat configure content db delta deltacmd descendants diff diffcmd doc encode event export file finfo foci fusefs glob graph gzip http http_socket http_ssl http_transport import info json json_artifact json_branch json_config json_diff json_dir json_finfo json_login json_query json_report json_status json_tag json_timeline json_user json_wiki leaf loadctrl login lookslike main manifest markdown markdown_html md5 merge merge3 moderate name path pivot popen pqueue printf rebuild regexp report rss schema search setup sha1 shun skins sqlcmd stash stat style sync tag tar th_main timeline tkt tktsetup undo unicode update url user utf8 util verify vfile wiki wikiformat winfile winhttp wysiwyg xfer xfersetup zip shell sqlite3 th th_lang > $@
+ +echo add allrepo attach bag bisect blob branch browse builtin bundle cache captcha cgi checkin checkout clearsign clone comformat configure content db delta deltacmd descendants diff diffcmd doc encode event export file finfo foci fusefs glob graph gzip http http_socket http_ssl http_transport import info json json_artifact json_branch json_config json_diff json_dir json_finfo json_login json_query json_report json_status json_tag json_timeline json_user json_wiki leaf loadctrl login lookslike main manifest markdown markdown_html md5 merge merge3 moderate name path pivot popen pqueue printf publish purge rebuild regexp report rss schema search setup sha1 shun skins sqlcmd stash stat style sync tag tar th_main timeline tkt tktsetup undo unicode update url user utf8 util verify vfile wiki wikiformat winfile winhttp wysiwyg xfer xfersetup zip shell sqlite3 th th_lang > $@
+echo fossil >> $@
+echo fossil >> $@
+echo $(LIBS) >> $@
+echo. >> $@
+echo fossil >> $@
@@ -176,10 +176,16 @@
$(OBJDIR)\builtin$O : builtin_.c builtin.h
$(TCC) -o$@ -c builtin_.c
builtin_.c : $(SRCDIR)\builtin.c
+translate$E $** > $@
+
+$(OBJDIR)\bundle$O : bundle_.c bundle.h
+ $(TCC) -o$@ -c bundle_.c
+
+bundle_.c : $(SRCDIR)\bundle.c
+ +translate$E $** > $@
$(OBJDIR)\cache$O : cache_.c cache.h
$(TCC) -o$@ -c cache_.c
cache_.c : $(SRCDIR)\cache.c
@@ -572,10 +578,22 @@
$(OBJDIR)\printf$O : printf_.c printf.h
$(TCC) -o$@ -c printf_.c
printf_.c : $(SRCDIR)\printf.c
+translate$E $** > $@
+
+$(OBJDIR)\publish$O : publish_.c publish.h
+ $(TCC) -o$@ -c publish_.c
+
+publish_.c : $(SRCDIR)\publish.c
+ +translate$E $** > $@
+
+$(OBJDIR)\purge$O : purge_.c purge.h
+ $(TCC) -o$@ -c purge_.c
+
+purge_.c : $(SRCDIR)\purge.c
+ +translate$E $** > $@
$(OBJDIR)\rebuild$O : rebuild_.c rebuild.h
$(TCC) -o$@ -c rebuild_.c
rebuild_.c : $(SRCDIR)\rebuild.c
@@ -802,7 +820,7 @@
zip_.c : $(SRCDIR)\zip.c
+translate$E $** > $@
headers: makeheaders$E page_index.h builtin_data.h VERSION.h
- +makeheaders$E add_.c:add.h allrepo_.c:allrepo.h attach_.c:attach.h bag_.c:bag.h bisect_.c:bisect.h blob_.c:blob.h branch_.c:branch.h browse_.c:browse.h builtin_.c:builtin.h cache_.c:cache.h captcha_.c:captcha.h cgi_.c:cgi.h checkin_.c:checkin.h checkout_.c:checkout.h clearsign_.c:clearsign.h clone_.c:clone.h comformat_.c:comformat.h configure_.c:configure.h content_.c:content.h db_.c:db.h delta_.c:delta.h deltacmd_.c:deltacmd.h descendants_.c:descendants.h diff_.c:diff.h diffcmd_.c:diffcmd.h doc_.c:doc.h encode_.c:encode.h event_.c:event.h export_.c:export.h file_.c:file.h finfo_.c:finfo.h foci_.c:foci.h fusefs_.c:fusefs.h glob_.c:glob.h graph_.c:graph.h gzip_.c:gzip.h http_.c:http.h http_socket_.c:http_socket.h http_ssl_.c:http_ssl.h http_transport_.c:http_transport.h import_.c:import.h info_.c:info.h json_.c:json.h json_artifact_.c:json_artifact.h json_branch_.c:json_branch.h json_config_.c:json_config.h json_diff_.c:json_diff.h json_dir_.c:json_dir.h json_finfo_.c:json_finfo.h json_login_.c:json_login.h json_query_.c:json_query.h json_report_.c:json_report.h json_status_.c:json_status.h json_tag_.c:json_tag.h json_timeline_.c:json_timeline.h json_user_.c:json_user.h json_wiki_.c:json_wiki.h leaf_.c:leaf.h loadctrl_.c:loadctrl.h login_.c:login.h lookslike_.c:lookslike.h main_.c:main.h manifest_.c:manifest.h markdown_.c:markdown.h markdown_html_.c:markdown_html.h md5_.c:md5.h merge_.c:merge.h merge3_.c:merge3.h moderate_.c:moderate.h name_.c:name.h path_.c:path.h pivot_.c:pivot.h popen_.c:popen.h pqueue_.c:pqueue.h printf_.c:printf.h rebuild_.c:rebuild.h regexp_.c:regexp.h report_.c:report.h rss_.c:rss.h schema_.c:schema.h search_.c:search.h setup_.c:setup.h sha1_.c:sha1.h shun_.c:shun.h skins_.c:skins.h sqlcmd_.c:sqlcmd.h stash_.c:stash.h stat_.c:stat.h style_.c:style.h sync_.c:sync.h tag_.c:tag.h tar_.c:tar.h th_main_.c:th_main.h timeline_.c:timeline.h tkt_.c:tkt.h tktsetup_.c:tktsetup.h undo_.c:undo.h unicode_.c:unicode.h update_.c:update.h url_.c:url.h user_.c:user.h utf8_.c:utf8.h util_.c:util.h verify_.c:verify.h vfile_.c:vfile.h wiki_.c:wiki.h wikiformat_.c:wikiformat.h winfile_.c:winfile.h winhttp_.c:winhttp.h wysiwyg_.c:wysiwyg.h xfer_.c:xfer.h xfersetup_.c:xfersetup.h zip_.c:zip.h $(SRCDIR)\sqlite3.h $(SRCDIR)\th.h VERSION.h $(SRCDIR)\cson_amalgamation.h
+ +makeheaders$E add_.c:add.h allrepo_.c:allrepo.h attach_.c:attach.h bag_.c:bag.h bisect_.c:bisect.h blob_.c:blob.h branch_.c:branch.h browse_.c:browse.h builtin_.c:builtin.h bundle_.c:bundle.h cache_.c:cache.h captcha_.c:captcha.h cgi_.c:cgi.h checkin_.c:checkin.h checkout_.c:checkout.h clearsign_.c:clearsign.h clone_.c:clone.h comformat_.c:comformat.h configure_.c:configure.h content_.c:content.h db_.c:db.h delta_.c:delta.h deltacmd_.c:deltacmd.h descendants_.c:descendants.h diff_.c:diff.h diffcmd_.c:diffcmd.h doc_.c:doc.h encode_.c:encode.h event_.c:event.h export_.c:export.h file_.c:file.h finfo_.c:finfo.h foci_.c:foci.h fusefs_.c:fusefs.h glob_.c:glob.h graph_.c:graph.h gzip_.c:gzip.h http_.c:http.h http_socket_.c:http_socket.h http_ssl_.c:http_ssl.h http_transport_.c:http_transport.h import_.c:import.h info_.c:info.h json_.c:json.h json_artifact_.c:json_artifact.h json_branch_.c:json_branch.h json_config_.c:json_config.h json_diff_.c:json_diff.h json_dir_.c:json_dir.h json_finfo_.c:json_finfo.h json_login_.c:json_login.h json_query_.c:json_query.h json_report_.c:json_report.h json_status_.c:json_status.h json_tag_.c:json_tag.h json_timeline_.c:json_timeline.h json_user_.c:json_user.h json_wiki_.c:json_wiki.h leaf_.c:leaf.h loadctrl_.c:loadctrl.h login_.c:login.h lookslike_.c:lookslike.h main_.c:main.h manifest_.c:manifest.h markdown_.c:markdown.h markdown_html_.c:markdown_html.h md5_.c:md5.h merge_.c:merge.h merge3_.c:merge3.h moderate_.c:moderate.h name_.c:name.h path_.c:path.h pivot_.c:pivot.h popen_.c:popen.h pqueue_.c:pqueue.h printf_.c:printf.h publish_.c:publish.h purge_.c:purge.h rebuild_.c:rebuild.h regexp_.c:regexp.h report_.c:report.h rss_.c:rss.h schema_.c:schema.h search_.c:search.h setup_.c:setup.h sha1_.c:sha1.h shun_.c:shun.h skins_.c:skins.h sqlcmd_.c:sqlcmd.h stash_.c:stash.h stat_.c:stat.h style_.c:style.h sync_.c:sync.h tag_.c:tag.h tar_.c:tar.h th_main_.c:th_main.h timeline_.c:timeline.h tkt_.c:tkt.h tktsetup_.c:tktsetup.h undo_.c:undo.h unicode_.c:unicode.h update_.c:update.h url_.c:url.h user_.c:user.h utf8_.c:utf8.h util_.c:util.h verify_.c:verify.h vfile_.c:vfile.h wiki_.c:wiki.h wikiformat_.c:wikiformat.h winfile_.c:winfile.h winhttp_.c:winhttp.h wysiwyg_.c:wysiwyg.h xfer_.c:xfer.h xfersetup_.c:xfersetup.h zip_.c:zip.h $(SRCDIR)\sqlite3.h $(SRCDIR)\th.h VERSION.h $(SRCDIR)\cson_amalgamation.h
@copy /Y nul: headers
Index: win/Makefile.mingw
==================================================================
--- win/Makefile.mingw
+++ win/Makefile.mingw
@@ -352,10 +352,11 @@
$(SRCDIR)/bisect.c \
$(SRCDIR)/blob.c \
$(SRCDIR)/branch.c \
$(SRCDIR)/browse.c \
$(SRCDIR)/builtin.c \
+ $(SRCDIR)/bundle.c \
$(SRCDIR)/cache.c \
$(SRCDIR)/captcha.c \
$(SRCDIR)/cgi.c \
$(SRCDIR)/checkin.c \
$(SRCDIR)/checkout.c \
@@ -418,10 +419,12 @@
$(SRCDIR)/path.c \
$(SRCDIR)/pivot.c \
$(SRCDIR)/popen.c \
$(SRCDIR)/pqueue.c \
$(SRCDIR)/printf.c \
+ $(SRCDIR)/publish.c \
+ $(SRCDIR)/purge.c \
$(SRCDIR)/rebuild.c \
$(SRCDIR)/regexp.c \
$(SRCDIR)/report.c \
$(SRCDIR)/rss.c \
$(SRCDIR)/schema.c \
@@ -470,10 +473,11 @@
$(OBJDIR)/bisect_.c \
$(OBJDIR)/blob_.c \
$(OBJDIR)/branch_.c \
$(OBJDIR)/browse_.c \
$(OBJDIR)/builtin_.c \
+ $(OBJDIR)/bundle_.c \
$(OBJDIR)/cache_.c \
$(OBJDIR)/captcha_.c \
$(OBJDIR)/cgi_.c \
$(OBJDIR)/checkin_.c \
$(OBJDIR)/checkout_.c \
@@ -536,10 +540,12 @@
$(OBJDIR)/path_.c \
$(OBJDIR)/pivot_.c \
$(OBJDIR)/popen_.c \
$(OBJDIR)/pqueue_.c \
$(OBJDIR)/printf_.c \
+ $(OBJDIR)/publish_.c \
+ $(OBJDIR)/purge_.c \
$(OBJDIR)/rebuild_.c \
$(OBJDIR)/regexp_.c \
$(OBJDIR)/report_.c \
$(OBJDIR)/rss_.c \
$(OBJDIR)/schema_.c \
@@ -585,10 +591,11 @@
$(OBJDIR)/bisect.o \
$(OBJDIR)/blob.o \
$(OBJDIR)/branch.o \
$(OBJDIR)/browse.o \
$(OBJDIR)/builtin.o \
+ $(OBJDIR)/bundle.o \
$(OBJDIR)/cache.o \
$(OBJDIR)/captcha.o \
$(OBJDIR)/cgi.o \
$(OBJDIR)/checkin.o \
$(OBJDIR)/checkout.o \
@@ -651,10 +658,12 @@
$(OBJDIR)/path.o \
$(OBJDIR)/pivot.o \
$(OBJDIR)/popen.o \
$(OBJDIR)/pqueue.o \
$(OBJDIR)/printf.o \
+ $(OBJDIR)/publish.o \
+ $(OBJDIR)/purge.o \
$(OBJDIR)/rebuild.o \
$(OBJDIR)/regexp.o \
$(OBJDIR)/report.o \
$(OBJDIR)/rss.o \
$(OBJDIR)/schema.o \
@@ -893,10 +902,11 @@
$(OBJDIR)/bisect_.c:$(OBJDIR)/bisect.h \
$(OBJDIR)/blob_.c:$(OBJDIR)/blob.h \
$(OBJDIR)/branch_.c:$(OBJDIR)/branch.h \
$(OBJDIR)/browse_.c:$(OBJDIR)/browse.h \
$(OBJDIR)/builtin_.c:$(OBJDIR)/builtin.h \
+ $(OBJDIR)/bundle_.c:$(OBJDIR)/bundle.h \
$(OBJDIR)/cache_.c:$(OBJDIR)/cache.h \
$(OBJDIR)/captcha_.c:$(OBJDIR)/captcha.h \
$(OBJDIR)/cgi_.c:$(OBJDIR)/cgi.h \
$(OBJDIR)/checkin_.c:$(OBJDIR)/checkin.h \
$(OBJDIR)/checkout_.c:$(OBJDIR)/checkout.h \
@@ -959,10 +969,12 @@
$(OBJDIR)/path_.c:$(OBJDIR)/path.h \
$(OBJDIR)/pivot_.c:$(OBJDIR)/pivot.h \
$(OBJDIR)/popen_.c:$(OBJDIR)/popen.h \
$(OBJDIR)/pqueue_.c:$(OBJDIR)/pqueue.h \
$(OBJDIR)/printf_.c:$(OBJDIR)/printf.h \
+ $(OBJDIR)/publish_.c:$(OBJDIR)/publish.h \
+ $(OBJDIR)/purge_.c:$(OBJDIR)/purge.h \
$(OBJDIR)/rebuild_.c:$(OBJDIR)/rebuild.h \
$(OBJDIR)/regexp_.c:$(OBJDIR)/regexp.h \
$(OBJDIR)/report_.c:$(OBJDIR)/report.h \
$(OBJDIR)/rss_.c:$(OBJDIR)/rss.h \
$(OBJDIR)/schema_.c:$(OBJDIR)/schema.h \
@@ -1077,10 +1089,18 @@
$(OBJDIR)/builtin.o: $(OBJDIR)/builtin_.c $(OBJDIR)/builtin.h $(OBJDIR)/builtin_data.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/builtin.o -c $(OBJDIR)/builtin_.c
$(OBJDIR)/builtin.h: $(OBJDIR)/headers
+
+$(OBJDIR)/bundle_.c: $(SRCDIR)/bundle.c $(TRANSLATE)
+ $(TRANSLATE) $(SRCDIR)/bundle.c >$@
+
+$(OBJDIR)/bundle.o: $(OBJDIR)/bundle_.c $(OBJDIR)/bundle.h $(SRCDIR)/config.h
+ $(XTCC) -o $(OBJDIR)/bundle.o -c $(OBJDIR)/bundle_.c
+
+$(OBJDIR)/bundle.h: $(OBJDIR)/headers
$(OBJDIR)/cache_.c: $(SRCDIR)/cache.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/cache.c >$@
$(OBJDIR)/cache.o: $(OBJDIR)/cache_.c $(OBJDIR)/cache.h $(SRCDIR)/config.h
@@ -1605,10 +1625,26 @@
$(OBJDIR)/printf.o: $(OBJDIR)/printf_.c $(OBJDIR)/printf.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/printf.o -c $(OBJDIR)/printf_.c
$(OBJDIR)/printf.h: $(OBJDIR)/headers
+
+$(OBJDIR)/publish_.c: $(SRCDIR)/publish.c $(TRANSLATE)
+ $(TRANSLATE) $(SRCDIR)/publish.c >$@
+
+$(OBJDIR)/publish.o: $(OBJDIR)/publish_.c $(OBJDIR)/publish.h $(SRCDIR)/config.h
+ $(XTCC) -o $(OBJDIR)/publish.o -c $(OBJDIR)/publish_.c
+
+$(OBJDIR)/publish.h: $(OBJDIR)/headers
+
+$(OBJDIR)/purge_.c: $(SRCDIR)/purge.c $(TRANSLATE)
+ $(TRANSLATE) $(SRCDIR)/purge.c >$@
+
+$(OBJDIR)/purge.o: $(OBJDIR)/purge_.c $(OBJDIR)/purge.h $(SRCDIR)/config.h
+ $(XTCC) -o $(OBJDIR)/purge.o -c $(OBJDIR)/purge_.c
+
+$(OBJDIR)/purge.h: $(OBJDIR)/headers
$(OBJDIR)/rebuild_.c: $(SRCDIR)/rebuild.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/rebuild.c >$@
$(OBJDIR)/rebuild.o: $(OBJDIR)/rebuild_.c $(OBJDIR)/rebuild.h $(SRCDIR)/config.h
Index: win/Makefile.msc
==================================================================
--- win/Makefile.msc
+++ win/Makefile.msc
@@ -204,10 +204,11 @@
bisect_.c \
blob_.c \
branch_.c \
browse_.c \
builtin_.c \
+ bundle_.c \
cache_.c \
captcha_.c \
cgi_.c \
checkin_.c \
checkout_.c \
@@ -270,10 +271,12 @@
path_.c \
pivot_.c \
popen_.c \
pqueue_.c \
printf_.c \
+ publish_.c \
+ purge_.c \
rebuild_.c \
regexp_.c \
report_.c \
rss_.c \
schema_.c \
@@ -320,10 +323,11 @@
$(OX)\bisect$O \
$(OX)\blob$O \
$(OX)\branch$O \
$(OX)\browse$O \
$(OX)\builtin$O \
+ $(OX)\bundle$O \
$(OX)\cache$O \
$(OX)\captcha$O \
$(OX)\cgi$O \
$(OX)\checkin$O \
$(OX)\checkout$O \
@@ -387,10 +391,12 @@
$(OX)\path$O \
$(OX)\pivot$O \
$(OX)\popen$O \
$(OX)\pqueue$O \
$(OX)\printf$O \
+ $(OX)\publish$O \
+ $(OX)\purge$O \
$(OX)\rebuild$O \
$(OX)\regexp$O \
$(OX)\report$O \
$(OX)\rss$O \
$(OX)\schema$O \
@@ -490,10 +496,11 @@
echo $(OX)\bisect.obj >> $@
echo $(OX)\blob.obj >> $@
echo $(OX)\branch.obj >> $@
echo $(OX)\browse.obj >> $@
echo $(OX)\builtin.obj >> $@
+ echo $(OX)\bundle.obj >> $@
echo $(OX)\cache.obj >> $@
echo $(OX)\captcha.obj >> $@
echo $(OX)\cgi.obj >> $@
echo $(OX)\checkin.obj >> $@
echo $(OX)\checkout.obj >> $@
@@ -557,10 +564,12 @@
echo $(OX)\path.obj >> $@
echo $(OX)\pivot.obj >> $@
echo $(OX)\popen.obj >> $@
echo $(OX)\pqueue.obj >> $@
echo $(OX)\printf.obj >> $@
+ echo $(OX)\publish.obj >> $@
+ echo $(OX)\purge.obj >> $@
echo $(OX)\rebuild.obj >> $@
echo $(OX)\regexp.obj >> $@
echo $(OX)\report.obj >> $@
echo $(OX)\rss.obj >> $@
echo $(OX)\schema.obj >> $@
@@ -752,10 +761,16 @@
$(OX)\builtin$O : builtin_.c builtin.h
$(TCC) /Fo$@ -c builtin_.c
builtin_.c : $(SRCDIR)\builtin.c
translate$E $** > $@
+
+$(OX)\bundle$O : bundle_.c bundle.h
+ $(TCC) /Fo$@ -c bundle_.c
+
+bundle_.c : $(SRCDIR)\bundle.c
+ translate$E $** > $@
$(OX)\cache$O : cache_.c cache.h
$(TCC) /Fo$@ -c cache_.c
cache_.c : $(SRCDIR)\cache.c
@@ -1148,10 +1163,22 @@
$(OX)\printf$O : printf_.c printf.h
$(TCC) /Fo$@ -c printf_.c
printf_.c : $(SRCDIR)\printf.c
translate$E $** > $@
+
+$(OX)\publish$O : publish_.c publish.h
+ $(TCC) /Fo$@ -c publish_.c
+
+publish_.c : $(SRCDIR)\publish.c
+ translate$E $** > $@
+
+$(OX)\purge$O : purge_.c purge.h
+ $(TCC) /Fo$@ -c purge_.c
+
+purge_.c : $(SRCDIR)\purge.c
+ translate$E $** > $@
$(OX)\rebuild$O : rebuild_.c rebuild.h
$(TCC) /Fo$@ -c rebuild_.c
rebuild_.c : $(SRCDIR)\rebuild.c
@@ -1390,10 +1417,11 @@
bisect_.c:bisect.h \
blob_.c:blob.h \
branch_.c:branch.h \
browse_.c:browse.h \
builtin_.c:builtin.h \
+ bundle_.c:bundle.h \
cache_.c:cache.h \
captcha_.c:captcha.h \
cgi_.c:cgi.h \
checkin_.c:checkin.h \
checkout_.c:checkout.h \
@@ -1456,10 +1484,12 @@
path_.c:path.h \
pivot_.c:pivot.h \
popen_.c:popen.h \
pqueue_.c:pqueue.h \
printf_.c:printf.h \
+ publish_.c:publish.h \
+ purge_.c:purge.h \
rebuild_.c:rebuild.h \
regexp_.c:regexp.h \
report_.c:report.h \
rss_.c:rss.h \
schema_.c:schema.h \
Index: www/checkin_names.wiki
==================================================================
--- www/checkin_names.wiki
+++ www/checkin_names.wiki
@@ -115,10 +115,31 @@
The "tag:deed2" name will refer to the most recent check-in
tagged with "deed2" not to the
check-in whose canonical name begins with "deed2".
+Whole Branches
+
+Usually whan a branch name is specified, it means the latest checkin on
+that branch. But for some commands (ex: [/help/purge|purge]) a branch name
+on the argument means the earliest connected checkin on the branch. This
+seems confusing when being explained here, but it works out to be intuitive
+in practice.
+
+For example, the command "fossil purge XYZ" means to purge the checkin XYZ
+and all of its descendents. But when XYZ is in the form of a branch name, one
+generally wants to purge the entire branch, not just the last checkin on the
+branch. And so for this reason, commands like purge will interpret a branch
+name to be the first checkin of the branch rather than the last. If there
+are two or more branches with the same name, then these commands will select
+the first check-in of the branch that has the most recent checkin. What
+happens is that Fossil searches for the most recent checkin with the given
+tag, just as it always does. But if that tag is a branch name, it then walks
+back down the branch looking for the first check-in of that branch.
+
+Again, this behavior only occurs on a few commands where it make sense.
+
Timestamps
A timestamp in one of the formats shown below means the most recent
check-in that occurs no later than the timestamp given: