[fossil-users] Finding out whether a file needs an update in C
Not sure whether last night's post made it - it isn't there on the archives. I need help with one thing. How can I figure out if a file needs an update (meaning it has been updated in the repository, but the version in the current dir is old). db_blob(&uuid,"SELECT uuid FROM blob, mlink, vfile WHERE " "blob.rid = mlink.mid AND mlink.fid = vfile.rid AND " "vfile.pathname=%B",&fname); db_blob(&latest, "SELECT ci.uuid FROM mlink, blob b, event, blob ci" " WHERE mlink.fnid=(SELECT fnid FROM filename WHERE name=%B)" " AND b.rid=mlink.fid AND event.objid=mlink.mid" " AND event.objid=ci.rid ORDER BY event.mtime DESC", &fname); isLatest = strcmp(blob_str(&latest),blob_str(&uuid)) == 0; That works most of the time, but is wrong. e.g. on the latest fossil tree, www/delta1.gif shows up as isLatest == 0. I don't understand the schema well enough. Anybody have ideas? Thanks - Venkat Here's the first version (2009-10-29). I hope this mailing list allows attachments. I haven't quite figured out the meanings of the tables in the schema, so have mostly done a cut and paste. The zip has 2 file in it: 1. info.c.diffs (these are diffs into src/info.c), there's a new subcommand finfo. See the comment at the beginning of the function. Apply the patch, and build fossil. 2. vc-fossil.el, follow instructions on the top of the file to install. I've tested it on a small project, and the basic vc-actions are fine. There are a few things that I'd like help with. 3. The "latest" detection in the "-s" branch is hosed. I don't understand enough of the schema to make it work always. It seems to work most of the time now. Search for "db_blob(&latest," in the patch. 4. I'm not at all sure that I'm handing branches right. I hope that this will provide a starting point for this effort. I will continue to improve it as I can. It will definitely help me promote fossil internally, as we use emacs heavily. ___ fossil-users mailing list fossil-users@lists.fossil-scm.org http://lists.fossil-scm.org:8080/cgi-bin/mailman/listinfo/fossil-users
Re: [fossil-users] Finding out whether a file needs an update in C
This was probably a stupid question. What I really wanted to know was - will the file change if I do a "fossil update". I now have a newer version of emacs integration done. Much thanks to drh for the finfo changes in the tree. My zip from last time doesn't seem to have made it. I'm attaching files inline. Here are the fossil related changes: 1. fossil finfo -b|--brief gives a brief (one line per revision, and it prints revision numbers). The revision numbers are checkin-numbers. 2. fossil finfo -s|--status prints the edited state and the (checkin) revision numbers. 3. fossil finfo -p|--print -r|--revision . Prints the file from the specified (checkin) revision number. 4. fossil update --local, does a local update without an autosync, even if autosync was turned on. 5. fossil update -n|--nochange, goes through the update process (syncing if --local was not specified), but does not change any checked out file. It prints out the actions it would do if -n was not specified 6. fossil update -v|--verbose, prints messages to stdout for unchanged/edited files The vc-fossil.el included here uses fossil finfo -l -b fossil finfo -s fossil finfo -p -r fossil update --local -n -v fossil diff -r first below is fossil diff of my clone, after 3.6.20 sqlite3 upgrade. I have merged in drh's changes from this weekend. second is the current vc-fossil.el. There must be a better way to submit patches, but I don't know about it yet. If it makes sense, I'd suggest adding vc-fossil.el as a new file to the repository. Thanks - Venkat Index: src/finfo.c === fossil diff /proj/baliva/users/venkat/fossil/tool/head/fossil/src/finfo.c --- src/finfo.c +++ src/finfo.c @@ -27,71 +27,165 @@ #include "finfo.h" /* ** COMMAND: finfo ** -** Usage: %fossil finfo FILENAME +** Usage: %fossil finfo -l|--log ?-b|--brief? FILENAME / -s|--status FILENAME / -p|--print ?-r|--revision REV?FILENAME ** -** Print the change history for a single file. +** Print the complete change history for a single file going backwards +** in time. If -l is specified the full comment is printed, otherwise +** one line is printed per revision. ** ** The "--limit N" and "--offset P" options limits the output to the first ** N changes after skipping P changes. +** +** In the -s form prints the status as +** +** In the -p form prints to stdout the revision of the file specified by REV +** */ + void finfo_cmd(void){ - Stmt q; - int vid; - Blob dest; - const char *zFilename; - const char *zLimit; - const char *zOffset; - int iLimit, iOffset; + int vid; db_must_be_within_tree(); vid = db_lget_int("checkout", 0); if( vid==0 ){ fossil_panic("no checkout to finfo files in"); } - zLimit = find_option("limit",0,1); - iLimit = zLimit ? atoi(zLimit) : -1; - zOffset = find_option("offset",0,1); - iOffset = zOffset ? atoi(zOffset) : 0; - if (g.argc<3) { -usage("FILENAME"); - } - file_tree_name(g.argv[2], &dest, 1); - zFilename = blob_str(&dest); - db_prepare(&q, -"SELECT b.uuid, ci.uuid, date(event.mtime,'localtime')," -" coalesce(event.ecomment, event.comment)," -" coalesce(event.euser, event.user)" -" FROM mlink, blob b, event, blob ci" -" WHERE mlink.fnid=(SELECT fnid FROM filename WHERE name=%Q)" -" AND b.rid=mlink.fid" -" AND event.objid=mlink.mid" -" AND event.objid=ci.rid" -" ORDER BY event.mtime DESC LIMIT %d OFFSET %d", -zFilename, iLimit, iOffset - ); + vfile_check_signature(vid); + if (find_option("status","s",0)) { + Stmt q; + Blob line; + Blob fname; + + if (g.argc != 3) { + usage("-s|--status FILENAME"); + } + file_tree_name(g.argv[2], &fname, 1); + db_prepare(&q, +"SELECT pathname, deleted, rid, chnged, coalesce(origname!=pathname,0)" +" FROM vfile WHERE vfile.pathname=%B", &fname); + blob_zero(&line); + if ( db_step(&q)==SQLITE_ROW ) { + Blob uuid; + int isDeleted = db_column_int(&q, 1); + int isNew = db_column_int(&q,2) == 0; + int chnged = db_column_int(&q,3); + int renamed = db_column_int(&q,4); + + blob_zero(&uuid); + db_blob(&uuid,"SELECT uuid FROM blob, mlink, vfile WHERE " + "blob.rid = mlink.mid AND mlink.fid = vfile.rid AND " + "vfile.pathname=%B",&fname); + if (isNew) { + blob_appendf(&line, "new"); + } else if (isDeleted) { + blob_appendf(&line, "deleted"); + } else if (renamed) { + blob_appendf(&line, "renamed"); + } else if (chnged) { + blob_appendf(&line, "edited"); + } else { + blob_appendf(&line, "unchanged"); + } + blob_appendf(&line, " "); + blob_appendf(&line, " %10.10s", blob_str(&uuid)); +
Re: [fossil-users] Finding out whether a file needs an update in C
I needed to add one more flag. --file to update, so that I could get the update status quickly for a single file. The changes to the function as below. I had to make the corresponding changes to vc-fossil.el as well. I'm done for now, I have the "minimal" frequently used functions working satisfactorily for vc mode to be usable with fossil. - Venkat + const char *zFile;/* Name of file to update */ Blob fname; ... localFlag = find_option("local", 0,0) != 0; + zFile = find_option("file",0,1); + if (zFile != 0) { + file_tree_name(zFile, &fname, 1); + } ... db_finalize(&q); + if (zFile != 0) { + db_multi_exec("DELETE FROM fv WHERE fn <> %B", &fname); + } + db_prepare(&q, "SELECT fn, idv, ridv, idt, ridt, chnged FROM fv ORDER BY 1" ); (defun vc-fossil-state (file) "Fossil specific version of `vc-state'." (let ((state (vc-fossil-filestr file "update" "-n" "-v" "--local" "--file"))) (setq status-word (car (split-string state))) (if (not status-word) nil (cond ((string= status-word "UNCHANGED") 'up-to-date) ((or (string= status-word "EDITED") (string= status-word "CONFLICT") (string= status-word "ADDED") (string= status-word "REMOVE")) 'edited) ((string= status-word "UPDATE") 'needs-patch) ((string= status-word "MERGE") 'needs-merge) ((string= status-word "UNKNOWN") nil) -Original Message- From: Venkat Iyer Sent: Sunday, November 1, 2009 15:27:37 Subject: Re: [fossil-users] Finding out whether a file needs an update in C This was probably a stupid question. What I really wanted to know was - will the file change if I do a "fossil update". I now have a newer version of emacs integration done. Much thanks to drh for the finfo changes in the tree. My zip from last time doesn't seem to have made it. I'm attaching files inline. Here are the fossil related changes: 1. fossil finfo -b|--brief gives a brief (one line per revision, and it prints revision numbers). The revision numbers are checkin-numbers. 2. fossil finfo -s|--status prints the edited state and the (checkin) revision numbers. 3. fossil finfo -p|--print -r|--revision . Prints the file from the specified (checkin) revision number. 4. fossil update --local, does a local update without an autosync, even if autosync was turned on. 5. fossil update -n|--nochange, goes through the update process (syncing if --local was not specified), but does not change any checked out file. It prints out the actions it would do if -n was not specified 6. fossil update -v|--verbose, prints messages to stdout for unchanged/edited files The vc-fossil.el included here uses fossil finfo -l -b fossil finfo -s fossil finfo -p -r fossil update --local -n -v fossil diff -r first below is fossil diff of my clone, after 3.6.20 sqlite3 upgrade. I have merged in drh's changes from this weekend. second is the current vc-fossil.el. There must be a better way to submit patches, but I don't know about it yet. If it makes sense, I'd suggest adding vc-fossil.el as a new file to the repository. Thanks - Venkat ___ fossil-users mailing list fossil-users@lists.fossil-scm.org http://lists.fossil-scm.org:8080/cgi-bin/mailman/listinfo/fossil-users