darcs-2.18.2: a distributed, interactive, smart revision control system

Safe Haskell | None
Language | Haskell2010

Darcs.Patch.Match

Description

First matcher, Second matcher and Nonrange matcher

When we match for patches, we have a PatchSet, of which we want a subset. This subset is formed by the patches in a given interval which match a given criterion. If we represent time going left to right, then we have (up to) three `Matcher`s:

- the `firstMatcher` is the left bound of the interval,
- the `secondMatcher` is the right bound, and
- the `nonrangeMatcher` is the criterion we use to select among patches in the interval.

Synopsis

- helpOnMatchers :: [String]
- matchFirstPatchset :: forall (p :: Type -> Type -> Type) wStart wX. MatchableRP p => [MatchFlag] -> PatchSet p wStart wX -> Maybe (SealedPatchSet p wStart)
- matchSecondPatchset :: forall (p :: Type -> Type -> Type) wStart wX. MatchableRP p => [MatchFlag] -> PatchSet p wStart wX -> Maybe (SealedPatchSet p wStart)
- splitSecondFL :: forall (p :: Type -> Type -> Type) q wX wY. Matchable p => (forall wA wB. q wA wB -> Sealed2 p) -> [MatchFlag] -> FL q wX wY -> (FL q :> FL q) wX wY
- matchAPatch :: Matchable p => [MatchFlag] -> p wX wY -> Bool
- rollbackToPatchSetMatch :: forall (p :: Type -> Type -> Type) m wX. (ApplyMonad (ApplyState p) m, MatchableRP p, ApplyState p ~ Tree) => PatchSetMatch -> PatchSet p Origin wX -> m ()
- firstMatch :: [MatchFlag] -> Bool
- secondMatch :: [MatchFlag] -> Bool
- haveNonrangeMatch :: [MatchFlag] -> Bool
- data PatchSetMatch
  - = IndexMatch Int
  - | PatchMatch Matcher
  - | TagMatch Matcher
  - | ContextMatch AbsolutePath
- patchSetMatch :: [MatchFlag] -> Maybe PatchSetMatch
- checkMatchSyntax :: [MatchFlag] -> IO ()
- hasIndexRange :: [MatchFlag] -> Maybe (Int, Int)
- getMatchingTag :: forall (p :: Type -> Type -> Type) wStart wX. MatchableRP p => Matcher -> PatchSet p wStart wX -> SealedPatchSet p wStart
- matchAPatchset :: forall (p :: Type -> Type -> Type) wStart wX. MatchableRP p => Matcher -> PatchSet p wStart wX -> SealedPatchSet p wStart
- data MatchFlag
  - = OnePattern String
  - | SeveralPattern String
  - | AfterPattern String
  - | UpToPattern String
  - | OnePatch String
  - | SeveralPatch String
  - | AfterPatch String
  - | UpToPatch String
  - | OneHash String
  - | AfterHash String
  - | UpToHash String
  - | OneTag String
  - | SeveralTag String
  - | AfterTag String
  - | UpToTag String
  - | LastN Int
  - | OneIndex Int
  - | IndexRange Int Int
  - | Context AbsolutePath
- matchingHead :: forall (p :: Type -> Type -> Type) wR. MatchableRP p => [MatchFlag] -> PatchSet p Origin wR -> (PatchSet p :> FL (PatchInfoAnd p)) Origin wR
- type Matchable (p :: Type -> Type -> Type) = (Apply p, PatchInspect p, Ident p, PatchId p ~ PatchInfo)
- type MatchableRP (p :: Type -> Type -> Type) = (Apply p, Commute p, PatchInspect p)

# Documentation

helpOnMatchers :: [String] #

The string that is emitted when the user runs `darcs help patterns`.

matchFirstPatchset :: forall (p :: Type -> Type -> Type) wStart wX. MatchableRP p => [MatchFlag] -> PatchSet p wStart wX -> Maybe (SealedPatchSet p wStart) #

`matchFirstPatchset fs ps` returns the part of `ps` before its first matcher, ie the one that comes first dependencywise. Hence, patches in `matchFirstPatchset fs ps` are the context for the ones we want.

matchSecondPatchset :: forall (p :: Type -> Type -> Type) wStart wX. MatchableRP p => [MatchFlag] -> PatchSet p wStart wX -> Maybe (SealedPatchSet p wStart) #

`matchSecondPatchset fs ps` returns the part of `ps` before its second matcher, ie the one that comes last dependencywise.

splitSecondFL #

Arguments

