[Unison-hackers] [unison-svn] r380 - in branches/2.27/src: . ubase

vouillon@seas.upenn.edu vouillon at seas.upenn.edu
Tue Jul 21 09:10:32 EDT 2009


Author: vouillon
Date: 2009-07-21 09:10:32 -0400 (Tue, 21 Jul 2009)
New Revision: 380

Modified:
   branches/2.27/src/RECENTNEWS
   branches/2.27/src/mkProjectInfo.ml
   branches/2.27/src/os.ml
   branches/2.27/src/ubase/prefs.ml
   branches/2.27/src/ubase/trace.ml
   branches/2.27/src/ubase/util.ml
   branches/2.27/src/ubase/util.mli
   branches/2.27/src/uitext.ml
Log:
Backport to stable release:
* Truncate temporary filenames to remain under system limits.
* Fix include directive failure when the line ends by CRLF
  (the CR was not removed)
* Ignore errors when writing to the log file
* Do not print the "Connected" message when the preference "silent" is set.
* Print a warning when running "unison -ui graphic" with a text-only
  build of Unison


Modified: branches/2.27/src/RECENTNEWS
===================================================================
--- branches/2.27/src/RECENTNEWS	2009-07-21 13:06:29 UTC (rev 379)
+++ branches/2.27/src/RECENTNEWS	2009-07-21 13:10:32 UTC (rev 380)
@@ -1,3 +1,15 @@
+CHANGES FROM VERSION 2.27.157
+
+Backport to stable release:
+* Truncate temporary filenames to remain under system limits.
+* Fix include directive failure when the line ends by CRLF
+  (the CR was not removed)
+* Ignore errors when writing to the log file
+* Do not print the "Connected" message when the preference "silent" is set.
+* Print a warning when running "unison -ui graphic" with a text-only
+  build of Unison
+
+-------------------------------
 CHANGES FROM VERSION 2.27.156
 
 * Tweak

Modified: branches/2.27/src/mkProjectInfo.ml
===================================================================
--- branches/2.27/src/mkProjectInfo.ml	2009-07-21 13:06:29 UTC (rev 379)
+++ branches/2.27/src/mkProjectInfo.ml	2009-07-21 13:10:32 UTC (rev 380)
@@ -84,3 +84,4 @@
 
 
 
+

Modified: branches/2.27/src/os.ml
===================================================================
--- branches/2.27/src/os.ml	2009-07-21 13:06:29 UTC (rev 379)
+++ branches/2.27/src/os.ml	2009-07-21 13:10:32 UTC (rev 380)
@@ -285,6 +285,14 @@
 (*                           TEMPORARY FILES                                 *)
 (*****************************************************************************)
 
+(* Truncate a filename to at most [l] bytes, making sure of not
+   truncating an UTF-8 character *)
+let rec truncate_filename s l =
+  if l >= 0 && Char.code s.[l] land 0xC0 = 0x80 then
+    truncate_filename s (l - 1)
+  else
+    String.sub s 0 l
+
 (* Generates an unused fspath for a temporary file.                          *)
 let freshPath fspath path prefix suffix =
   let rec f i =
@@ -292,9 +300,19 @@
       if i=0 then suffix
       else Printf.sprintf "..%03d.%s" i suffix in
     let tempPath =
-      Path.addPrefixToFinalName
-        (Path.addSuffixToFinalName path s)
-        prefix
+      match Path.deconstructRev path with
+        None ->
+          assert false
+      | Some (name, parentPath) ->
+          let name = Name.toString name in
+          let len = String.length name in
+          let maxlen = 64 in
+          let name =
+            if len <= maxlen then name else
+            (truncate_filename name maxlen ^
+             Digest.to_hex (Digest.string name))
+          in
+          Path.child parentPath (Name.fromString (prefix ^ name ^ s))
     in
     if exists fspath tempPath then f (i + 1) else tempPath
   in f 0

