ContentsIndex
Darcs.Patch.Prim
Synopsis
data Prim where
Move :: !FileName -> !FileName -> Prim
DP :: !FileName -> !DirPatchType -> Prim
FP :: !FileName -> !FilePatchType -> Prim
Split :: FL Prim -> Prim
Identity :: Prim
ChangePref :: !String -> !String -> !String -> Prim
data FilePatchType
= RmFile
| AddFile
| Hunk !Int [ByteString] [ByteString]
| TokReplace !String !String !String
| Binary ByteString ByteString
data DirPatchType
= RmDir
| AddDir
null_patch :: Prim
is_null_patch :: Prim -> Bool
nullP :: Prim -> EqCheck
is_identity :: Prim -> EqCheck
is_similar :: Prim -> Prim -> Bool
is_addfile :: Prim -> Bool
is_adddir :: Prim -> Bool
is_hunk :: Prim -> Bool
is_binary :: Prim -> Bool
is_setpref :: Prim -> Bool
addfile :: FilePath -> Prim
rmfile :: FilePath -> Prim
adddir :: FilePath -> Prim
rmdir :: FilePath -> Prim
move :: FilePath -> FilePath -> Prim
changepref :: String -> String -> String -> Prim
hunk :: FilePath -> Int -> [ByteString] -> [ByteString] -> Prim
tokreplace :: FilePath -> String -> String -> String -> Prim
binary :: FilePath -> ByteString -> ByteString -> Prim
evalargs :: (a -> b -> c) -> a -> b -> c
n_fn :: FilePath -> FilePath
data FileNameFormat
= OldFormat
| NewFormat
formatFileName :: FileNameFormat -> FileName -> Doc
showPrim :: FileNameFormat -> Prim -> Doc
showAddFile :: FileNameFormat -> FileName -> Doc
showRmFile :: FileNameFormat -> FileName -> Doc
showMove :: FileNameFormat -> FileName -> FileName -> Doc
showChangePref :: String -> String -> String -> Doc
showAddDir :: FileNameFormat -> FileName -> Doc
showRmDir :: FileNameFormat -> FileName -> Doc
showHunk :: FileNameFormat -> FileName -> Int -> [ByteString] -> [ByteString] -> Doc
showTok :: FileNameFormat -> FileName -> String -> String -> String -> Doc
showBinary :: FileNameFormat -> FileName -> ByteString -> ByteString -> Doc
break_every :: Int -> ByteString -> [ByteString]
showSplit :: FileNameFormat -> FL Prim -> Doc
commute_split :: CommuteFunction
try_to_shrink :: FL Prim -> FL Prim
mapPrimFL :: (FL Prim -> FL Prim) -> FL Prim -> FL Prim
data Simple
= SFP !FilePatchType
| SDP !DirPatchType
| SCP String String String
toSimple :: Prim -> Maybe (FileName, Simple)
fromSimple :: FileName -> Simple -> Prim
fromSimples :: FileName -> FL Simple -> FL Prim
try_harder_to_shrink :: FL Prim -> FL Prim
try_to_shrink2 :: FL Prim -> FL Prim
try_shrinking_inverse :: FL Prim -> Maybe (FL Prim)
shrink_a_bit :: FL Prim -> FL Prim
try_one :: RL Prim -> Prim -> FL Prim -> Maybe (FL Prim)
sort_coalesceFL :: FL Prim -> FL Prim
sort_coalesceFL2 :: FL Prim -> FL Prim
push_coalesce_patch :: Prim -> FL Prim -> Either (FL Prim) (FL Prim)
is_in_directory :: FileName -> FileName -> Bool
data Perhaps a
= Unknown
| Failed
| Succeeded a
toMaybe :: Perhaps a -> Maybe a
toPerhaps :: Maybe a -> Perhaps a
clever_commute :: CommuteFunction -> CommuteFunction
speedy_commute :: CommuteFunction
everything_else_commute :: CommuteFunction
is_filepatch :: Prim -> Maybe FileName
is_superdir :: FileName -> FileName -> Bool
commute_filedir :: CommuteFunction
type CommuteFunction = (Prim :< Prim) -> Perhaps (Prim :< Prim)
subcommutes :: [(String, CommuteFunction)]
elegant_merge :: (Prim :\/: Prim) -> Maybe (Prim :/\: Prim)
canonize :: Prim -> FL Prim
coalesce :: (Prim :< Prim) -> Maybe Prim
join :: (Prim :> Prim) -> Maybe Prim
commute_filepatches :: CommuteFunction
commuteFP :: FileName -> (FilePatchType :< FilePatchType) -> Perhaps (Prim :< Prim)
coalesceFilePrim :: FileName -> (FilePatchType :< FilePatchType) -> Maybe Prim
commuteHunk :: FileName -> (FilePatchType :< FilePatchType) -> Maybe (Prim :< Prim)
coalesceHunk :: FileName -> Int -> [ByteString] -> [ByteString] -> Int -> [ByteString] -> [ByteString] -> Maybe Prim
canonizeHunk :: FileName -> Int -> [ByteString] -> [ByteString] -> FL Prim
make_holey :: FileName -> Int -> [(Int, [ByteString], [ByteString])] -> FL Prim
try_tok_replace :: String -> String -> String -> [ByteString] -> Maybe [ByteString]
try_tok_internal :: String -> ByteString -> ByteString -> ByteString -> Maybe [ByteString]
modernizePrim :: Prim -> FL Prim
merge_orders :: Ordering -> Ordering -> Ordering
comparePrim :: Prim -> Prim -> Ordering
eq_FL :: (a -> a -> Bool) -> FL a -> FL a -> Bool
compare_FL :: (a -> a -> Ordering) -> FL a -> FL a -> Ordering
class FromPrim p where
fromPrim :: Prim -> p
class FromPrim p => ToFromPrim p where
toPrim :: p -> Maybe Prim
class FromPrims p where
fromPrims :: FL Prim -> p
joinPatches :: FL p -> p
class (Invert p, Commute p, Effect p) => Conflict p where
list_conflicted_files :: p -> [FilePath]
resolve_conflicts :: p -> [[Sealed (FL Prim)]]
commute_no_conflicts :: (p :> p) -> Maybe (p :> p)
conflictedEffect :: p -> [IsConflictedPrim]
data IsConflictedPrim where
IsC :: !ConflictState -> !Prim -> IsConflictedPrim
data ConflictState
= Okay
| Conflicted
| Duplicated
class Effect p where
effect :: p -> FL Prim
effectRL :: p -> RL Prim
isHunk :: p -> Maybe Prim
commute_no_conflictsFL :: Conflict p => (p :> FL p) -> Maybe (FL p :> p)
commute_no_conflictsRL :: Conflict p => (RL p :> p) -> Maybe (p :> RL p)
commute_no_conflictsRLFL :: Conflict p => (RL p :> FL p) -> Maybe (FL p :> RL p)
Documentation
data Prim where
Constructors
Move :: !FileName -> !FileName -> Prim
DP :: !FileName -> !DirPatchType -> Prim
FP :: !FileName -> !FilePatchType -> Prim
Split :: FL Prim -> Prim
Identity :: Prim
ChangePref :: !String -> !String -> !String -> Prim
show/hide Instances
data FilePatchType
Constructors
RmFile
AddFile
Hunk !Int [ByteString] [ByteString]
TokReplace !String !String !String
Binary ByteString ByteString
show/hide Instances
data DirPatchType
Constructors
RmDir
AddDir
show/hide Instances
null_patch :: Prim
is_null_patch :: Prim -> Bool
nullP :: Prim -> EqCheck
is_identity :: Prim -> EqCheck
is_similar :: Prim -> Prim -> Bool
Tells you if two patches are in the same category, human-wise. Currently just returns true if they are filepatches on the same file.
is_addfile :: Prim -> Bool
is_adddir :: Prim -> Bool
is_hunk :: Prim -> Bool
is_binary :: Prim -> Bool
is_setpref :: Prim -> Bool
addfile :: FilePath -> Prim
rmfile :: FilePath -> Prim
adddir :: FilePath -> Prim
rmdir :: FilePath -> Prim
move :: FilePath -> FilePath -> Prim
changepref :: String -> String -> String -> Prim
hunk :: FilePath -> Int -> [ByteString] -> [ByteString] -> Prim
tokreplace :: FilePath -> String -> String -> String -> Prim
binary :: FilePath -> ByteString -> ByteString -> Prim
evalargs :: (a -> b -> c) -> a -> b -> c
n_fn :: FilePath -> FilePath
data FileNameFormat
Constructors
OldFormat
NewFormat
formatFileName :: FileNameFormat -> FileName -> Doc
showPrim :: FileNameFormat -> Prim -> Doc
showAddFile :: FileNameFormat -> FileName -> Doc
showRmFile :: FileNameFormat -> FileName -> Doc
showMove :: FileNameFormat -> FileName -> FileName -> Doc
showChangePref :: String -> String -> String -> Doc
showAddDir :: FileNameFormat -> FileName -> Doc
showRmDir :: FileNameFormat -> FileName -> Doc
showHunk :: FileNameFormat -> FileName -> Int -> [ByteString] -> [ByteString] -> Doc
showTok :: FileNameFormat -> FileName -> String -> String -> String -> Doc
showBinary :: FileNameFormat -> FileName -> ByteString -> ByteString -> Doc
break_every :: Int -> ByteString -> [ByteString]
showSplit :: FileNameFormat -> FL Prim -> Doc
commute_split :: CommuteFunction
try_to_shrink :: FL Prim -> FL Prim
mapPrimFL :: (FL Prim -> FL Prim) -> FL Prim -> FL Prim
data Simple
Constructors
SFP !FilePatchType
SDP !DirPatchType
SCP String String String
show/hide Instances
Show Simple
toSimple :: Prim -> Maybe (FileName, Simple)
fromSimple :: FileName -> Simple -> Prim
fromSimples :: FileName -> FL Simple -> FL Prim
try_harder_to_shrink :: FL Prim -> FL Prim
try_to_shrink2 :: FL Prim -> FL Prim
try_shrinking_inverse :: FL Prim -> Maybe (FL Prim)
shrink_a_bit :: FL Prim -> FL Prim
try_one :: RL Prim -> Prim -> FL Prim -> Maybe (FL Prim)
sort_coalesceFL :: FL Prim -> FL Prim
sort_coalesceFL ps coalesces as many patches in ps as possible, sorting the results according to the scheme defined in comparePrim
sort_coalesceFL2 :: FL Prim -> FL Prim
The heart of sort_coalesceFL
push_coalesce_patch :: Prim -> FL Prim -> Either (FL Prim) (FL Prim)

