Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore force = newer/older if mtimes are equal #970

Merged
merged 2 commits into from
Oct 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ Released 2023-xx-yy
for changed build goals, input variables and build artifact names.
See INSTALL.md for details.
* Various fixes in Windows and Cygwin builds.
* Preferences "force", "prefer" and related "partial" preferences now
work slightly differently with values "newer" and "older". Previously,
if mtimes in both replicas were equal then always the second root
propagated to the first root (possibly reverting user changes). It
is now made explicit that "newer" and "older" only work when mtimes
are different.
* Cleanups in documentation.
* Bugfixes, minor improvements, cleanups.

Expand Down
14 changes: 12 additions & 2 deletions src/recon.ml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ let setDirection ri dir force =
diff.direction <- Replica1ToReplica2
| _ ->
let comp = Props.time rc1.desc -. Props.time rc2.desc in
(* If mtimes are equal then `Older and `Newer are not defined
and will be ignored. This is safer than the previous way of
always propagating from replica 2 to replica 1. *)
if comp <> 0.0 then
let comp = if dir=`Newer then -. comp else comp in
if comp<0.0 then
diff.direction <- Replica1ToReplica2
Expand Down Expand Up @@ -125,7 +129,10 @@ let forceRoot: string Prefs.t =
^ "You can also specify \\verb|-force newer| (or \\verb|-force older|) "
^ "to force Unison to choose the file with the later (earlier) "
^ "modtime. In this case, the \\verb|-times| preference must also "
^ "be enabled.\n\n"
^ "be enabled. If modtimes are equal in both replicas when using "
^ "\\verb|newer| or \\verb|older| then this preference will have no "
^ "effect (changes will be synced as if without this preference or "
^ "remain unsynced in case of a conflict).\n\n"
^ "This preference is overridden by the \\verb|forcepartial| preference.\n\n"
^ "This preference should be used only if you are {\\em sure} you "
^ "know what you are doing!")
Expand All @@ -145,7 +152,10 @@ let forceRootPartial: Pred.t =
^ "(or \\verb|forcepartial PATHSPEC -> older|) "
^ "to force Unison to choose the file with the later (earlier) "
^ "modtime. In this case, the \\verb|-times| preference must also "
^ "be enabled.\n\n"
^ "be enabled. If modtimes are equal in both replicas when using "
^ "\\verb|newer| or \\verb|older| then this preference will have no "
^ "effect (changes will be synced as if without this preference or "
^ "remain unsynced in case of a conflict).\n\n"
^ "This preference should be used only if you are {\\em sure} you "
^ "know what you are doing!")

Expand Down
11 changes: 9 additions & 2 deletions src/strings.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1562,7 +1562,11 @@ let docs =
\n\
\032 You can also specify -force newer (or -force older) to force\n\
\032 Unison to choose the file with the later (earlier) modtime. In\n\
\032 this case, the -times preference must also be enabled.\n\
\032 this case, the -times preference must also be enabled. If\n\
\032 modtimes are equal in both replicas when using newer or older\n\
\032 then this preference will have no effect (changes will be synced\n\
\032 as if without this preference or remain unsynced in case of a\n\
\032 conflict).\n\
\n\
\032 This preference is overridden by the forcepartial preference.\n\
\n\
Expand All @@ -1583,7 +1587,10 @@ let docs =
\032 You can also specify forcepartial PATHSPEC -> newer (or\n\
\032 forcepartial PATHSPEC -> older) to force Unison to choose the\n\
\032 file with the later (earlier) modtime. In this case, the -times\n\
\032 preference must also be enabled.\n\
\032 preference must also be enabled. If modtimes are equal in both\n\
\032 replicas when using newer or older then this preference will\n\
\032 have no effect (changes will be synced as if without this\n\
\032 preference or remain unsynced in case of a conflict).\n\
\n\
\032 This preference should be used only if you are sure you know\n\
\032 what you are doing!\n\
Expand Down