Modified: branches/2.27/src/ubase/prefs.ml
===================================================================
--- branches/2.27/src/ubase/prefs.ml	2009-07-21 13:06:29 UTC (rev 379)
+++ branches/2.27/src/ubase/prefs.ml	2009-07-21 13:10:32 UTC (rev 380)
@@ -254,6 +254,7 @@
     match lines with
       [] -> res
     | theLine :: rest ->
+        let theLine = Util.removeTrailingCR theLine in
         let l = Util.trimWhitespace theLine in
         if l = "" || l.[0]='#' then
           loop rest (lineNum+1) res

Modified: branches/2.27/src/ubase/trace.ml
===================================================================
--- branches/2.27/src/ubase/trace.ml	2009-07-21 13:06:29 UTC (rev 379)
+++ branches/2.27/src/ubase/trace.ml	2009-07-21 13:10:32 UTC (rev 380)
@@ -136,8 +136,10 @@
       | `FormatStdout -> Format.printf "%s " s);
   if Prefs.read logging then begin
     let ch = getLogch() in
-    output_string ch s;
-    flush ch
+    begin try
+      output_string ch s;
+      flush ch
+    with Sys_error _ -> () end
   end
 
 (* ---------------------------------------------------------------------- *)

Modified: branches/2.27/src/ubase/util.ml
===================================================================
--- branches/2.27/src/ubase/util.ml	2009-07-21 13:06:29 UTC (rev 379)
+++ branches/2.27/src/ubase/util.ml	2009-07-21 13:10:32 UTC (rev 380)
@@ -372,6 +372,11 @@
 let concatmap sep f l =
   String.concat sep (Safelist.map f l)
 
+let removeTrailingCR s =
+  let l = String.length s in
+  if l = 0 || s.[l - 1] <> '\r' then s else
+  String.sub s 0 (l - 1)
+
 let rec trimWhitespace s =
   let l = String.length s in
   if l=0 then s

Modified: branches/2.27/src/ubase/util.mli
===================================================================
--- branches/2.27/src/ubase/util.mli	2009-07-21 13:06:29 UTC (rev 379)
+++ branches/2.27/src/ubase/util.mli	2009-07-21 13:10:32 UTC (rev 380)
@@ -53,6 +53,7 @@
 val replacesubstring : string -> string -> string -> string (* IN,FROM,TO *)
 val replacesubstrings : string -> (string * string) list -> string
 val concatmap : string -> ('a -> string) -> 'a list -> string
+val removeTrailingCR : string -> string
 val trimWhitespace : string -> string
 val splitIntoWords : string -> char -> string list
 val splitIntoWordsByString : string -> string -> string list

Modified: branches/2.27/src/uitext.ml
===================================================================
--- branches/2.27/src/uitext.ml	2009-07-21 13:06:29 UTC (rev 379)
+++ branches/2.27/src/uitext.ml	2009-07-21 13:10:32 UTC (rev 380)
@@ -609,14 +609,17 @@
     synchronizeUntilDone ()
   end
 
-let start _ =
+let start interface =
+  if interface <> Uicommon.Text then
+    Util.msg "This Unison binary only provides the text GUI...\n";
   begin try
     (* Just to make sure something is there... *)
     setWarnPrinterForInitialization();
     Uicommon.uiInit
       (fun s -> Util.msg "%s\n%s\n" Uicommon.shortUsageMsg s; exit 1)
       (fun s -> Util.msg "%s" Uicommon.shortUsageMsg; exit 1)
-      (fun () -> if not (Prefs.read silent)
+      (fun () -> if Prefs.read silent then Prefs.set Trace.terse true;
+                 if not (Prefs.read silent)
                  then Util.msg "%s\n" (Uicommon.contactingServerMsg())) 
       (fun () -> Some "default")
       (fun () -> Util.msg "%s" Uicommon.shortUsageMsg; exit 1)



More information about the Unison-hackers mailing list