push_coalesce_patch new ps is almost like new :>: ps except as an alternative to consing, we first try to coalesce new with the head of ps. If this fails, we try again, using commutation to push new down the list until we find a place where either (a) new is LT the next member of the list [see comparePrim] (b) commutation fails or (c) coalescing succeeds. The basic principle is to coalesce if we can and cons otherwise.

As an additional optimization, push_coalesce_patch outputs a Left value if it wasn't able to shrink the patch sequence at all, and a Right value if it was indeed able to shrink the patch sequence. This avoids the O(N) calls to lengthFL that were in the older code.

Also note that push_coalesce_patch is only ever used (and should only ever be used) as an internal function in in sort_coalesceFL2.

is_in_directory :: FileName -> FileName -> Bool
data Perhaps a
Constructors
Unknown
Failed
Succeeded a
show/hide Instances
Monad Perhaps
MonadPlus Perhaps
toMaybe :: Perhaps a -> Maybe a
toPerhaps :: Maybe a -> Perhaps a
clever_commute :: CommuteFunction -> CommuteFunction
speedy_commute :: CommuteFunction
everything_else_commute :: CommuteFunction
is_filepatch :: Prim -> Maybe FileName
is_superdir :: FileName -> FileName -> Bool
commute_filedir :: CommuteFunction
type CommuteFunction = (Prim :< Prim) -> Perhaps (Prim :< Prim)
subcommutes :: [(String, CommuteFunction)]
elegant_merge :: (Prim :\/: Prim) -> Maybe (Prim :/\: Prim)
canonize :: Prim -> FL Prim
coalesce :: (Prim :< Prim) -> Maybe Prim
coalesce p2 :< p1 tries to combine p1 and p2 into a single patch without intermediary changes. For example, two hunk patches modifying adjacent lines can be coalesced into a bigger hunk patch. Or a patch which moves file A to file B can be coalesced with a patch that moves file B into file C, yielding a patch that moves file A to file C.
join :: (Prim :> Prim) -> Maybe Prim
commute_filepatches :: CommuteFunction
commuteFP :: FileName -> (FilePatchType :< FilePatchType) -> Perhaps (Prim :< Prim)
coalesceFilePrim :: FileName -> (FilePatchType :< FilePatchType) -> Maybe Prim
commuteHunk :: FileName -> (FilePatchType :< FilePatchType) -> Maybe (Prim :< Prim)
coalesceHunk :: FileName -> Int -> [ByteString] -> [ByteString] -> Int -> [ByteString] -> [ByteString] -> Maybe Prim
canonizeHunk :: FileName -> Int -> [ByteString] -> [ByteString] -> FL Prim
make_holey :: FileName -> Int -> [(Int, [ByteString], [ByteString])] -> FL Prim
try_tok_replace :: String -> String -> String -> [ByteString] -> Maybe [ByteString]
try_tok_internal :: String -> ByteString -> ByteString -> ByteString -> Maybe [ByteString]
modernizePrim :: Prim -> FL Prim
merge_orders :: Ordering -> Ordering -> Ordering
comparePrim :: Prim -> Prim -> Ordering
comparePrim p1 p2 is used to provide an arbitrary ordering between p1 and p2. Basically, identical patches are equal and Move < DP < FP < Split < Identity < ChangePref. Everything else is compared in dictionary order of its arguments.
eq_FL :: (a -> a -> Bool) -> FL a -> FL a -> Bool
compare_FL :: (a -> a -> Ordering) -> FL a -> FL a -> Ordering
class FromPrim p where
Methods
fromPrim :: Prim -> p
show/hide Instances
class FromPrim p => ToFromPrim p where
Methods
toPrim :: p -> Maybe Prim
show/hide Instances
class FromPrims p where
Methods
fromPrims :: FL Prim -> p
joinPatches :: FL p -> p
show/hide Instances
class (Invert p, Commute p, Effect p) => Conflict p where
Methods
list_conflicted_files :: p -> [FilePath]
resolve_conflicts :: p -> [[Sealed (FL Prim)]]
commute_no_conflicts :: (p :> p) -> Maybe (p :> p)