:: forall (p :: Type -> Type -> Type) q wX wY. Matchable p |
=> (forall wA wB. q wA wB -> Sealed2 p) |
-> [MatchFlag] |
-> FL q wX wY |
-> (FL q :> FL q) wX wY | The first element is the patches before and including the first patch matching the second matcher, the second element is the patches after it

Split on the second matcher. Note that this picks up the first match starting from the earliest patch in a sequence, as opposed to `matchSecondPatchset` which picks up the first match starting from the latest patch

matchAPatch :: Matchable p => [MatchFlag] -> p wX wY -> Bool #

Whether a patch matches the given `MatchFlag`s. This should be invariant under inversion:

    matchAPatch (invert p) = matchAPatch p

rollbackToPatchSetMatch :: forall (p :: Type -> Type -> Type) m wX. (ApplyMonad (ApplyState p) m, MatchableRP p, ApplyState p ~ Tree) => PatchSetMatch -> PatchSet p Origin wX -> m () #

Rollback (i.e. apply the inverse) of what remains of a `PatchSet` after we extract a `PatchSetMatch`. This is the counterpart of `getOnePatchset` and is used to create a matching state. In particular, if the match is --index=n then rollback the last (n-1) patches; if the match is --tag, then rollback patches that are not depended on by the tag; otherwise rollback patches that follow the latest matching patch.

firstMatch :: [MatchFlag] -> Bool #

`firstMatch fs` tells whether `fs` implies a "first match", that is if we match against patches from a point in the past on, rather than against all patches since the creation of the repository.

secondMatch :: [MatchFlag] -> Bool #

`secondMatch fs` tells whether `fs` implies a "second match", that is if we match against patches up to a point in the past on, rather than against all patches until now.

haveNonrangeMatch :: [MatchFlag] -> Bool #

`haveNonrangeMatch flags` tells whether there is a flag in `flags` which corresponds to a match that is "non-range". Thus, `--match`, `--patch`, and `--hash` make `haveNonrangeMatch` true, but not `--from-patch` or `--to-patch`.

data PatchSetMatch #

Constructors

IndexMatch Int |
PatchMatch Matcher |
TagMatch Matcher |
ContextMatch AbsolutePath |

patchSetMatch :: [MatchFlag] -> Maybe PatchSetMatch #

checkMatchSyntax :: [MatchFlag] -> IO () #

hasIndexRange :: [MatchFlag] -> Maybe (Int, Int) #

getMatchingTag :: forall (p :: Type -> Type -> Type) wStart wX. MatchableRP p => Matcher -> PatchSet p wStart wX -> SealedPatchSet p wStart #

`getMatchingTag m ps`, where `m` is a `Matcher` which matches tags returns a `SealedPatchSet` containing all patches in the last tag which matches `m`. Last tag means the most recent tag in repository order, i.e. the last one you'd see if you ran darcs log -t `m`. Calls `error` if there is no matching tag.

matchAPatchset :: forall (p :: Type -> Type -> Type) wStart wX. MatchableRP p => Matcher -> PatchSet p wStart wX -> SealedPatchSet p wStart #

`matchAPatchset m ps` returns a prefix of `ps` ending in a patch matching `m`, and calls `error` if there is none.

data MatchFlag #

Constructors

OnePattern String |
SeveralPattern String |
AfterPattern String |
UpToPattern String |
OnePatch String |
SeveralPatch String |
AfterPatch String |
UpToPatch String |
OneHash String |
AfterHash String |
UpToHash String |
OneTag String |
SeveralTag String |
AfterTag String |
UpToTag String |
LastN Int |
OneIndex Int |
IndexRange Int Int |
Context AbsolutePath |

#### Instances

Instances details

Show MatchFlag # |
Instance details Defined in Darcs.Patch.Match Methods showsPrec :: Int -> MatchFlag -> ShowS # show :: MatchFlag -> String # showList :: [MatchFlag] -> ShowS #

matchingHead :: forall (p :: Type -> Type -> Type) wR. MatchableRP p => [MatchFlag] -> PatchSet p Origin wR -> (PatchSet p :> FL (PatchInfoAnd p)) Origin wR #

matchingHead returns the repository up to some tag. The tag t is the last tag such that there is a patch after t that is matched by the user's query.

type Matchable (p :: Type -> Type -> Type) = (Apply p, PatchInspect p, Ident p, PatchId p ~ PatchInfo) #

Patches that can be matched.

type MatchableRP (p :: Type -> Type -> Type) = (Apply p, Commute p, PatchInspect p) #

Constraint for a patch type `p` that ensures ``PatchInfoAnd` p` is `Matchable`.