BARKS IN THE WIND

Modifying fossil to use for archival work

Posted on 2020-05-22 19:17 technotes

mtime_of_manifest_file is used to set the mtime from a handful of methods in fossil that are timestamp aware. the function looks up the file in the mlink table which i believe provides the link between EVENT table (i.e. repo history) and VFILE.

src/db.c:896:  int rc = mtime_of_manifest_file(sqlite3_value_int(argv[0]),

db_checkin_mtime_function which is linked to a sql helper function checkin_mtime. The function is documented in a handful of places, including help for sql command. checkin_mtime(X,Y) Return the mtime for the file Y (a BLOB.RID) found in check-in X (another BLOB.RID value).

src/file.c:2095:** mtime_of_manifest_file() is asked to provide the timestamp for a
src/file.c:2319:      if( newMtime || mtime_of_manifest_file(vid, fid, &newMtime)==0 ){
src/file.c:2364:        if(mtime_of_manifest_file( vid, fid, &newMtime )!=0){

The context of above is touch_cmd which knows how to set mtime using following options,

  --now          Stamp each affected file with the current time.
                 This is the default behavior.
  -c|--checkin   Stamp each affected file with the time of the
                 most recent check-in which modified that file.
  -C|--checkout  Stamp each affected file with the time of the
                 currently-checked-out version.
src/checkin.c:186:   * SQLite opcode.  checkin_mtime() calls mtime_of_manifest_file() which
src/vfile.c:249:      if( mtime_of_manifest_file(vid,rid,&desiredMtime)==0 ){

Above is part of vfile_check_signature, which the main function that figures out if the file has been changed in the working tree. It syncs the working tree against fossil's VFILE table. The table also keeps mtime's for the purposes of quickly figuring out what has changed.

The users of vfile_check_signature make particularly strong assumptions about the tie between checkin time and modification time e.g. fossil ls --age is described as Show when each file was committed. and is essentially equivalent to the following fossil sql,

select
pathname,
datetime(checkin_mtime((select value from vvar where name='checkout'), rid), 'unixepoch', toLocal())
from vfile

but of course before doing that sql fossil does vfile_check_signature to ensure that sql state reflects filesystem state.

create_manifest used from commit_cmd and manifest_parse

ref fossil hacker howto