[darcs-users] index format

Jason Dagit dagit at codersbase.com
Tue Jun 9 17:56:14 UTC 2009


On Tue, Jun 9, 2009 at 3:01 AM, Petr Rockai <me at mornfall.net> wrote:

> Eric Kow <kowey at darcs.net> writes:
> > I realise this is really more for Petr to say, but since I'm posting an
> update
> > email, I might as well mention that I noticed this patch just now:
> >
> > Tue Jun  9 08:02:02 BST 2009  Petr Rockai <me at mornfall.net>
> >   * Make peekItem safe even when dirlen is Nothing.
> >
> > And the updated version of peekItem
> >
> > peekItem :: ForeignPtr () -> Int -> Maybe Int -> IO Item
> > peekItem fp off dirlen =
> >     withForeignPtr fp $ \p -> do
> >       nl' :: Int32 <- peekByteOff p off
> >       let nl = fromIntegral nl'
> >           path = fromForeignPtr (castForeignPtr fp) (off + 4) (nl - 1)
> >           path_noslash = (BS.last path == '/') ? (BS.init path, path)
> >           hash = fromForeignPtr (castForeignPtr fp) (off + 4 + nl) 64
> >           name = snd $ case dirlen of
> >                          Just split -> BS.splitAt split path_noslash
> >                          Nothing -> BS.spanEnd (/= '/') path_noslash
> >       return $! Item { iName = name
> >                      , iPath = path
> >                      , iHash = hash
> >                      , iSize = plusPtr p (off + 4 + nl + 64)
> >                      , iAux = plusPtr p (off + 4 + nl + 64 + 8)
> >                      }
> >
> > No more undefined! Thanks!
>
> Well, we instead have a code line that's never executed (and never tested,
> so
> if it's buggy -- although I guess it's not -- people will get funny
> behaviour
> instead of a clear bug in the unlikely case they somehow use this code
> directly). I'm not sure it's very cool, but I guess the opposition to
> error/undefined is too strong for whatever reason. (I'm just wondering if
> one
> of these days when we get HPC reports of darcs, people will complain about
> never-executed code lines ...) And I guess we should now bury this
> discussion?


Hmm...Perhaps HPC is broken now, but several months ago it was pretty much
trivial to collect HPC reports from darcs.  I even included one in my thesis
because it was quick and easy.  Does anyone know the status of this now?
 Not related to the current thread, just curious if it still works.  Did the
switch to cabal make it harder?  I seem to recall it was just a special way
of running the the test suite that involved an environment variable and one
option to configure.


>
> Ahw about hyperlinks. As for tacking newlines between entries, I'm not sure
> it's really useful, since the file contains binary garbage in-between
> anyway. You can use "hd" or hexedit to conveniently look at the file
> contents. A tool for dumping the index content would be probably more
> useful
> though, and is trivial to write with hashed-storage. Also, you can look
> into
> your index with ghci:
>
>    ... > :m + Storage.Hashed.Tree Storage.Hashed.Index Storage.Hashed
>    ... > a <- readIndex "_darcs/index" >>= unfold
>    ... > printPath a ""
>    == Listing Tree  (immediates only):
>    install-sh
>    hpc.README
>    darcs.cabal
>
> [snip]
>
>    ... > printPath a "bugs"
>    == Listing Tree bugs (immediates only):
>    time-stamps.sh
>    record-scaling.sh
>    nfs-failure.sh
>    newlines.sh
>    merging_newlines.sh
>
> [snip]
>
> I guess I'll extend the listing format to include hashes and entry types.
> Maybe
> add specialised code to dump also timestamps (those are internal to the
> Index
> and there's no external interface to access them).


Oh, a tool to make the index human readable is a cool idea.  Please continue
working on this, time permitting.  It may be worthwhile making it part of
the darcs show command.  I could imagine people running:
darcs show index

As a sanity check while they develop trust for the index (it's important
that users are able to come to trust new features, otherwise, they may not
adopt the new feature!).

Jason
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osuosl.org/pipermail/darcs-users/attachments/20090609/3d50db87/attachment.htm>


More information about the darcs-users mailing list