On Sun, 25 Nov, Jan Nijtmans wrote:

> Partly, "-f" already functions like that, although -f does more: It
> permits no-op commits as well.
> 
> >> I do not (yet) feel confident enough to propose code changes.
> 
> Maybe trying to implement a "unicode-glob" would be a
> good not-to-difficult first step. I would welcome that.

Attached you'll find a patch that adds the "unicode-glob" to the
settings and respects its setting in the check-in. Additionally I
disabled all the check-in warnings (crnl, binary and unicode) in case
--force/-f is set on commit.

Hope this quick and rough patch is of some value.

Greetings,
Stefan

-- 
Stefan Bellon
Index: src/checkin.c
==================================================================
--- src/checkin.c
+++ src/checkin.c
@@ -890,10 +890,11 @@
 */
 static void commit_warning(
   const Blob *p,        /* The content of the file being committed. */
   int crnlOk,           /* Non-zero if CR/NL warnings should be disabled. */
   int binOk,            /* Non-zero if binary warnings should be disabled. */
+  int unicodeOk,        /* Non-zero if unicode warnings should be disabled. */
   const char *zFilename /* The full name of the file being committed. */
 ){
   int eType;              /* return value of looks_like_utf8/utf16() */
   int fUnicode;           /* return value of starts_with_utf16_bom() */
   char *zMsg;             /* Warning message */
@@ -907,10 +908,13 @@
     const char *zWarning;
     Blob ans;
     char cReply;
 
     if( eType==-1 && fUnicode ){
+      if ( unicodeOk ){
+        return; /* We don't want unicode warnings for this file. */
+      }
       zWarning = "Unicode and CR/NL line endings";
     }else if( eType==-1 ){
       if( crnlOk ){
         return; /* We don't want CR/NL warnings for this file. */
       }
@@ -919,10 +923,13 @@
       if( binOk ){
         return; /* We don't want binary warnings for this file. */
       }
       zWarning = "binary data";
     }else{
+      if ( unicodeOk ){
+        return; /* We don't want unicode warnings for this file. */
+      }
       zWarning = "Unicode";
     }
     file_relative_name(zFilename, &fname, 0);
     blob_zero(&ans);
     zMsg = mprintf(
@@ -1251,36 +1258,42 @@
   /* Step 1: Insert records for all modified files into the blob
   ** table. If there were arguments passed to this command, only
   ** the identified files are inserted (if they have been modified).
   */
   db_prepare(&q,
-    "SELECT id, %Q || pathname, mrid, %s, chnged, %s FROM vfile "
+    "SELECT id, %Q || pathname, mrid, %s, chnged, %s, %s FROM vfile "
     "WHERE chnged==1 AND NOT deleted AND is_selected(id)",
-    g.zLocalRoot, glob_expr("pathname", db_get("crnl-glob","")),
-    glob_expr("pathname", db_get("binary-glob",""))
+    g.zLocalRoot,
+    glob_expr("pathname", db_get("crnl-glob","")),
+    glob_expr("pathname", db_get("binary-glob","")),
+    glob_expr("pathname", db_get("unicode-glob",""))
   );
   while( db_step(&q)==SQLITE_ROW ){
     int id, rid;
     const char *zFullname;
     Blob content;
-    int crnlOk, binOk, chnged;
+    int crnlOk, binOk, unicodeOk, chnged;
 
     id = db_column_int(&q, 0);
     zFullname = db_column_text(&q, 1);
     rid = db_column_int(&q, 2);
     crnlOk = db_column_int(&q, 3);
     chnged = db_column_int(&q, 4);
     binOk = binaryOk || db_column_int(&q, 5);
+    unicodeOk = db_column_int(&q, 6);
 
     blob_zero(&content);
     if( file_wd_islink(zFullname) ){
       /* Instead of file content, put link destination path */
       blob_read_link(&content, zFullname);
     }else{
       blob_read_from_file(&content, zFullname);
     }
-    commit_warning(&content, crnlOk, binOk, zFullname);
+    if( !forceFlag ){
+      /* Do not emit any warnings in force mode. */
+      commit_warning(&content, crnlOk, binOk, unicodeOk, zFullname);
+    }
     if( chnged==1 && contains_merge_marker(&content) ){
       Blob fname; /* Relative pathname of the file */
 
       nConflict++;
       file_relative_name(zFullname, &fname, 0);

Index: src/configure.c
==================================================================
--- src/configure.c
+++ src/configure.c
@@ -103,10 +103,11 @@
   { "project-description",    CONFIGSET_PROJ },
   { "manifest",               CONFIGSET_PROJ },
   { "binary-glob",            CONFIGSET_PROJ },
   { "ignore-glob",            CONFIGSET_PROJ },
   { "crnl-glob",              CONFIGSET_PROJ },
+  { "unicode-glob",           CONFIGSET_PROJ },
   { "empty-dirs",             CONFIGSET_PROJ },
   { "allow-symlinks",         CONFIGSET_PROJ },
 
   { "ticket-table",           CONFIGSET_TKT  },
   { "ticket-common",          CONFIGSET_TKT  },

Index: src/db.c
==================================================================
--- src/db.c
+++ src/db.c
@@ -2085,10 +2085,11 @@
   { "th1-setup",     0,               40, 0, ""                    },
 #ifdef FOSSIL_ENABLE_TCL
   { "tcl",           0,                0, 0, "off"                 },
   { "tcl-setup",     0,               40, 0, ""                    },
 #endif
+  { "unicode-glob",  0,               40, 1, ""                    },
   { "web-browser",   0,               32, 0, ""                    },
   { "white-foreground", 0,             0, 0, "off"                 },
   { 0,0,0,0,0 }
 };
 
@@ -2262,10 +2263,14 @@
 **                     is empty and no extra setup is performed.
 **
 **    th1-setup        This is the setup script to be evaluated after creating
 **                     and initializing the TH1 interpreter.  By default, this
 **                     is empty and no extra setup is performed.
+**
+**    unicode-glob     The VALUE is a comma or newline-separated list of
+**     (versionable)   GLOB patterns of files that should not produce a Unicode
+**                     warning.  Set to "*" to disable Unicode checking.
 **
 **    web-browser      A shell command used to launch your preferred
 **                     web browser when given a URL as an argument.
 **                     Defaults to "start" on windows, "open" on Mac,
 **                     and "firefox" on Unix.

_______________________________________________
fossil-users mailing list
fossil-users@lists.fossil-scm.org
http://lists.fossil-scm.org:8080/cgi-bin/mailman/listinfo/fossil-users

Reply via email to