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

Safe HaskellNone
LanguageHaskell2010

Darcs.Repository

Contents

Synopsis

Documentation

data Repository p wRecordedstate wUnrecordedstate wTentativestate Source

A Repository is a token representing the state of a repository on disk. It is parameterized by the patch type in the repository, and witnesses for the recorded state of the repository (i.e. what darcs get would retrieve), the unrecorded state (what's in the working directory now), and the tentative state, which represents work in progress that will eventually become the new recorded state unless something goes wrong.

Instances

Show (Repository p wRecordedstate wUnrecordedstate wTentativestate) 

newtype Cache Source

Cache is an abstract type for hiding the underlying cache locations

Constructors

Ca [CacheLoc] 

Instances

data RepoJob a Source

A RepoJob wraps up an action to be performed with a repository. Because repositories can contain different types of patches, such actions typically need to be polymorphic in the kind of patch they work on. RepoJob is used to wrap up the polymorphism, and the various functions that act on a RepoJob are responsible for instantiating the underlying action with the appropriate patch type.

Constructors

RepoJob (forall p wR wU. (RepoPatch p, ApplyState p ~ Tree, ApplyState (PrimOf p) ~ Tree) => Repository p wR wU wR -> IO a)

The most common RepoJob; the underlying action can accept any patch type that a darcs repository may use.

V1Job (forall wR wU. Repository (Patch Prim) wR wU wR -> IO a)

A job that only works on darcs 1 patches

V2Job (forall wR wU. Repository (RealPatch Prim) wR wU wR -> IO a)

A job that only works on darcs 2 patches

PrimV1Job (forall p wR wU. (RepoPatch p, ApplyState p ~ Tree, PrimOf p ~ Prim) => Repository p wR wU wR -> IO a)

A job that works on any repository where the patch type p has PrimOf p = Prim.

This was added to support darcsden, which inspects the internals of V1 prim patches.

In future this should be replaced with a more abstract inspection API as part of PrimPatch.

RebaseAwareJob Compression Verbosity UpdateWorking (forall p wR wU. (RepoPatch p, ApplyState p ~ Tree, ApplyState (PrimOf p) ~ Tree, PrimOf (Named p) ~ PrimOf p) => Repository p wR wU wR -> IO a) 
RebaseJob Compression Verbosity UpdateWorking (forall p wR wU. (RepoPatch p, ApplyState p ~ Tree, ApplyState (PrimOf p) ~ Tree, PrimOf (Named p) ~ PrimOf p) => Repository (Rebasing p) wR wU wR -> IO a) 
StartRebaseJob Compression Verbosity UpdateWorking (forall p wR wU. (RepoPatch p, ApplyState p ~ Tree, ApplyState (PrimOf p) ~ Tree, PrimOf (Named p) ~ PrimOf p) => Repository (Rebasing p) wR wU wR -> IO a) 

maybeIdentifyRepository :: UseCache -> String -> IO (IdentifyRepo p wR wU wT) Source

Tries to identify the repository in a given directory

identifyRepositoryFor :: forall p wR wU wT vR vU vT. RepoPatch p => Repository p wR wU wT -> UseCache -> String -> IO (Repository p vR vU vT) Source

identifyRepositoryFor repo url identifies (and returns) the repo at url, but fails if it is not compatible for reading from and writing to.

withRecorded :: RepoPatch p => Repository p wR wU wT -> ((AbsolutePath -> IO a) -> IO a) -> (AbsolutePath -> IO a) -> IO a Source

withRepoLock :: DryRun -> UseCache -> UpdateWorking -> UMask -> RepoJob a -> IO a Source

apply a given RepoJob to a repository in the current working directory, taking a lock

withRepoLockCanFail :: UseCache -> UpdateWorking -> UMask -> RepoJob () -> IO () Source

apply a given RepoJob to a repository in the current working directory, taking a lock. If lock not takeable, do nothing.

withRepository :: UseCache -> RepoJob a -> IO a Source

apply a given RepoJob to a repository in the current working directory

withRepositoryDirectory :: UseCache -> String -> RepoJob a -> IO a Source

apply a given RepoJob to a repository in a given url

writePatchSet :: (RepoPatch p, ApplyState p ~ Tree) => PatchSet p Origin wX -> UseCache -> IO (Repository p wR wU wT) Source

writePatchSet is like patchSetToRepository, except that it doesn't touch the working directory or pristine cache.

replacePristine :: Repository p wR wU wT -> Tree IO -> IO () Source

Replace the existing pristine with a new one (loaded up in a Tree object).

readRepo :: (RepoPatch p, ApplyState p ~ Tree) => Repository p wR wU wT -> IO (PatchSet p Origin wR) Source

prefsUrl :: Repository p wR wU wT -> String Source

addToPending :: (RepoPatch p, ApplyState p ~ Tree) => Repository p wR wU wT -> UpdateWorking -> FL (PrimOf p) wU wY -> IO () Source

Add a FL of patches starting from the working state to the pending patch, including as much extra context as is necessary (context meaning dependencies), by commuting the patches to be added past as much of the changes between pending and working as is possible, and including anything that doesn't commute, and the patch itself in the new pending patch.

addPendingDiffToPending :: (RepoPatch p, ApplyState p ~ Tree) => Repository p wR wU wT -> UpdateWorking -> FreeLeft (FL (PrimOf p)) -> IO () Source

Add an FL of patches started from the pending state to the pending patch. TODO: add witnesses for pending so we can make the types precise: currently the passed patch can be applied in any context, not just after pending.

tentativelyAddToPending :: forall p wR wU wT wX wY. RepoPatch p => Repository p wR wU wT -> UpdateWorking -> FL (PrimOf p) wX wY -> IO () Source

tentativelyAddToPending repo NoDryRun YesUpdateWorking pend ps appends ps to the pending patch.

It has no effect with NoUpdateWorking.

This fuction is unsafe because it accepts a patch that works on the tentative pending and we don't currently track the state of the tentative pending.

tentativelyReplacePatches :: forall p wR wU wT wX. (RepoPatch p, ApplyState p ~ Tree) => Repository p wR wU wT -> Compression -> UpdateWorking -> Verbosity -> FL (PatchInfoAnd p) wX wT -> IO () Source

Given a sequence of patches anchored at the end of the current repository, actually pull them to the end of the repository by removing any patches with the same name and then adding the passed in sequence. Typically callers will have obtained the passed in sequence using findCommon and friends.

withManualRebaseUpdate :: forall p x wR wU wT1 wT2. (RepoPatch p, ApplyState p ~ Tree) => Compression -> Verbosity -> UpdateWorking -> Repository p wR wU wT1 -> (Repository p wR wU wT1 -> IO (Repository p wR wU wT2, FL (RebaseFixup p) wT2 wT1, x)) -> IO (Repository p wR wU wT2, x) Source

revertRepositoryChanges :: RepoPatch p => Repository p wR wU wT -> UpdateWorking -> IO () Source

Slightly confusingly named: as well as throwing away any tentative changes, revertRepositoryChanges also re-initialises the tentative state. It's therefore used before makign any changes to the repo.

patchSetToRepository :: (RepoPatch p, ApplyState p ~ Tree) => Repository p wR1 wU1 wR1 -> PatchSet p Origin wX -> UseCache -> RemoteDarcs -> IO () Source

patchSetToRepository takes a patch set, and writes a new repository in the current directory that contains all the patches in the patch set. This function is used when 'darcs get'ing a repository with the --to-match flag.

applyToWorking :: (ApplyState (PrimOf p) ~ Tree, RepoPatch p) => Repository p wR wU wT -> Verbosity -> FL (PrimOf p) wU wY -> IO (Repository p wR wY wT) Source

patchSetToPatches :: RepoPatch p => PatchSet p wX wY -> FL (Named p) wX wY Source

createPristineDirectoryTree :: RepoPatch p => Repository p wR wU wT -> FilePath -> WithWorkingDir -> IO () Source

grab the pristine hash of _darcs/hash_inventory, and retrieve whole pristine tree, possibly writing a clean working copy in the process.

createPartialsPristineDirectoryTree :: (FilePathLike fp, RepoPatch p) => Repository p wR wU wT -> [fp] -> FilePath -> IO () Source

Used by the commands dist and diff

reorderInventory :: (RepoPatch p, ApplyState p ~ Tree) => Repository p wR wU wR -> Compression -> UpdateWorking -> Verbosity -> IO () Source

Writes out a fresh copy of the inventory that minimizes the amount of inventory that need be downloaded when people pull from the repository.

Specifically, it breaks up the inventory on the most recent tag. This speeds up most commands when run remotely, both because a smaller file needs to be transfered (only the most recent inventory). It also gives a guarantee that all the patches prior to a given tag are included in that tag, so less commutation and history traversal is needed. This latter issue can become very important in large repositories.

cleanRepository :: RepoPatch p => Repository p wR wU wT -> IO () Source

data PatchSet p wStart wY Source

The patches in a repository are stored in chunks broken up at "clean" tags. A tag is clean if the only patches before it in the current repository ordering are ones that the tag depends on (either directly or indirectly). Each chunk is stored in a separate inventory file on disk.

A PatchSet represents a repo's history as the list of patches since the last clean tag, and then a list of patch lists each delimited by clean tags.

Instances

Show2 p => Show2 (PatchSet p) 
Show2 p => Show1 (PatchSet p wStart) 
Show2 p => Show (PatchSet p wStart wY) 

type SealedPatchSet p wStart = Sealed (PatchSet p wStart) Source

data PatchInfoAnd p wA wB Source

PatchInfoAnd p wA wB represents a hope we have to get a patch through its info. We're not sure we have the patch, but we know its info.

checkUnrelatedRepos :: RepoPatch p => Bool -> PatchSet p wStart wX -> PatchSet p wStart wY -> IO () Source

modifyCache :: forall p wR wU wT. RepoPatch p => Repository p wR wU wT -> (Cache -> Cache) -> Repository p wR wU wT Source

modifyCache repository function modifies the cache of repository with function, remove duplicates and sort the results with compareByLocality.

reportBadSources :: IO () Source

Prints an error message with a list of bad caches.

Recorded and unrecorded and pending.

readRecorded :: (RepoPatch p, ApplyState p ~ Tree) => Repository p wR wU wT -> IO (Tree IO) Source

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 wR wU wT -> Maybe [SubPath] -> IO (Tree IO) Source

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.

unrecordedChanges :: forall p wR wU wT. (RepoPatch p, ApplyState p ~ Tree) => (UseIndex, ScanKnown, DiffAlgorithm) -> Repository p wR wU wT -> Maybe [SubPath] -> IO (FL (PrimOf p) wT wU) Source

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).

