[Unison-hackers] [unison-svn] r453 - trunk/src

bcpierce@seas.upenn.edu bcpierce at seas.upenn.edu
Mon May 31 09:24:33 EDT 2010


Author: bcpierce
Date: 2010-05-31 09:24:33 -0400 (Mon, 31 May 2010)
New Revision: 453

Modified:
   trunk/src/RECENTNEWS
   trunk/src/mkProjectInfo.ml
   trunk/src/uitext.ml
   trunk/src/update.ml
Log:
* Trim duplicate paths when using "-repeat watch"

* Bump version number, since protocol has changed (should have done
  this a few commits ago)






Modified: trunk/src/RECENTNEWS
===================================================================
--- trunk/src/RECENTNEWS	2010-05-30 15:52:12 UTC (rev 452)
+++ trunk/src/RECENTNEWS	2010-05-31 13:24:33 UTC (rev 453)
@@ -1,3 +1,15 @@
+CHANGES FROM VERSION 2.41.-28
+
+* Trim duplicate paths when using "-repeat watch"
+
+* Bump version number, since protocol has changed (should have done
+  this a few commits ago)
+
+
+
+
+
+-------------------------------
 CHANGES FROM VERSION 2.40.16
 
 * Correct a bug in the watcher startup code for remote sync

Modified: trunk/src/mkProjectInfo.ml
===================================================================
--- trunk/src/mkProjectInfo.ml	2010-05-30 15:52:12 UTC (rev 452)
+++ trunk/src/mkProjectInfo.ml	2010-05-31 13:24:33 UTC (rev 453)
@@ -5,8 +5,8 @@
 
 let projectName = "unison"
 let majorVersion = 2
