[Unison-hackers] [unison-svn] r544 - in trunk/src: . uimac14

bcpierce at seas.upenn.edu bcpierce at seas.upenn.edu
Mon Jul 13 17:34:49 EDT 2015


Author: bcpierce
Date: 2015-07-13 17:34:49 -0400 (Mon, 13 Jul 2015)
New Revision: 544

Modified:
   trunk/src/RECENTNEWS
   trunk/src/globals.ml
   trunk/src/globals.mli
   trunk/src/mkProjectInfo.ml
   trunk/src/recon.ml
   trunk/src/test.ml
   trunk/src/uimac14/MyController.m
   trunk/src/uimac14/cltool.c
Log:
* Small change for OSX El Capitan, from Alan Shutko

* Add a new preference, 'atomic', for specifying directories that
  should be treated atomically -- if there are changes within such a
  directory in both replicase, the whole directory is marked as a
  conflict instead of propagating any of the changes.  Thanks to
  Julian Squires for submitting this patch!

Modified: trunk/src/RECENTNEWS
===================================================================
--- trunk/src/RECENTNEWS	2015-06-08 14:58:56 UTC (rev 543)
+++ trunk/src/RECENTNEWS	2015-07-13 21:34:49 UTC (rev 544)
@@ -1,3 +1,13 @@
+CHANGES FROM VERSION 2.49.0
+
+* Small change for OSX El Capitan, from Alan Shutko
+
+* Add a new preference, 'atomic', for specifying directories that
+  should be treated atomically -- if there are changes within such a
+  directory in both replicase, the whole directory is marked as a
+  conflict instead of propagating any of the changes.  Thanks to
+  Julian Squires for submitting this patch!
+-------------------------------
 CHANGES FROM VERSION 2.48.6
 
 * Add shortcut key to GTK2 user interface allowing - to be used as a

Modified: trunk/src/globals.ml
===================================================================
--- trunk/src/globals.ml	2015-06-08 14:58:56 UTC (rev 543)
+++ trunk/src/globals.ml	2015-07-13 21:34:49 UTC (rev 544)
@@ -258,7 +258,11 @@
      and then using {\\tt ignorenot} to select particular paths to be 
      synchronized will not work.  Instead, you should use the {\\tt path}
      preference to choose particular paths to synchronize.")
-    
+
+let atomic = Pred.create "atomic" ~advanced:true
+  ("This preference specifies paths for directories whose \
+     contents will be considered as a group rather than individually.")
+
 let shouldIgnore p =
   let p = Path.toString p in
   (Pred.test ignorePred p) && not (Pred.test ignorenotPred p) 

Modified: trunk/src/globals.mli
===================================================================
--- trunk/src/globals.mli	2015-06-08 14:58:56 UTC (rev 543)
+++ trunk/src/globals.mli	2015-07-13 21:34:49 UTC (rev 544)
@@ -80,6 +80,7 @@
 val shouldMerge : 'a Path.path -> bool
 val ignorePred : Pred.t
 val ignorenotPred : Pred.t
