common.mli (7493B)
1 (* Unison file synchronizer: src/common.mli *) 2 (* Copyright 1999-2020, Benjamin C. Pierce (see COPYING for details) *) 3 4 (***************************************************************************) 5 (* COMMON TYPES USED BY ALL MODULES *) 6 (***************************************************************************) 7 8 type hostname = string 9 10 (* "Canonized" names of hosts *) 11 type host = 12 Local 13 | Remote of string 14 15 (* Roots for replicas (this is the type that is used by most of the code) *) 16 type root = host * Fspath.t 17 18 val root2string : root -> string 19 20 (* Give a printable hostname from a root (local prints as "local") *) 21 val root2hostname : root -> hostname 22 23 val compareRoots : root -> root -> int 24 val sortRoots : root list -> root list 25 (* Note, local roots come before remote roots *) 26 27 (* There are a number of functions in several modules that accept or return 28 lists containing one element for each path-to-be-synchronized specified 29 by the user using the -path option. This type constructor is used 30 instead of list, to help document their behavior -- in particular, 31 allowing us to write 'blah list list' as 'blah list oneperpath' in a few 32 places. *) 33 type 'a oneperpath = ONEPERPATH of 'a list 34 35 36 (*****************************************************************************) 37 (* COMMON TYPES USED BY UPDATE MODULE AND RECONCILER *) 38 (*****************************************************************************) 39 40 (* An updateItem describes the difference between the current state of the 41 filesystem below a given path and the state recorded in the archive below 42 that path. The other types are helpers. *) 43 44 type prevState251 = 45 Previous of Fileinfo.typ * Props.t251 * Os.fullfingerprint * Osx.ressStamp 46 | New 47 48 type contentschange251 = 49 ContentsSame 50 | ContentsUpdated of Os.fullfingerprint * Fileinfo.stamp251 * Osx.ressStamp 51 type permchange = PropsSame | PropsUpdated 52 53 (* Variable name prefix: "ui" *) 54 type updateItem251 = 55 NoUpdates (* Path not changed *) 56 | Updates (* Path changed in this replica *) 57 of updateContent251 (* - new state *) 58 * prevState251 (* - summary of old state *) 59 | Error (* Error while detecting updates *) 60 of string (* - description of error *) 61 62 (* Variable name prefix: "uc" *) 63 and updateContent251 = 64 Absent (* Path refers to nothing *) 65 | File (* Path refers to an ordinary file *) 66 of Props.t251 (* - summary of current state *) 67 * contentschange251 (* - hint to transport agent *) 68 | Dir (* Path refers to a directory *) 69 of Props.t251 (* - summary of current state *) 70 * (Name.t * updateItem251) list(* - children 71 MUST KEEP SORTED for recon *) 72 * permchange (* - did permissions change? *) 73 * bool (* - is the directory now empty? *) 74 | Symlink (* Path refers to a symbolic link *) 75 of string (* - link text *) 76 77 type prevState = 78 Previous of Fileinfo.typ * Props.t * Os.fullfingerprint * Osx.ressStamp 79 | New 80 81 type contentschange = 82 ContentsSame 83 | ContentsUpdated of Os.fullfingerprint * Fileinfo.stamp * Osx.ressStamp 84 85 (* Variable name prefix: "ui" *) 86 type updateItem = 87 NoUpdates (* Path not changed *) 88 | Updates (* Path changed in this replica *) 89 of updateContent (* - new state *) 90 * prevState (* - summary of old state *) 91 | Error (* Error while detecting updates *) 92 of string (* - description of error *) 93 94 (* Variable name prefix: "uc" *) 95 and updateContent = 96 Absent (* Path refers to nothing *) 97 | File (* Path refers to an ordinary file *) 98 of Props.t (* - summary of current state *) 99 * contentschange (* - hint to transport agent *) 100 | Dir (* Path refers to a directory *) 101 of Props.t (* - summary of current state *) 102 * (Name.t * updateItem) list (* - children 103 MUST KEEP SORTED for recon *) 104 * permchange (* - did permissions change? *) 105 * bool (* - is the directory now empty? *) 106 | Symlink (* Path refers to a symbolic link *) 107 of string (* - link text *) 108 109 val mupdateItem : updateItem Umarshal.t 110 val mupdateContent : updateContent Umarshal.t 111 112 val ui_to_compat251 : updateItem -> updateItem251 113 val ui_of_compat251 : updateItem251 -> updateItem 114 val uc_to_compat251 : updateContent -> updateContent251 115 val uc_of_compat251 : updateContent251 -> updateContent 116 117 (*****************************************************************************) 118 (* COMMON TYPES SHARED BY RECONCILER AND TRANSPORT AGENT *) 119 (*****************************************************************************) 120 121 type status = 122 [ `Deleted 123 | `Modified 124 | `PropsChanged 125 | `Created 126 | `Unchanged ] 127 128 (* Variable name prefix: "rc" *) 129 type replicaContent = 130 { typ : Fileinfo.typ; 131 status : status; 132 desc : Props.t; (* Properties (for the UI) *) 133 ui : updateItem; 134 size : int * Uutil.Filesize.t; (* Number of items and size *) 135 props : Props.t list } (* Parent properties *) 136 137 type direction = 138 Conflict of string (* The string is the reason of the conflict *) 139 | Merge 140 | Replica1ToReplica2 141 | Replica2ToReplica1 142 143 val direction2string : direction -> string 144 145 val isConflict : direction -> bool 146 147 type difference = 148 { rc1 : replicaContent; (* - content of first replica *) 149 rc2 : replicaContent; (* - content of second replica *) 150 errors1 : string list; (* - deep errors in first replica *) 151 errors2 : string list; (* - deep errors in second replica *) 152 mutable direction : direction; (* - action to take (it's mutable so that 153 the user interface can change it) *) 154 default_direction : direction } (* - default action to take *) 155 156 (* Variable name prefix: "rplc" *) 157 type replicas = 158 Problem of string (* There was a problem during update detection *) 159 | Different of difference (* Replicas differ *) 160 161 (* Variable name prefix: "ri" *) 162 type reconItem = {path1 : Path.t; path2 : Path.t; replicas : replicas} 163 164 val ucLength : updateContent -> Uutil.Filesize.t 165 val uiLength : updateItem -> Uutil.Filesize.t 166 val riLength : reconItem -> Uutil.Filesize.t 167 val riFileType : reconItem -> string 168 val fileInfos : 169 updateItem -> updateItem -> 170 Props.t * Os.fullfingerprint * Osx.ressStamp * 171 Props.t * Os.fullfingerprint * Osx.ressStamp 172 173 (* True if the ri's type is Problem or if it is Different and the direction 174 is Conflict *) 175 val problematic : reconItem -> bool 176 (* True if the ri is problematic or if it has some deep errors in a 177 directory *) 178 val partiallyProblematic : reconItem -> bool 179 val isDeletion : reconItem -> bool