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

Safe Haskell | None

Darcs.Repository.State

Contents

- Diffs.
- Trees.
- Index.

Synopsis

- restrictSubpaths :: forall p m r u t. (RepoPatch p, ApplyState p ~ Tree) => Repository p r u t -> [SubPath] -> IO (TreeFilter m)
- restrictBoring :: forall m. Tree m -> IO (TreeFilter m)
- newtype TreeFilter m = TreeFilter {
  - applyTreeFilter :: forall tr. FilterTree tr m => tr m -> tr m
  }
- unrecordedChanges :: forall p r u t. (RepoPatch p, ApplyState p ~ Tree) => (UseIndex, ScanKnown) -> Repository p r u t -> Maybe [SubPath] -> IO (FL (PrimOf p) t u)
- readPending :: (RepoPatch p, ApplyState p ~ Tree) => Repository p r u t -> IO (Tree IO, Sealed (FL p t))
- readRecorded :: (RepoPatch p, ApplyState p ~ Tree) => Repository p r u t -> IO (Tree IO)
- readUnrecorded :: (RepoPatch p, ApplyState p ~ Tree) => Repository p r u t -> Maybe [SubPath] -> IO (Tree IO)
- readRecordedAndPending :: (RepoPatch p, ApplyState p ~ Tree) => Repository p r u t -> IO (Tree IO)
- readWorking :: IO (Tree IO)
- readIndex :: (RepoPatch p, ApplyState p ~ Tree) => Repository p r u t -> IO Index
- invalidateIndex :: t -> IO ()
- data UseIndex
  - = UseIndex
  - | IgnoreIndex
- data ScanKnown
  - = ScanKnown
  - | ScanAll
  - | ScanBoring

# Documentation

restrictSubpaths :: forall p m r u t. (RepoPatch p, ApplyState p ~ Tree) => Repository p r u t -> [SubPath] -> IO (TreeFilter m)

From a repository and a list of SubPath's, construct a filter that can be used on a Tree (recorded or unrecorded state) of this repository. This constructed filter will take pending into account, so the subpaths will be translated correctly relative to pending move patches.

restrictBoring :: forall m. Tree m -> IO (TreeFilter m)

Construct a Tree filter that removes any boring files the Tree might have contained. Additionally, you should (in most cases) pass an (expanded) Tree that corresponds to the recorded content of the repository. This is important in the cases when the repository contains files that would be boring otherwise. (If you pass emptyTree instead, such files will simply be discarded by the filter, which is usually not what you want.)

This function is most useful when you have a plain Tree corresponding to the full working copy of the repository, including untracked files. Cf. whatsnew, record --look-for-adds. NB. Assumes that our CWD is the repository root.

newtype TreeFilter m

Constructors

TreeFilter |
Fields applyTreeFilter :: forall tr. FilterTree tr m => tr m -> tr m

# Diffs.

unrecordedChanges :: forall p r u t. (RepoPatch p, ApplyState p ~ Tree) => (UseIndex, ScanKnown) -> Repository p r u t -> Maybe [SubPath] -> IO (FL (PrimOf p) t u)

For a repository and an optional list of paths (when Nothing, take everything) compute a (forward) list of prims (i.e. a patch) going from the recorded state of the repository (pristine) to the unrecorded state of the repository (the working copy + pending). When a list of paths is given, at least the files that live under any of these paths in either recorded or unrecorded will be included in the resulting patch. NB. More patches may be included in this list, eg. the full contents of the pending patch. This is usually not a problem, since selectChanges will properly filter the results anyway.

This also depends on the options given: with LookForAdds, we will include any non-boring files (i.e. also those that do not exist in the recorded state) in the working in the unrecorded state, and therefore they will show up in the patches as addfiles.

The IgnoreTimes option disables index usage completely -- for each file, we read both the unrecorded and the recorded copy and run a diff on them. This is very inefficient, although in extremely rare cases, the index could go out of sync (file is modified, index is updated and file is modified again within a single second).

readPending :: (RepoPatch p, ApplyState p ~ Tree) => Repository p r u t -> IO (Tree IO, Sealed (FL p t))

# Trees.

readRecorded :: (RepoPatch p, ApplyState p ~ Tree) => Repository p r u t -> IO (Tree IO)

Obtains a Tree corresponding to the recorded state of the repository: this is the same as the pristine cache, which is the same as the result of applying all the repository's patches to an empty directory.

Handles the plain and hashed pristine cases. Currently does not handle the no-pristine case, as that requires replaying patches. Cf. `readDarcsHashed` and `readPlainTree` in hashed-storage that are used to do the actual `Tree` construction.

readUnrecorded :: (RepoPatch p, ApplyState p ~ Tree) => Repository p r u t -> Maybe [SubPath] -> IO (Tree IO)

Obtains a Tree corresponding to the unrecorded state of the repository: the working tree plus the pending patch. The optional list of paths allows to restrict the query to a subtree.

Limiting the query may be more efficient, since hashes on the uninteresting parts of the index do not need to go through an up-to-date check (which involves a relatively expensive lstat(2) per file.

readRecordedAndPending :: (RepoPatch p, ApplyState p ~ Tree) => Repository p r u t -> IO (Tree IO)

readWorking :: IO (Tree IO)

Obtains a Tree corresponding to the working copy of the repository. NB. Almost always, using readUnrecorded is the right choice. This function is only useful in not-completely-constructed repositories.

# Index.

readIndex :: (RepoPatch p, ApplyState p ~ Tree) => Repository p r u t -> IO Index

invalidateIndex :: t -> IO ()

Mark the existing index as invalid. This has to be called whenever the listing of pristine changes and will cause darcs to update the index next time it tries to read it. (NB. This is about files added and removed from pristine: changes to file content in either pristine or working are handled transparently by the index reading code.)

data UseIndex

Constructors

UseIndex |
IgnoreIndex |

data ScanKnown

Constructors

ScanKnown | Just files already known to darcs
ScanAll | All files, i.e. look for new ones
ScanBoring | All files, even boring ones