On Wed, Jun 10, 2009 at 01:01:25 +0200, Reinier Lamers wrote:
> This fixes all of the unit test failures in the command that first generated 
> five:
> 
>   dist/build/unit/unit -r '1387922338 2147483372,86'
> 
> I optimistically assume that this fixes all of issue 1412, but you are of
> course welcome to re-open it if you still see unit test failures.
> 
> The problem was that the patch checking code in Darcs/Patch/Check.hs did not
> accurately track the highest known line number in a file, so that file_empty
> could falsely return True, so that binary patches and remove-file patches
> were allowed by the checking code in places where they should not have been
> allowed.

Applied, thanks for the helpful explanation.

I'm going to insert more context for the interested:

|  insert_line :: String -> Int -> B.ByteString -> PatchCheck Bool
|  insert_line f n l = do
|      c <- file_contents f
|      case c of
|        Nothing -> assert_not $ FileEx f -- in this case, the repo is 
inconsistent
>        Just c' -> do
>          let lines'  = M.mapKeys (\k -> if k >= n then k+1 else k) (fc_lines 
> c')
>              lines'' = M.insert n l lines'
> -        set_contents f (c' { fc_lines = lines'' })
> +            maxline' | fc_maxline c' >= n = fc_maxline c'
> +                     | otherwise          = n
> +        set_contents f (c' { fc_lines = lines'', fc_maxline = maxline' })
|          return True
 
I'm guessing fc_maxline = max n (fc_maxline c') would have been equivalent,
not that it really matters here.

Idle chatter: It's a funny thing with unit tests, that we often spend a lot of
time having to fix our tests...  it pays off, of course, because we get
infinite re-use and also because refining a test often is the result of getting
a better understanding of our implicit assumptions (though this doesn't seem to
be the case here)

-- 
Eric Kow <http://www.nltg.brighton.ac.uk/home/Eric.Kow>
PGP Key ID: 08AC04F9

Attachment: signature.asc
Description: Digital signature

_______________________________________________
darcs-users mailing list
[email protected]
http://lists.osuosl.org/mailman/listinfo/darcs-users

Reply via email to