feature request: switch of archive timestamp , baseline or commit times.

Hello. 

I need file commit date in the archive output.

I do not know the inside of fossil and sqlite because it is a few days I 
started to use fossil.
This code may be wrong, but I can be changed by this way.


Thank you.


Index: src/setup.c
==================================================================
--- src/setup.c
+++ src/setup.c
@@ -1545,10 +1545,15 @@
   @ <p>This is used as a prefix on the names of generated tarballs and ZIP 
archive.
   @ For best results, keep this prefix brief and avoid special characters such
   @ as "/" and "\".
   @ If no tarball prefix is specified, then the full Project Name above is 
used.
   @ </p>
+  @ <hr />
+  onoff_attribute("archive: file timestamp use last committed timestamps",
+                  "archive-date-use-commit-times", 
"archive-date-use-commit-times", 0, 0);
+  @ <p>archive use the file commit time. not use baseline commit time.
+  @ </p>
   @ <hr />
   onoff_attribute("Enable WYSIWYG Wiki Editing",
                   "wysiwyg-wiki", "wysiwyg-wiki", 0, 0);
   @ <p>Enable what-you-see-is-what-you-get (WYSIWYG) editing of wiki pages.
   @ The WYSIWYG editor generates HTML instead of markup, which makes

Index: src/tar.c
==================================================================
--- src/tar.c
+++ src/tar.c
@@ -470,10 +470,15 @@
   ManifestFile *pFile;
   Blob filename;
   int nPrefix;
   char *zName;
   unsigned int mTime;
+  int is_use_commit_times = 0;
+
+  if( db_get_int("archive-date-use-commit-times", 0) ){
+    is_use_commit_times = 1;
+  }
 
   content_get(rid, &mfile);
   if( blob_size(&mfile)==0 ){
     blob_zero(pTar);
     return;
@@ -502,22 +507,39 @@
       blob_append(&filename, "manifest.uuid", -1);
       zName = blob_str(&filename);
       tar_add_file(zName, &hash, 0, mTime);
       blob_reset(&hash);
     }
+    Stmt q = empty_Stmt;
+    if( is_use_commit_times ){
+      compute_fileage(rid, 0);
+      db_prepare_ignore_error(&q, "SELECT mtime FROM fileage WHERE fid=:r");
+    }
     manifest_file_rewind(pManifest);
     while( (pFile = manifest_file_next(pManifest,0))!=0 ){
       int fid = uuid_to_rid(pFile->zUuid, 0);
       if( fid ){
+        if( is_use_commit_times && q.pStmt ){
+          mTime = (pManifest->rDate - 2440587.5)*86400.0;
+          db_bind_int(&q, ":r", fid);
+          if( db_step(&q)==SQLITE_ROW ){
+            mTime = (db_column_double(&q,0) - 2440587.5)*86400.0;
+          }
+          db_reset(&q);
+          sqlite3_clear_bindings(q.pStmt);
+        }
         content_get(fid, &file);
         blob_resize(&filename, nPrefix);
         blob_append(&filename, pFile->zName, -1);
         zName = blob_str(&filename);
         tar_add_file(zName, &file, manifest_file_mperm(pFile), mTime);
         blob_reset(&file);
       }
     }
+    if( q.pStmt ){
+      db_finalize(&q);
+    }
   }else{
     sha1sum_blob(&mfile, &hash);
     blob_append(&filename, blob_str(&hash), 16);
     zName = blob_str(&filename);
     mTime = db_int64(0, "SELECT (julianday('now') -  2440587.5)*86400.0;");

Index: src/zip.c
==================================================================
--- src/zip.c
+++ src/zip.c
@@ -327,10 +327,15 @@
   Blob mfile, hash, file;
   Manifest *pManifest;
   ManifestFile *pFile;
   Blob filename;
   int nPrefix;
+  int is_use_commit_times = 0;
+
+  if( db_get_int("archive-date-use-commit-times", 0) ){
+    is_use_commit_times = 1;
+  }
 
   content_get(rid, &mfile);
   if( blob_size(&mfile)==0 ){
     blob_zero(pZip);
     return;
@@ -361,23 +366,41 @@
       blob_append(&filename, "manifest.uuid", -1);
       zName = blob_str(&filename);
       zip_add_file(zName, &hash, 0);
       blob_reset(&hash);
     }
+    Stmt q = empty_Stmt;
+    if( is_use_commit_times ){
+      compute_fileage(rid, 0);
+      db_prepare_ignore_error(&q, "SELECT mtime FROM fileage WHERE fid=:r");
+    }
     manifest_file_rewind(pManifest);
     while( (pFile = manifest_file_next(pManifest,0))!=0 ){
       int fid = uuid_to_rid(pFile->zUuid, 0);
       if( fid ){
+        if( is_use_commit_times && q.pStmt ){
+          double mtime = pManifest->rDate;
+          db_bind_int(&q, ":r", fid);
+          if( db_step(&q)==SQLITE_ROW ){
+            mtime = db_column_double(&q,0);
+          }
+          db_reset(&q);
+          sqlite3_clear_bindings(q.pStmt);
+          zip_set_timedate(mtime);
+        }
         content_get(fid, &file);
         blob_resize(&filename, nPrefix);
         blob_append(&filename, pFile->zName, -1);
         zName = blob_str(&filename);
         zip_add_folders(zName);
         zip_add_file(zName, &file, manifest_file_mperm(pFile));
         blob_reset(&file);
       }
     }
+    if( q.pStmt ){
+      db_finalize(&q);
+    }
   }else{
     blob_reset(&mfile);
   }
   manifest_destroy(pManifest);
   blob_reset(&filename);

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

Reply via email to