Find git executable at run time
[git-darcs-import.git] / src / Darcs / Patch.lhs
blob7615b269ebbcaaa70aa7ff33c841db8e16ab856a
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)
6 % any later version.
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}
19 \label{Patch}
21 \newtheorem{thm}{Theorem}
22 \newtheorem{dfn}{Definition}
24 \section{Background}
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
32 foundations.
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
40 about darcs.
42 \begin{code}
43 {-# OPTIONS_GHC -cpp -fno-warn-orphans #-}
44 #include "gadts.h"
45 module Darcs.Patch ( RepoPatch, Prim, Patch, RealPatch, Named, Patchy,
46 flattenFL, joinPatches,
47 fromPrim, fromPrims,
48 is_null_patch, nullP,
49 rmfile, addfile, rmdir, adddir, move,
50 hunk, tokreplace, namepatch, anonymous,
51 binary,
52 description,
53 showContextPatch, showPatch, showNicely,
54 infopatch, changepref,
55 thing, things,
56 is_similar, is_addfile, is_hunk, is_setpref,
57 #ifndef GADT_WITNESSES
58 merger, is_merger, merge,
59 commute, commutex, list_touched_files,
60 -- for PatchTest
61 unravel, elegant_merge,
62 #else
63 Commute(..),
64 #endif
65 resolve_conflicts,
66 Effect, effect,
67 is_binary, gzWritePatch, writePatch, is_adddir,
68 invert, invertFL, invertRL, identity,
69 commuteFL, commuteRL,
70 readPatch,
71 canonize, sort_coalesceFL,
72 try_to_shrink,
73 apply_to_slurpy, patchname, patchcontents,
74 apply_to_filepaths, force_replace_slurpy, apply,
75 patch2patchinfo,
76 LineMark(AddedLine, RemovedLine, AddedRemovedLine, None),
77 MarkedUpFile, markup_file, empty_markedup_file,
78 summary, summarize, xml_summary,
79 adddeps, getdeps,
80 list_conflicted_files,
81 modernize_patch,
82 -- for Population
83 DirMark(..), patchChanges, applyToPop,
84 ) where
85 import Darcs.PopulationData ( DirMark(..) )
86 import Darcs.Patch.Core ( Patch, Named,
87 flattenFL,
88 adddeps, namepatch,
89 anonymous,
90 #ifndef GADT_WITNESSES
91 is_merger,
92 #endif
93 getdeps,
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,
100 thing, things,
101 commuteFL, commuteRL, apply,
102 description, summary,
103 #ifndef GADT_WITNESSES
104 commute, commutex, list_touched_files,
105 #else
106 Commute(..)
107 #endif
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
116 unravel,
117 merger, merge, elegant_merge,
118 #endif
120 import Darcs.Patch.Prim ( FromPrims, fromPrims, joinPatches, FromPrim, fromPrim,
121 Conflict, Effect(effect), list_conflicted_files, resolve_conflicts,
122 Prim, canonize,
123 sort_coalesceFL,
124 rmdir, rmfile, tokreplace, adddir, addfile,
125 binary, changepref, hunk, move,
126 is_adddir, is_addfile,
127 is_hunk, is_binary, is_setpref,
128 is_similar,
129 try_to_shrink )
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)
144 \end{code}
146 \input{Darcs/Patch/Apply.lhs}
147 \input{Darcs/Patch/Core.lhs}
148 \input{Darcs/Patch/Commute.lhs}
149 \input{Darcs/Patch/Show.lhs}