Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Change the bundle on-disk format slightly. Add the "bundle ls" command. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | DBP-workflow |
Files: | files | file ages | folders |
SHA1: |
b2a56a76d55c99860a1ed4dba0440f93 |
User & Date: | drh 2014-11-25 22:43:02.189 |
Context
2014-11-25
| ||
23:15 | First cut at the "bundle export" command. Enhancements to "bundle ls". ... (check-in: a2f04d81 user: drh tags: DBP-workflow) | |
22:43 | Change the bundle on-disk format slightly. Add the "bundle ls" command. ... (check-in: b2a56a76 user: drh tags: DBP-workflow) | |
20:49 | Work on the logic for parsing command-line options to the "bundle export". The same routine might well be useful for other routines, like "timeline". ... (check-in: 8a57413e user: drh tags: DBP-workflow) | |
Changes
Changes to src/bundle.c.
︙ | ︙ | |||
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | */ #include "config.h" #include "bundle.h" #include <assert.h> /* ** SQL code used to initialize the schema of a bundle. */ 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 | > > > > > > | > > | > > > > > > > > > > > > > > > > > > | > > | > > > | 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 | */ #include "config.h" #include "bundle.h" #include <assert.h> /* ** 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 @ 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 */ ){ db_multi_exec("ATTACH %Q AS %Q;", zFile, zBName); db_multi_exec(zBundleInit /*works-like:"%w%w"*/, zBName, zBName); } /* ** fossil bundle ls BUNDLE ?OPTIONS? ** ** Display the content of a bundle in human-readable form. */ static void bundle_ls(void){ Stmt q; sqlite3_int64 sumSz = 0; sqlite3_int64 sumLen = 0; bundle_attach_file(g.argv[3], "b1", 0); db_prepare(&q, "SELECT blobid, substr(uuid,1,16), coalesce(substr(delta,1,16),'')," " sz, length(data)" " FROM bblob" ); while( db_step(&q)==SQLITE_ROW ){ fossil_print("%4d %16s %16s %10d %10d\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)); sumSz += db_column_int(&q,3); sumLen += db_column_int(&q,4); } db_finalize(&q); fossil_print("%38s %10lld %10lld\n", "Total:", sumSz, sumLen); } /* ** 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(void){ char *zFilename; 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) " "VALUES(NULL, $uuid, $sz, NULL, $data)"); db_begin_transaction(); for(i=4; i<g.argc; i++){ int sz; blob_read_from_file(&content, g.argv[i]); |
︙ | ︙ | |||
252 253 254 255 256 257 258 | void bundle_cmd(void){ const char *zSubcmd; const char *zBundleFile; int n; if( g.argc<4 ) usage("SUBCOMMAND BUNDLE ?ARGUMENTS?"); zSubcmd = g.argv[2]; db_find_and_open_repository(0,0); | < < | 283 284 285 286 287 288 289 290 291 292 293 294 295 296 | void bundle_cmd(void){ const char *zSubcmd; const char *zBundleFile; int n; if( g.argc<4 ) usage("SUBCOMMAND BUNDLE ?ARGUMENTS?"); zSubcmd = g.argv[2]; db_find_and_open_repository(0,0); n = (int)strlen(zSubcmd); if( strncmp(zSubcmd, "export", n)==0 ){ fossil_print("Not yet implemented...\n"); }else if( strncmp(zSubcmd, "import", n)==0 ){ fossil_print("Not yet implemented...\n"); }else if( strncmp(zSubcmd, "ls", n)==0 ){ bundle_ls(); |
︙ | ︙ |