1 % Copyright (C) 2002-2003 David Roundy
3 % This program is free software; you can redistribute it and/or modify
4 % it under the terms of the GNU General Public License as published by
5 % the Free Software Foundation; either version 2, or (at your option)
8 % This program is distributed in the hope that it will be useful,
9 % but WITHOUT ANY WARRANTY; without even the implied warranty of
10 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 % GNU General Public License for more details.
13 % You should have received a copy of the GNU General Public License
14 % along with this program; see the file COPYING. If not, write to
15 % the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16 % Boston, MA 02110-1301, USA.
18 \chapter{Theory of patches}
21 \newtheorem{thm}{Theorem}
22 \newtheorem{dfn}{Definition}
26 I think a little background on the author is in order. I am a physicist,
27 and think like a physicist. The proofs and theorems given here are what I
28 would call ``physicist'' proofs and theorems, which is to say that while
29 the proofs may not be rigorous, they are practical, and the theorems are
30 intended to give physical insight. It would be great to have a
31 mathematician work on this to give patch theory better formalized
34 From the beginning of this theory, which originated as the result of a
35 series of email discussions with Tom Lord, I have looked at patches as
36 being analogous to the operators of quantum mechanics. I include in this
37 appendix footnotes explaining the theory of patches in terms of the theory
38 of quantum mechanics. I advise against taking this analogy too seriously,
39 although it could provide some insight into how a physicist might think
43 {-# OPTIONS_GHC -cpp -fno-warn-orphans #-}
45 module Darcs.Patch ( RepoPatch, Prim, Patch, RealPatch, Named, Patchy,
46 flattenFL, joinPatches,
49 rmfile, addfile, rmdir, adddir, move,
50 hunk, tokreplace, namepatch, anonymous,
53 showContextPatch, showPatch, showNicely,
54 infopatch, changepref,
56 is_similar, is_addfile, is_hunk, is_setpref,
57 #ifndef GADT_WITNESSES
58 merger, is_merger, merge,
59 commute, commutex, list_touched_files,
61 unravel, elegant_merge,
67 is_binary, gzWritePatch, writePatch, is_adddir,
68 invert, invertFL, invertRL, identity,
71 canonize, sort_coalesceFL,
73 apply_to_slurpy, patchname, patchcontents,
74 apply_to_filepaths, force_replace_slurpy, apply,
76 LineMark(AddedLine, RemovedLine, AddedRemovedLine, None),
77 MarkedUpFile, markup_file, empty_markedup_file,
78 summary, summarize, xml_summary,
80 list_conflicted_files,
83 DirMark(..), patchChanges, applyToPop,
85 import Darcs.PopulationData ( DirMark(..) )
86 import Darcs.Patch.Core ( Patch, Named,
90 #ifndef GADT_WITNESSES
94 is_null_patch, nullP, infopatch,
95 patch2patchinfo, patchname, patchcontents )
96 import Darcs.Patch.Read ( readPatch )
97 import Darcs.Patch.Patchy ( Patchy, writePatch, gzWritePatch,
98 showPatch, showNicely, showContextPatch,
99 invert, invertRL, invertFL, identity,
101 commuteFL, commuteRL, apply,
102 description, summary,
103 #ifndef GADT_WITNESSES
104 commute, commutex, list_touched_files,
109 import Darcs.Patch.Viewing ( xml_summary, summarize )
110 import Darcs.Patch.Apply ( applyToPop, patchChanges, empty_markedup_file,
111 markup_file, force_replace_slurpy,
112 apply_to_filepaths, apply_to_slurpy,
113 LineMark(..), MarkedUpFile )
114 import Darcs.Patch.Commute ( modernize_patch,
115 #ifndef GADT_WITNESSES
117 merger, merge, elegant_merge,
120 import Darcs.Patch.Prim ( FromPrims, fromPrims, joinPatches, FromPrim, fromPrim,
121 Conflict, Effect(effect), list_conflicted_files, resolve_conflicts,
124 rmdir, rmfile, tokreplace, adddir, addfile,
125 binary, changepref, hunk, move,
126 is_adddir, is_addfile,
127 is_hunk, is_binary, is_setpref,
130 import Darcs.Ordered ( FL )
131 import Darcs.Patch.Real ( RealPatch )
133 instance Patchy Patch
134 instance (Conflict p, Effect p, Patchy p) => Patchy (Named p)
136 class (Patchy p, Effect p, FromPrim p, Conflict p) => RepoPatchBase p
137 instance RepoPatchBase Patch
138 instance RepoPatchBase RealPatch
140 class (Patchy p, Effect p, FromPrims p, Conflict p) => RepoPatch p
141 instance RepoPatch Patch
142 instance RepoPatchBase p => RepoPatch (FL p)
146 \input{Darcs/Patch/Apply.lhs}
147 \input{Darcs/Patch/Core.lhs}
148 \input{Darcs/Patch/Commute.lhs}
149 \input{Darcs/Patch/Show.lhs}