If commute_no_conflicts x :> y succeeds, we know that that x commutes past y without any conflicts. This function is useful for patch types for which commute is defined to always succeed; so we need some way to pick out the specific cases where commutation succeeds without any conflicts.

Consider the commute square with patch names written in capital letters and repository states written in small letters.

          X
       o-->--a
       |     |
    Y' v     v Y
       |     |
       z-->--b
          X'

The default definition of this function checks that we can mirror the commutation with patch inverses (written with the negative sign)

         -X     X
       a-->--o-->--a
       |     |     |
   Y'' v  Y' v     v Y
       |     |     |
       b-->--z-->--b
         (-X)'  X'

We check that commuting X and Y succeeds, as does commuting -X and Y'. It also checks that Y'' == Y and that -(X') is the same as (-X)'

conflictedEffect :: p -> [IsConflictedPrim]
show/hide Instances
data IsConflictedPrim where
Constructors
IsC :: !ConflictState -> !Prim -> IsConflictedPrim
data ConflictState
Constructors
Okay
Conflicted
Duplicated
show/hide Instances
class Effect p where

Patches whose concrete effect which can be expressed as a list of primitive patches.

A minimal definition would be either of effect or effectRL.

Methods
effect :: p -> FL Prim
effectRL :: p -> RL Prim
isHunk :: p -> Maybe Prim
show/hide Instances
commute_no_conflictsFL :: Conflict p => (p :> FL p) -> Maybe (FL p :> p)
commute_no_conflictsRL :: Conflict p => (RL p :> p) -> Maybe (p :> RL p)
commute_no_conflictsRLFL :: Conflict p => (RL p :> FL p) -> Maybe (FL p :> RL p)
Produced by Haddock version 2.4.2