Fossil

Diff
Login

Differences From Artifact [32323dc331]:

To Artifact [ca2d8a411f]:


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
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
109
110







-
+





+
+
+
+
+
+
+
+
+

-
+













-
+







-
+







}

/*
**  fossil bundle ls BUNDLE ?OPTIONS?
**
** Display the content of a bundle in human-readable form.
*/
static void bundle_ls(void){
static void bundle_ls_cmd(void){
  Stmt q;
  sqlite3_int64 sumSz = 0;
  sqlite3_int64 sumLen = 0;
  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);
  db_prepare(&q,
    "SELECT blobid, substr(uuid,1,16), coalesce(substr(delta,1,16),''),"
   "        sz, length(data)"
    "       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);
  fossil_print("%39s %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){
static void bundle_append_cmd(void){
  char *zFilename;
  Blob content, hash;
  int i;
  Stmt q;

  verify_all_options();
  bundle_attach_file(g.argv[3], "b1", 1);
179
180
181
182
183
184
185
186

187
188
189
190
191
192
193
188
189
190
191
192
193
194

195
196
197
198
199
200
201
202







-
+







        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))",
                        "    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*/);
  }
}
226
227
228
229
230
231
232









































233
234
235
236
237
238
239
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289







+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+







        db_column_int(&q, 2),
        db_column_text(&q, 0),
        db_column_text(&q, 1));
  }
  db_finalize(&q);
  db_end_transaction(1);
}

/* fossil bundle export BUNDLE ?OPTIONS?
**
** OPTIONS:
**   --branch BRANCH
**   --from TAG
**   --to TAG
**   --checkin TAG
*/
static void bundle_export_cmd(void){
  db_multi_exec("CREATE TEMP TABLE tobundle(rid INTEGER PRIMARY KEY);");
  subtree_from_arguments("tobundle");
  verify_all_options();
  bundle_attach_file(g.argv[3], "b1", 1);
  find_checkin_associates("tobundle");
  db_begin_transaction();
  db_multi_exec(
    "REPLACE INTO bblob(blobid,uuid,sz,delta,data) "
    " SELECT"
    "   tobundle.rid,"
    "   b1.uuid,"
    "   b1.size,"
    "   CASE WHEN delta.srcid NOT IN tobundle"
    "        THEN (SELECT uuid FROM blob WHERE rid=delta.srcid)"
    "        ELSE delta.srcid END,"
    "   b1.content"
    " FROM tobundle"
    "      JOIN blob AS b1 ON b1.rid=tobundle.rid"
    "      LEFT JOIN delta ON delta.rid=tobundle.rid"
  );
  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');"
  );
  db_end_transaction(0);
}

/*
** COMMAND: bundle
**
** Usage: %fossil bundle SUBCOMMAND ARGS...
**
**   fossil bundle export BUNDLE ?OPTIONS?
285
286
287
288
289
290
291
292

293
294
295
296

297
298

299
300
301
302
303
304
335
336
337
338
339
340
341

342
343
344
345

346
347

348
349
350
351
352
353
354







-
+



-
+

-
+






  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");
    bundle_export_cmd();
  }else if( strncmp(zSubcmd, "import", n)==0 ){
    fossil_print("Not yet implemented...\n");
  }else if( strncmp(zSubcmd, "ls", n)==0 ){
    bundle_ls();
    bundle_ls_cmd();
  }else if( strncmp(zSubcmd, "append", n)==0 ){
    bundle_append();
    bundle_append_cmd();
  }else if( strncmp(zSubcmd, "extract", n)==0 ){
    fossil_print("Not yet implemented...\n");
  }else{
    fossil_fatal("unknown subcommand for bundle: %s", zSubcmd);
  }
}