At 12:45 PM 3/10/2010, Matt wrote:
>I would like to know how to export a repo from commandline
>recognizing there's a "Zip archive" option using "fossil ui".
>
>Is there something simliar in fossil like "git archive"?

Almost.

There is the nearly undocumented test command "fossil
test-baseline-zip" which takes a version and file name and writes
an archive that is similar to (but not identical to) the one
available from the web interface. The largest difference is that
it uses the exact text of the version string named on the command
line to name the top folder inside the zip file, whereas the web
names the top folder after the project name and the 10-digit prefix
of the version number.

I've attached a patch that adds a new "fossil zip" command that
makes archives that match the web interface. In particular, it can
generate a zip file that is identical to the one available from
the web.

Note that it works for me here, but I may have missed something
critical as I'm not expert on the innards of fossil.

I'd be happy to see it (or something like it) make it into the
official sources since it seems like a useful feature and clearly
didn't take very much code to implement.

Ross Berteig                               [email protected]
Cheshire Engineering Corp.           http://www.CheshireEng.com/
--- src/zip.c
+++ src/zip.c
@@ -392,10 +392,38 @@
   }
   db_must_be_within_tree();
   rid = name_to_rid(g.argv[2]);
   zip_of_baseline(rid, &zip, g.argv[2]);
   blob_write_to_file(&zip, g.argv[3]);
+}
+
+/*
+** COMMAND: zip
+**
+** Usage: %fossil zip VERSION ZIPFILE
+**
+** Generate a ZIP archive similar to that available through the web ui
+** for a specified version, and write it to the named file.
+*/
+void zip_cmd(void){
+    int rid;
+    Blob zip;
+    char *zUuid, *zName;
+    if( g.argc!=4 ){
+       usage("VERSION ZIPFILE");
+    }
+    db_must_be_within_tree();
+    rid = name_to_rid(g.argv[2]);
+    zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid);
+    if( rid==0 || !zUuid){
+       fossil_panic("no such object: %s\n", g.argv[2]);
+    }
+    zName = mprintf("%s-%.10s", db_get("project-name", "unnamed"), zUuid);
+    zip_of_baseline(rid, &zip, zName);
+    free(zName);
+    free(zUuid);
+    blob_write_to_file(&zip, g.argv[3]);
 }
 
 /*
 ** WEBPAGE: zip
 ** URL: /zip/RID.zip

_______________________________________________
fossil-users mailing list
[email protected]
http://lists.fossil-scm.org:8080/cgi-bin/mailman/listinfo/fossil-users

Reply via email to