+val atomic : Pred.t
 
 (* Be careful calling this to add new patterns to be ignored: Its
    value does NOT persist when a new profile is loaded, so it has to

Modified: trunk/src/mkProjectInfo.ml
===================================================================
--- trunk/src/mkProjectInfo.ml	2015-06-08 14:58:56 UTC (rev 543)
+++ trunk/src/mkProjectInfo.ml	2015-07-13 21:34:49 UTC (rev 544)
@@ -5,8 +5,8 @@
 
 let projectName = "unison"
 let majorVersion = 2
-let minorVersion = 48
-let pointVersionOrigin = 533 (* Revision that corresponds to point version 0 *)
+let minorVersion = 49
+let pointVersionOrigin = 543 (* Revision that corresponds to point version 0 *)
 
 (* Documentation:
    This is a program to construct a version of the form Major.Minor.Point,
@@ -100,5 +100,6 @@
 
 
 
+
 
 

Modified: trunk/src/recon.ml
===================================================================
--- trunk/src/recon.ml	2015-06-08 14:58:56 UTC (rev 543)
+++ trunk/src/recon.ml	2015-07-13 21:34:49 UTC (rev 544)
@@ -580,39 +580,49 @@
       (add_equal counter equals (Absent, Absent), unequals)
   | (Updates (Dir (desc1, children1, propsChanged1, _) as uc1, prevState1),
      Updates (Dir (desc2, children2, propsChanged2, _) as uc2, prevState2)) ->
-       (* See if the directory itself should have a reconItem *)
-       let dirResult =
-         if propsChanged1 = PropsSame && propsChanged2 = PropsSame then
-           (equals, unequals)
-         else if Props.similar desc1 desc2 then
-           let uc1 = Dir (desc1, [], PropsSame, false) in
-           let uc2 = Dir (desc2, [], PropsSame, false) in
-           (add_equal counter equals (uc1, uc2), unequals)
-         else
-           let action =
-             if propsChanged1 = PropsSame then Replica2ToReplica1
-             else if propsChanged2 = PropsSame then Replica1ToReplica2
-             else Conflict "properties changed on both sides" in
-           (equals,
-            Tree.add unequals
-              (Different
-                 {rc1 = update2replicaContent path false ui1 [] uc1 `DIRECTORY;
-                  rc2 = update2replicaContent path false ui2 [] uc2 `DIRECTORY;
+       if Pred.test Globals.atomic (Path.toString path) then
+         let action = Conflict "atomic directory" in
+         (equals,
+          Tree.add unequals
+            (Different
+                 {rc1 = update2replicaContent path true ui1 [] uc1 `DIRECTORY;
+                  rc2 = update2replicaContent path true ui2 [] uc2 `DIRECTORY;
                   direction = action; default_direction = action;
                   errors1 = []; errors2 = []}))
-       in
-       (* Apply reconcile on children. *)
-       Safelist.fold_left
-         (fun (equals, unequals) (name1,ui1,name2,ui2) ->
-           let (eq, uneq) =
-             reconcile
-               allowPartial (Path.child path name1) ui1 [] ui2 [] counter
-               (Tree.enter equals (name1, name2))
-               (Tree.enter unequals (name1, name2))
-           in
-           (Tree.leave eq, Tree.leave uneq))
-         dirResult
-         (combineChildren children1 children2)
+       else
+         (* See if the directory itself should have a reconItem *)
+         let dirResult =
+           if propsChanged1 = PropsSame && propsChanged2 = PropsSame then
+             (equals, unequals)
+           else if Props.similar desc1 desc2 then
+             let uc1 = Dir (desc1, [], PropsSame, false) in
+             let uc2 = Dir (desc2, [], PropsSame, false) in
+             (add_equal counter equals (uc1, uc2), unequals)
+           else
+             let action =
+               if propsChanged1 = PropsSame then Replica2ToReplica1
+               else if propsChanged2 = PropsSame then Replica1ToReplica2
+               else Conflict "properties changed on both sides" in
+             (equals,
+              Tree.add unequals
+                (Different
+                   {rc1 = update2replicaContent path false ui1 [] uc1 `DIRECTORY;
+                    rc2 = update2replicaContent path false ui2 [] uc2 `DIRECTORY;
+                    direction = action; default_direction = action;
+                    errors1 = []; errors2 = []}))
+         in
+         (* Apply reconcile on children. *)
+         Safelist.fold_left
+           (fun (equals, unequals) (name1,ui1,name2,ui2) ->
+              let (eq, uneq) =
+                reconcile
+                  allowPartial (Path.child path name1) ui1 [] ui2 [] counter
+                  (Tree.enter equals (name1, name2))
+                  (Tree.enter unequals (name1, name2))
+              in
+              (Tree.leave eq, Tree.leave uneq))
+           dirResult
+           (combineChildren children1 children2)
   | (Updates (File (desc1,contentsChanged1) as uc1, prev),
      Updates (File (desc2,contentsChanged2) as uc2, _)) ->
        begin match contentsChanged1, contentsChanged2 with

Modified: trunk/src/test.ml
===================================================================
--- trunk/src/test.ml	2015-06-08 14:58:56 UTC (rev 543)
+++ trunk/src/test.ml	2015-07-13 21:34:49 UTC (rev 544)
@@ -322,6 +322,40 @@
      running fast enough that the whole thing happens within a second, then the
      update will be missed! *)
 
+  (* Test that .git is treated atomically. *)
+  runtest "Atomicity of certain directories 1" ["atomic = Name .git";
+                                                "force = newer"] (fun() ->
+      let orig = (Dir ["foo", Dir [".git", Dir ["a", File "foo";
+                                                "b", File "bar";
+                                                "c", File "baz"]]]) in
+      put R1 orig; put R2 orig; sync();
+      let expected = (Dir ["foo", Dir [".git", Dir ["a", File "modified on R1";
+                                                    "b", File "bar";
+                                                    "c", File "modified on R1"]]]) in
+      put R2 (Dir ["foo", Dir [".git",
+                               Dir ["a", File "foo";
+                                    "b", File "modified on R2";
+                                    "c", File "modified on R2"]]]);
+      put R1 expected;
+      sync ();
+      check "1" R2 expected;
+      check "2" R1 expected
+    );
+
+  runtest "Atomicity of certain directories 2" ["atomic = Name .git"] (fun() ->
+      let a = (Dir ["foo", Dir [".git", Dir ["a", File "foo";
+                                             "b", File "bar";
+                                             "c", File "baz";
+                                             "d", File "quux"]]]) in
+      let b = (Dir ["foo", Dir [".git", Dir ["a", File "foo";
+                                             "b", File "bar";
+                                             "c", File "baz";
+                                             "e", File "quux"]]]) in
+      put R1 a; put R2 b; sync();
+      check "1" R1 a;
+      check "2" R2 b
+    );
+
   (* Check for the bug reported by Ralf Lehmann *)
   if not bothRootsLocal then 
     runtest "backups 1 (remote)" ["backup = Name *"] (fun() -> 

Modified: trunk/src/uimac14/MyController.m
===================================================================
--- trunk/src/uimac14/MyController.m	2015-06-08 14:58:56 UTC (rev 543)
+++ trunk/src/uimac14/MyController.m	2015-07-13 21:34:49 UTC (rev 544)
@@ -182,7 +182,9 @@
   /* unless user has clicked Don't ask me again, ask about cltool */
   if ( ([[NSUserDefaults standardUserDefaults] boolForKey:@"CheckCltool"]) && 
 	  (![[NSFileManager defaultManager]
-		 fileExistsAtPath:@"/usr/bin/unison"]) )
+              /* BCP 6/2015: Changed from /usr/bin/unison for El Capitan, per 
+                 suggestion from Alan Shutko */
+		 fileExistsAtPath:@"/usr/local/bin/unison"]) )
 	  [self raiseCltoolWindow:nil];
 }
 

Modified: trunk/src/uimac14/cltool.c
===================================================================
--- trunk/src/uimac14/cltool.c	2015-06-08 14:58:56 UTC (rev 543)
+++ trunk/src/uimac14/cltool.c	2015-07-13 21:34:49 UTC (rev 544)
@@ -1,7 +1,7 @@
 /* cltool.c
 
    This is a command-line tool for Mac OS X that looks up the unison
-   application, where ever it has been installed, and runs it.  This
+   application, whereever it has been installed, and runs it.  This
    is intended to be installed in a standard place (e.g.,
    /usr/bin/unison) to make it easy to invoke unison as a server, or
    to use unison from the command line when it has been installed with



More information about the Unison-hackers mailing list