5

I've set up a custom automated sync between 2 folders (in OSX) with unison with the following line:

unison folder1 folder2 -batch -debug update+

Which worked fine until I encountered:

Synchronization complete at 12:01:44  (0 item transferred, 1 skipped, 0 failed)
  skipped: example.txt (contents changed on both sides)

I'd like the command to automatically sync the most recent version. Looking in the options:

$ unison -help | grep conflict
 -auto              automatically accept default (nonconflicting) actions
 -copyonconflict    keep copies of conflicting files
 -prefer xxx        choose this replica's version for conflicting changes

.. which suggests the only way to resolve is with -prefer, but I may be missing something. Is it possible to specify version by time-stamp?


EDIT: All relevant bits of the sync report:

[update+]   Unchanged file
[update+] buildUpdateChildren(handleChild): example.txt
[update] buildUpdateRec: /path/to/folder1/example.txt
[update] checkContentsChange: archStamp is inode (3373366) / info.inode (3373748) / times: 1433242394.000000 = 1433242527.000000... false / lengths: 110602 - 110611
[update+]   Double-check possibly updated file
[update]   archive digest = (29c46acff8e661513ec7487bc0069c2b,)   current digest = (cdc82c2519076f9e52486b1c881e179d,)

[update+]   Unchanged file
[update+] buildUpdateChildren(handleChild): example.txt
[update] buildUpdateRec: /path/to/folder2/example.txt
[update] checkContentsChange: archStamp is inode (3373726) / info.inode (3373746) / times: 1433242452.000000 = 1433242515.000000... false / lengths: 110602 - 109400
[update+]   Double-check possibly updated file
[update]   archive digest = (29c46acff8e661513ec7487bc0069c2b,)   current digest = (e12ef45f692808d50989ca4b08d8c27f,)

changed  <-?-> changed    example.txt

Synchronization complete at 12:23:37  (0 item transferred, 1 skipped, 0 failed)
  skipped: example.txt (contents changed on both sides)
geotheory
  • 1,099

2 Answers2

6

I've given up on time stamp and settled for prioritising one version by adding the argument

-prefer /path/to/folder1

which resolves the conflicts.

geotheory
  • 1,099
1

I think this will help. As Changes in Version 2.48.4:

Added a "copyonconflict" preference, to make a copy of files that would otherwise be overwritten or deleted in case of conflicting changes. (This makes it possible to automatically resolve conflicts in a fairly safe way when synchronizing continuously, in combination with the "repeat = watch" and "prefer = newer" preferences.