Fossil SCM

Add a "zip" command for generating a ZIP archive of a check-in from the command-line.

drh 2010-03-11 03:29 trunk
Commit 2582ecf2edc2d0d9c5818dc481bc7b330381716d
1 file changed +24 -5
+24 -5
--- src/zip.c
+++ src/zip.c
@@ -378,23 +378,42 @@
378378
blob_reset(&filename);
379379
zip_close(pZip);
380380
}
381381
382382
/*
383
-** COMMAND: test-baseline-zip
383
+** COMMAND: zip
384
+**
385
+** Usage: %fossil zip VERSION OUTPUTFILE [--name DIRECTORYNAME]
384386
**
385
-** Generate a ZIP archive for a specified baseline.
387
+** Generate a ZIP archive for a specified version. If the --name option is
388
+** used, it argument becomes the name of the top-level directory in the
389
+** resulting ZIP archive. If --name is omitted, the top-level directory
390
+** named is derived from the project name, the check-in date and time, and
391
+** the artifact ID of the check-in.
386392
*/
387393
void baseline_zip_cmd(void){
388394
int rid;
389395
Blob zip;
396
+ const char *zName;
397
+ zName = find_option("name", 0, 1);
398
+ db_find_and_open_repository(1);
390399
if( g.argc!=4 ){
391
- usage("UUID ZIPFILE");
400
+ usage("VERSION OUTPUTFILE");
392401
}
393
- db_must_be_within_tree();
394402
rid = name_to_rid(g.argv[2]);
395
- zip_of_baseline(rid, &zip, g.argv[2]);
403
+ if( zName==0 ){
404
+ zName = db_text("default-name",
405
+ "SELECT replace(%Q,' ','_') "
406
+ " || strftime('_%%Y-%%m-%%d_%%H%%M%%S_', event.mtime) "
407
+ " || substr(blob.uuid, 1, 10)"
408
+ " FROM event, blob"
409
+ " WHERE event.objid=%d"
410
+ " AND blob.rid=%d",
411
+ db_get("project-name", "unnamed"), rid, rid
412
+ );
413
+ }
414
+ zip_of_baseline(rid, &zip, zName);
396415
blob_write_to_file(&zip, g.argv[3]);
397416
}
398417
399418
/*
400419
** WEBPAGE: zip
401420
--- src/zip.c
+++ src/zip.c
@@ -378,23 +378,42 @@
378 blob_reset(&filename);
379 zip_close(pZip);
380 }
381
382 /*
383 ** COMMAND: test-baseline-zip
 
 
384 **
385 ** Generate a ZIP archive for a specified baseline.
 
 
 
 
386 */
387 void baseline_zip_cmd(void){
388 int rid;
389 Blob zip;
 
 
 
390 if( g.argc!=4 ){
391 usage("UUID ZIPFILE");
392 }
393 db_must_be_within_tree();
394 rid = name_to_rid(g.argv[2]);
395 zip_of_baseline(rid, &zip, g.argv[2]);
 
 
 
 
 
 
 
 
 
 
 
396 blob_write_to_file(&zip, g.argv[3]);
397 }
398
399 /*
400 ** WEBPAGE: zip
401
--- src/zip.c
+++ src/zip.c
@@ -378,23 +378,42 @@
378 blob_reset(&filename);
379 zip_close(pZip);
380 }
381
382 /*
383 ** COMMAND: zip
384 **
385 ** Usage: %fossil zip VERSION OUTPUTFILE [--name DIRECTORYNAME]
386 **
387 ** Generate a ZIP archive for a specified version. If the --name option is
388 ** used, it argument becomes the name of the top-level directory in the
389 ** resulting ZIP archive. If --name is omitted, the top-level directory
390 ** named is derived from the project name, the check-in date and time, and
391 ** the artifact ID of the check-in.
392 */
393 void baseline_zip_cmd(void){
394 int rid;
395 Blob zip;
396 const char *zName;
397 zName = find_option("name", 0, 1);
398 db_find_and_open_repository(1);
399 if( g.argc!=4 ){
400 usage("VERSION OUTPUTFILE");
401 }
 
402 rid = name_to_rid(g.argv[2]);
403 if( zName==0 ){
404 zName = db_text("default-name",
405 "SELECT replace(%Q,' ','_') "
406 " || strftime('_%%Y-%%m-%%d_%%H%%M%%S_', event.mtime) "
407 " || substr(blob.uuid, 1, 10)"
408 " FROM event, blob"
409 " WHERE event.objid=%d"
410 " AND blob.rid=%d",
411 db_get("project-name", "unnamed"), rid, rid
412 );
413 }
414 zip_of_baseline(rid, &zip, zName);
415 blob_write_to_file(&zip, g.argv[3]);
416 }
417
418 /*
419 ** WEBPAGE: zip
420

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button