-let minorVersion = 40
-let pointVersionOrigin = 409 (* Revision that corresponds to point version 0 *)
+let minorVersion = 41
+let pointVersionOrigin = 453 (* Revision that corresponds to point version 0 *)
 
 (* Documentation:
    This is a program to construct a version of the form Major.Minor.Point,
@@ -100,3 +100,4 @@
 
 
 
+

Modified: trunk/src/uitext.ml
===================================================================
--- trunk/src/uitext.ml	2010-05-30 15:52:12 UTC (rev 452)
+++ trunk/src/uitext.ml	2010-05-31 13:24:33 UTC (rev 453)
@@ -655,7 +655,7 @@
     end 
   end
 
-let synchronizeOnce() =
+let synchronizeOnce () =
   let showStatus path =
     if path = "" then Util.set_infos "" else
     let max_len = 70 in
@@ -673,6 +673,9 @@
   if not (Prefs.read Trace.terse) && (Prefs.read Trace.debugmods = []) then
     Uutil.setUpdateStatusPrinter (Some showStatus);
 
+  debug (fun() -> Util.msg "temp: Globals.paths = %s\n"
+           (String.concat " "
+              (Safelist.map Path.toString (Prefs.read Globals.paths))));
   let updates = Update.findUpdates() in
 
   Uutil.setUpdateStatusPrinter None;
@@ -703,6 +706,9 @@
 (* FIX: we should check that the child process has not died and
    restart it if so... *)
 
+(* FIX: the names of the paths being watched should get included
+   in the name of the watcher's state file *)
+
 let watchinterval = 5
 
 let watcherTemp r n =
@@ -730,15 +736,27 @@
 module RootMap = Map.Make (struct type t = Common.root
                                   let compare = Pervasives.compare
                            end)
+(* Using string concatenation to accumulate characters is
+   a bit inefficient, but it's not clear how much it matters in the
+   grand scheme of things.  Current experience suggests that this
+   implementation performs well enough. *)
 type watcherinfo = {file: System.fspath;
                     ch:Pervasives.in_channel option ref;
                     chars: string ref;
                     lines: string list ref}
 let watchers : watcherinfo RootMap.t ref = ref RootMap.empty 
 
-(* FIX: Using string concatenation to accumulate characters is
-   a bit inefficient!  Not sure how much it matters in the grand scheme,
-   though... *)
+let trim_duplicates l =
+  let rec loop l = match l with
+    [] -> l
+  | [s] -> l
+  | s1::s2::rest ->
+      if Util.startswith s1 s2 || Util.startswith s2 s1 then
+        loop (s2::rest)
+      else
+        s1 :: (loop (s2::rest)) in
+  loop (Safelist.sort String.compare l)  
+
 let getAvailableLinesFromWatcher wi =
   let ch = match !(wi.ch) with Some(c) -> c | None -> assert false in 
   let rec loop () =
@@ -746,7 +764,7 @@
       None ->
         let res = !(wi.lines) in
         wi.lines := [];
-        res
+        trim_duplicates res
     | Some(c) ->
         if c = '\n' then begin
           wi.lines := !(wi.chars) :: !(wi.lines);
@@ -779,9 +797,10 @@
                (System.fspathToPrintString wi.file));
              []
            end
-         else 
+         else begin
            (* Watcher running and channel built: go ahead and read *)
            getAvailableLinesFromWatcher wi
+         end 
        with Not_found -> begin
          (* Watcher process not running *)
          let (changefile,cmd) = watchercmd r in
@@ -805,14 +824,31 @@
     (Lwt_unix.run (
       Globals.allRootsMap (fun r -> suckOnWatcherFileRoot r r)))
 
+let shouldNotIgnore p =
+  let rec test prefix rest =
+    if Globals.shouldIgnore prefix then
+      false
+    else match (Path.deconstruct rest) with
+        None -> true
+      | Some(n,rest') ->
+          test (Path.child prefix n) rest'
+    in 
+  test Path.empty (Path.fromString p) 
+
 let synchronizePathsFromFilesystemWatcher () =
-  (* Make sure the confirmbigdeletes preference is turned off.  If it's on, then
-     deletions will fail because every deletion is a "big deletion"! *)
+  (* Make sure the confirmbigdeletes preference is turned off.  If it's on,
+     then all deletions will fail because every deletion will count as
+     a "big deletion"! *)
   Prefs.set Globals.confirmBigDeletes false;
+
   let rec loop failedPaths = 
-    let newpaths = suckOnWatcherFiles () in
+    let newpathsraw = suckOnWatcherFiles () in
+    debug (fun () -> Util.msg
+      "Changed paths: %s\n" (String.concat " " newpathsraw));
+    let newpaths = Safelist.filter shouldNotIgnore newpathsraw in
     if newpaths <> [] then
-      display (Printf.sprintf "Changed paths:\n  %s\n"
+      display (Printf.sprintf "Changed paths:  %s%s\n"
+                 (if newpaths=[] then "" else "\n  ")
                  (String.concat "\n  " newpaths));
     let p = failedPaths @ (Safelist.map Path.fromString newpaths) in
     if p <> [] then begin

Modified: trunk/src/update.ml
===================================================================
--- trunk/src/update.ml	2010-05-30 15:52:12 UTC (rev 452)
+++ trunk/src/update.ml	2010-05-31 13:24:33 UTC (rev 453)
@@ -1395,8 +1395,8 @@
   showStatusDir path;
   let skip =
     Pred.test immutable (Path.toString path) &&
-    not (Pred.test immutablenot (Path.toString path))
-  in
+    not (Pred.test immutablenot (Path.toString path)) in
+
   if unchangedChildren then begin
     if skip then begin
       if Prefs.read Xferhint.xferbycopying then
@@ -1414,15 +1414,24 @@
       let archUpdated = ref false in
       let handleChild nm archive =
         let path' = Path.child path nm in
-        showStatus scanInfo path';
-        let (arch,uiChild) =
-          buildUpdateRec archive fspath path' scanInfo in
-        if uiChild <> NoUpdates then
-          updates := (nm, uiChild) :: !updates;
-        match arch with
-          None      -> archive
-        | Some arch -> archUpdated := true; arch
-      in
+        debugverbose (fun () -> Util.msg
+          "buildUpdateChildren(handleChild): %s\n" (Path.toString path'));
+        (* BCP 6/10: Added check for ignored path, but I'm not completely
+           sure this is the right place for it: *)
+        if Globals.shouldIgnore path' then begin
+          debugignore (fun()->Util.msg "buildUpdateChildren: ignoring path %s\n"
+                                (Path.toString path'));
+          archive
+        end else begin
+          showStatus scanInfo path';
+          let (arch,uiChild) =
+            buildUpdateRec archive fspath path' scanInfo in
+          if uiChild <> NoUpdates then
+            updates := (nm, uiChild) :: !updates;
+          match arch with
+            None      -> archive
+          | Some arch -> archUpdated := true; arch
+        end in
       let newChi = NameMap.mapi handleChild archChi in
       (* The Recon module relies on the updates to be sorted *)
       ((if !archUpdated then Some newChi else None),
@@ -1521,7 +1530,7 @@
 and buildUpdateRec archive currfspath path scanInfo =
   try
     debug (fun() ->
-      Util.msg "buildUpdate: %s\n"
+      Util.msg "buildUpdateRec: %s\n"
         (Fspath.toDebugString (Fspath.concat currfspath path)));
     let info = Fileinfo.get true currfspath path in
     match (info.Fileinfo.typ, archive) with
@@ -1582,7 +1591,7 @@
              Actually, we could check for ignored children in the archive,
              but this has a significant cost.  We could mark directories
              with ignored children, and only perform the checks for them,
-             but that does not seem worthwhile, are directories with
+             but that does not seem worthwhile, as directories with
              ignored children are expected to be rare in the archive.
              (These are files or directories which used not to be
              ignored and are now ignored.) *)
@@ -1755,7 +1764,9 @@
    unchanged files *)
 let findLocal fspath pathList:
       (Path.local * Common.updateItem * Props.t list) list =
-  debug (fun() -> Util.msg "findLocal %s\n" (Fspath.toDebugString fspath));
+  debug (fun() -> Util.msg
+    "findLocal %s (%s)\n" (Fspath.toDebugString fspath)
+    (String.concat " " (Safelist.map Path.toString pathList)));
   addHashToTempNames fspath;
   (* Maybe we should remember the device number where the root lives at 
      the beginning of update detection, so that we can check, below, that 



More information about the Unison-hackers mailing list