[darcs-users] [patch264] Resolve issue1817: --external-merge broken, by bumping

Eric Kow kowey at darcs.net
Sun Jun 6 17:47:50 UTC 2010


Seems to make sense.  Applied (the version bump), thanks!

On Sun, Jun 06, 2010 at 14:39:29 +0000, Petr Ročkai wrote:
>  data IndexM m = Index { mmap :: (ForeignPtr ())
> +                      , basedir :: FilePath
>                        , hashtree :: Tree m -> Hash
>                        , predicate :: AnchoredPath -> TreeItem m -> Bool }

> @@ -291,7 +293,7 @@ readFile index state item =
>         size <- xlatePeek64 $ iSize item
>         let mtime' = modificationTime st
>             size' = fromIntegral $ fileSize st
> -           readblob = readSegment (BSC.unpack $ iPath item, Nothing)
> +           readblob = readSegment (basedir index </> BSC.unpack (iPath item), 

I'm assuming here that absolute path </> BSC.unpack (iPath item) always
does the right thing (and if I understand correctly, you would never
ever have anything like "..").

>  readIndex :: FilePath -> (Tree IO -> Hash) -> IO Index
>  readIndex indexpath ht = do
>    (mmap_ptr, mmap_size) <- mmapIndex indexpath 0
> +  base <- getCurrentDirectory
>    return $ if mmap_size == 0 then EmptyIndex
>                               else Index { mmap = mmap_ptr
> +                                        , basedir = base
>                                          , hashtree = ht
>                                          , predicate = \_ _ -> True }
> 

Basically, hold on the current working directory in case we cd somewhere
else in the meantime.

By the way, you may want to tweak the comment for readIndex to add an
example index path.

For the interested, darcs uses it like this:

I.readIndex "_darcs/index" darcsTreeHash

-- 
Eric Kow <http://www.nltg.brighton.ac.uk/home/Eric.Kow>
PGP Key ID: 08AC04F9
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
URL: <http://lists.osuosl.org/pipermail/darcs-users/attachments/20100606/7fc87191/attachment.pgp>


More information about the darcs-users mailing list