What makes me tick.

Friday, November 06, 2009

Mingw stat broken?

I had some unexplained failures in fossil-under-vc-under-dired on windows.  Finally tracked it down to the fact that file_isdir was failing under mingw.   For directory names including the trailing "/", stat does not set the ISDIR flag.  There's some on the topic in http://osdir.com/ml/bug-gnulib-gnu/2009-09/msg00153.html


 int file_isdir(const char *zFilename){
   struct stat buf;
+#ifdef __MINGW32__
+  /* mingw has a bug where a trailing slash causes ISDIR to be zero */
+  Blob  SaneName;
+
+  file_canonical_name(zFilename, &SaneName);
+  if( stat(blob_str(&SaneName), &buf)!=0 ){
+      blob_reset(&SaneName);
+      return 0;
+  }
+  blob_reset(&SaneName);
+#else
   if( stat(zFilename, &buf)!=0 ){
     return 0;
   }
+#endif
   return S_ISDIR(buf.st_mode) ? 1 : 2;
 }

Wednesday, November 04, 2009

Incremental Changes in Fossil-SCM Integration into Emacs

The --local flag was probably a bad idea.  So it's gone.  Now -n|--nochange implies that autosync is not performed.   Something else broke everything.  The file_tree_name errors out if the name of the directory which is the root of the checkout is passed in as the filename.  Here's the mod to make it return an empty
string if the root is passed in.  Without this, the call to get the tree at the root would fail with a "out of checkout tree" message.

--- src/file.c
+++ src/file.c
@@ -356,23 +356,26 @@
 ** false, then simply return 0.
 **
 ** The root of the tree is defined by the g.zLocalRoot variable.
 */
 int file_tree_name(const char *zOrigName, Blob *pOut, int errFatal){
-  int n;
+  int m,n;
   Blob full;
   db_must_be_within_tree();
   file_canonical_name(zOrigName, &full);
   n = strlen(g.zLocalRoot);
-  if( blob_size(&full)<=n || memcmp(g.zLocalRoot, blob_buffer(&full), n) ){
+  m = blob_size(&full);
+  if( m
     blob_reset(&full);
     if( errFatal ){
       fossil_fatal("file outside of checkout tree: %s", zOrigName);
     }
     return 0;
   }
   blob_zero(pOut);
+  if (m == n - 1)
+      return 1;
   blob_append(pOut, blob_buffer(&full)+n, blob_size(&full)-n);
   return 1;
 }

 

Monday, November 02, 2009

Providing vc-dir-state from vc-fossil.el

Since then I did a bunch of modifications.  What I didn't like at all was the total hack that needs-merge and needs-patch turned out to be.   After posting a stupid question on fossil-users, I realized what I really wanted was to know if the file would update if the fossil update command was invoked.  So I changed vc-fossil-state to use update.   Also added a vc-fossil-dir-state to make the VC under dired go a lot faster.

Found out last night that the vc-*-dir-state is called for every directory in the tree and is expected to return the status for only the files in that dir, not for the subdirs.

So I changed the update command to add these flags.

  • -n | --nochange : do not change any files, but go through the motions.
  • --local                : do not autosync even if autosync is on in the settings
  • -v                       : verbose, print messages even for UNCHANGED and EDITED
  • --file name       : only print status for file name.  If name is a directory, print status for files in that directory, but not for subdirectories.

Now C-x v d on the fossil tree takes a few seconds.   There's more speedup that can be done in update.c to filter out the subset earlier in the function if the --file flag is specified.

Followers