unrecordedChangesWithPatches :: forall p wR wU wT wX. (RepoPatch p, ApplyState p ~ Tree, ApplyState (PrimOf p) ~ Tree) => (UseIndex, ScanKnown, DiffAlgorithm) -> Repository p wR wU wT -> Maybe [SubPath] -> FL (PrimOf p) wX wT -> FL (PrimOf p) wT wT -> IO (FL (PrimOf p) wT wU) Source

filterOutConflicts Source

Arguments

:: (RepoPatch p, ApplyState p ~ Tree) 
=> RL (PatchInfoAnd p) wX wT

Recorded patches from repository, starting from same context as the patches to filter

-> Repository p wR wU wT

Repository itself, used for grabbing unrecorded changes

-> FL (PatchInfoAnd p) wX wZ

Patches to filter

-> IO (Bool, Sealed (FL (PatchInfoAnd p) wX))

(True iff any patches were removed, possibly filtered patches)

Remove any patches (+dependencies) from a sequence that conflict with the recorded or unrecorded changes in a repo

readPending :: (RepoPatch p, ApplyState p ~ Tree) => Repository p wR wU wT -> IO (Tree IO, Sealed (FL p wT)) Source

Index.

invalidateIndex :: t -> IO () Source

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.)

Used as command arguments

listFiles :: Bool -> IO [String] Source

Get a list of all files and directories in the working copy, including boring files if necessary

listRegisteredFiles :: IO [String] Source

listRegisteredFiles returns the list of all registered files in the repository.

listUnregisteredFiles :: Bool -> IO [String] Source

listUnregisteredFiles returns the list of all non-boring unregistered files in the repository.