On Sat, Feb 11, 2012 at 7:55 AM, frantisek holop <[email protected]> wrote:
>
> any interest in this simple patch?
>
I think the proposed behavior is a good way to go.
> hmm, on Tue, Feb 07, 2012 at 07:48:30PM +0100, frantisek holop said that
> > hi there,
> >
> > the motivation for this patch was that the zip and tarball links
> > from the web ui get a filename and checkout "for free", while they
> > are a mandatory parameters for the command line.
> >
> > so i tried to unify it a bit: the default archive name is now both
> > from web and cli the same, a lowercased project name followed by the
> > artifact ID. spaces are substituted with '-'.
> >
> > $ fossil zip
> > fossil-030035345c.zip: 2944427 bytes
> >
> > $ fossil zip tip
> > fossil-030035345c.zip: 2944427 bytes
> >
> > $ fossil zip -o f.zip
> > f.zip: 2944427 bytes
> >
> > $ fossil zip -o f.zip tip
> > f.zip: 2944427 bytes
> >
> > $ fossil tar
> > fossil-030035345c.tgz: 2944427 bytes
> >
> > $ fossil tar tip
> > fossil-030035345c.tgz: 2944427 bytes
> >
> > $ fossil tar -o f.tgz
> > f.zip: 2944427 bytes
> >
> > $ fossil tar -o f.tgz tip
> > f.zip: 2944427 bytes
> >
> >
> > $ fossil help zip
> > Usage: fossil zip [--name DIRECTORY] [-o OUTPUTFILE]
> > [-R REPOSITORY] [VERSION]
> >
> > Generate a ZIP archive containing VERSION of the checkout.
> > If VERSION is omitted, the current checkout is used.
> >
> > The name of the resulting archive can be set using the -o option,
> > otherwise it will be derived from the project name followed by the
> > check-in's artifact ID. Unless the --name option is specified, the
> > the top-level directory inside the archive will have the same name.
> >
> > Options:
> > --name DIRECTORY Name of the top-level directory inside
> > the archive.
> > -o OUTPUTFILE Name of the archive.
> > -R|--repository FILE Use the repository in FILE.
> >
> > See also: tarball
> >
> >
> >
> > --- src/info.c
> > +++ src/info.c
> > @@ -500,11 +500,18 @@
> > @ <td>%h(zUser) @ %h(zIpAddr) on %s(zDate)</td></tr>
> > }
> > db_finalize(&q);
> > }
> > if( g.perm.History ){
> > - const char *zProjName = db_get("project-name", "unnamed");
> > + char *zProjName = db_get("project-name", "unnamed");
> > + int i;
> > + for(i=0; i<strlen(zProjName); i++){
> > + zProjName[i] = fossil_tolower(zProjName[i]);
> > + if( zProjName[i]==' ' ){
> > + zProjName[i] = '-';
> > + }
> > + }
> > @ <tr><th>Timelines:</th><td>
> > @ <a href="%s(g.zTop)/timeline?f=%S(zUuid)">family</a>
> > if( zParent ){
> > @ | <a href="%s(g.zTop)/timeline?p=%S(zUuid)">ancestors</a>
> > }
> > @@ -526,16 +533,14 @@
> > @ </td></tr>
> > @ <tr><th>Other Links:</th>
> > @ <td>
> > @ <a href="%s(g.zTop)/dir?ci=%S(zUuid)">files</a>
> > if( g.perm.Zip ){
> > - char *zUrl = mprintf("%s/tarball/%s-%S.tar.gz?uuid=%s",
> > - g.zTop, zProjName, zUuid, zUuid);
> > - @ | <a href="%s(zUrl)">Tarball</a>
> > + @ | <a
> href="%s(g.zTop)/tarball/%s(zProjName)-%S(zUuid).tgz=%s(zUuid)">
> > + @ Tarball</a>
> > @ | <a
> href="%s(g.zTop)/zip/%s(zProjName)-%S(zUuid).zip?uuid=%s(zUuid)">
> > @ ZIP archive</a>
> > - fossil_free(zUrl);
> > }
> > @ | <a href="%s(g.zTop)/artifact/%S(zUuid)">manifest</a>
> > if( g.perm.Write ){
> > @ | <a href="%s(g.zTop)/ci_edit?r=%S(zUuid)">edit</a>
> > }
> >
> > --- src/tar.c
> > +++ src/tar.c
> > @@ -525,42 +525,63 @@
> > }
> >
> > /*
> > ** COMMAND: tarball*
> > **
> > -** Usage: %fossil tarball VERSION OUTPUTFILE [--name DIRECTORYNAME]
> [-R|--repository REPO]
> > +** Usage: %fossil tarball [--name DIRECTORY] [-o OUTPUTFILE]
> > +** [-R REPOSITORY] VERSION
> > +**
> > +** Generate a compressed tarball archive containing VERSION of the
> > +** project. If VERSION is omitted, the current checkout is used.
> > +**
> > +** The name of the resulting archive can be set using the -o option,
> > +** otherwise it will be derived from the project name followed by the
> > +** check-in's artifact ID. Unless the --name option is specified, the
> > +** the top-level directory inside the archive will have the same name.
> > +**
> > +** Options:
> > +** --name DIRECTORY Name of the top-level directory inside
> > +** the archive.
> > +** -o OUTPUTFILE Name of the archive.
> > +** -R|--repository FILE Use the repository in FILE.
> > **
> > -** Generate a compressed tarball for a specified version. If the --name
> > -** option is used, its argument becomes the name of the top-level
> directory
> > -** in the resulting tarball. If --name is omitted, the top-level
> directory
> > -** named is derived from the project name, the check-in date and time,
> and
> > -** the artifact ID of the check-in.
> > +** See also: zip
> > */
> > void tarball_cmd(void){
> > int rid;
> > Blob tarball;
> > const char *zName;
> > + const char *fName;
> > + int wrote;
> > zName = find_option("name", 0, 1);
> > + fName = find_option("o", "o", 1);
> > db_find_and_open_repository(0, 0);
> > - if( g.argc!=4 ){
> > - usage("VERSION OUTPUTFILE");
> > + if( g.argc!=2 && g.argc!=3 ){
> > + usage("[--name DIRECTORY] [-o OUTPUTFILE] [-R REPOSITORY]
> [VERSION]");
> > }
> > - rid = name_to_typed_rid(g.argv[2], "ci");
> > + if( g.argc==3 ){
> > + rid = name_to_typed_rid(g.argv[2], "ci");
> > + }else{
> > + rid = db_lget_int("checkout",0);
> > + }
> > if( zName==0 ){
> > - zName = db_text("default-name",
> > - "SELECT replace(%Q,' ','_') "
> > - " || strftime('_%%Y-%%m-%%d_%%H%%M%%S_', event.mtime) "
> > + zName = db_text("unnamed",
> > + "SELECT lower(replace(%Q,' ','-')) "
> > + " || '-' "
> > " || substr(blob.uuid, 1, 10)"
> > " FROM event, blob"
> > " WHERE event.objid=%d"
> > " AND blob.rid=%d",
> > db_get("project-name", "unnamed"), rid, rid
> > );
> > }
> > + if( fName==0 ){
> > + fName = mprintf("%s.tgz", zName);
> > + }
> > tarball_of_checkin(rid, &tarball, zName);
> > - blob_write_to_file(&tarball, g.argv[3]);
> > - blob_reset(&tarball);
> > + wrote = blob_write_to_file(&tarball, fName);
> > + fossil_print("%s: %d bytes\n", fName, wrote);
> > }
> >
> > /*
> > ** WEBPAGE: tarball
> > ** URL: /tarball/RID.tar.gz
> > @@ -578,16 +599,16 @@
> > if( !g.perm.Zip ){ login_needed(); return; }
> > zName = mprintf("%s", PD("name",""));
> > nName = strlen(zName);
> > zRid = mprintf("%s", PD("uuid",""));
> > nRid = strlen(zRid);
> > - if( nName>7 && fossil_strcmp(&zName[nName-7], ".tar.gz")==0 ){
> > - /* Special case: Remove the ".tar.gz" suffix. */
> > - nName -= 7;
> > + if( nName>4 && fossil_strcmp(&zName[nName-4], ".tgz")==0 ){
> > + /* Special case: Remove the ".tgz" suffix. */
> > + nName -= 4;
> > zName[nName] = 0;
> > }else{
> > - /* If the file suffix is not ".tar.gz" then just remove the
> > + /* If the file suffix is not ".tgz" then just remove the
> > ** suffix up to and including the last "." */
> > for(nName=strlen(zName)-1; nName>5; nName--){
> > if( zName[nName]=='.' ){
> > zName[nName] = 0;
> > break;
> >
> > --- src/zip.c
> > +++ src/zip.c
> > @@ -379,41 +379,63 @@
> > }
> >
> > /*
> > ** COMMAND: zip*
> > **
> > -** Usage: %fossil zip VERSION OUTPUTFILE [--name DIRECTORYNAME]
> [-R|--repository REPO]
> > +** Usage: %fossil zip [--name DIRECTORY] [-o OUTPUTFILE]
> > +** [-R REPOSITORY] [VERSION]
> > +**
> > +** Generate a ZIP archive containing VERSION of the checkout.
> > +** If VERSION is omitted, the current checkout is used.
> > +**
> > +** The name of the resulting archive can be set using the -o option,
> > +** otherwise it will be derived from the project name followed by the
> > +** check-in's artifact ID. Unless the --name option is specified, the
> > +** the top-level directory inside the archive will have the same name.
> > +**
> > +** Options:
> > +** --name DIRECTORY Name of the top-level directory inside
> > +** the archive.
> > +** -o OUTPUTFILE Name of the archive.
> > +** -R|--repository FILE Use the repository in FILE.
> > **
> > -** Generate a ZIP archive for a specified version. If the --name
> option is
> > -** used, it argument becomes the name of the top-level directory in the
> > -** resulting ZIP archive. If --name is omitted, the top-level directory
> > -** named is derived from the project name, the check-in date and time,
> and
> > -** the artifact ID of the check-in.
> > +** See also: tarball
> > */
> > void baseline_zip_cmd(void){
> > int rid;
> > Blob zip;
> > const char *zName;
> > + const char *fName;
> > + int wrote;
> > zName = find_option("name", 0, 1);
> > + fName = find_option("o", "o", 1);
> > db_find_and_open_repository(0, 0);
> > - if( g.argc!=4 ){
> > - usage("VERSION OUTPUTFILE");
> > + if( g.argc!=2 && g.argc!=3 ){
> > + usage("[--name DIRECTORY] [-o OUTPUTFILE] [-R REPOSITORY]
> [VERSION]");
> > }
> > - rid = name_to_typed_rid(g.argv[2],"ci");
> > + if( g.argc==3 ){
> > + rid = name_to_typed_rid(g.argv[2], "ci");
> > + }else{
> > + rid = db_lget_int("checkout",0);
> > + }
> > if( zName==0 ){
> > - zName = db_text("default-name",
> > - "SELECT replace(%Q,' ','_') "
> > - " || strftime('_%%Y-%%m-%%d_%%H%%M%%S_', event.mtime) "
> > + zName = db_text("unnamed",
> > + "SELECT lower(replace(%Q,' ','-')) "
> > + " || '-' "
> > " || substr(blob.uuid, 1, 10)"
> > " FROM event, blob"
> > " WHERE event.objid=%d"
> > " AND blob.rid=%d",
> > db_get("project-name", "unnamed"), rid, rid
> > );
> > }
> > + if( fName==0 ){
> > + fName = mprintf("%s.zip", zName);
> > + }
> > zip_of_baseline(rid, &zip, zName);
> > - blob_write_to_file(&zip, g.argv[3]);
> > + wrote = blob_write_to_file(&zip, fName);
> > + fossil_print("%s: %d bytes\n", fName, wrote);
> > }
> >
> > /*
> > ** WEBPAGE: zip
> > ** URL: /zip/RID.zip
> >
> >
> > --
> > Introibo ad altare Dei.
> > _______________________________________________
> > fossil-users mailing list
> > [email protected]
> > http://lists.fossil-scm.org:8080/cgi-bin/mailman/listinfo/fossil-users
>
> --
> the devil can cite scripture for his purpose.
> _______________________________________________
> fossil-users mailing list
> [email protected]
> http://lists.fossil-scm.org:8080/cgi-bin/mailman/listinfo/fossil-users
>
_______________________________________________
fossil-users mailing list
[email protected]
http://lists.fossil-scm.org:8080/cgi-bin/mailman/listinfo/fossil-users