[darcs-users] darcs patch: Simplify and camel-case setSimplys. (and 4 more)

Kamil Dworakowski kamil at dworakowski.name
Wed Sep 23 08:05:02 UTC 2009


On Wed, Sep 23, 2009 at 7:48 AM, Eric Kow <kowey at darcs.net> wrote:
> On Tue, Sep 22, 2009 at 23:29:11 +0100, Kamil Dworakowski wrote:
>> darcs diff -u -p 'Add support for gui record.'
>>
>> This patch is much easier to understand than the current code. You can
>> see that this -1
>> is meaningless by analyzing the mode of usage of pull_first and pull_firsts.
>
> Also, perhaps you could elaborate on why you think this is meaningless?

Ah, now that I look at that patch the second time, it is actually much
simpler then
I though initially. Just need to understand pull_first and pull_firsts.

+pull_first :: EasyPC -> Maybe (Patch, EasyPC)
+pull_first [] = Nothing
+pull_first ((p,Just True,_):e) = Just (p,e)
+pull_first ((p,Just False,n):e) =
+    case pull_first e of Just (p2,e') -> case commute (p2,p) of
+                                         Just (p',p2') -> Just
(p2',((p',Just False,n):e'))
+                                         Nothing -> error "Aaack fixme!"
+                         Nothing -> Nothing
+pull_first ((p,Nothing,n):e) =
+    case pull_first e of Just (p2,e') -> case commute (p2,p) of
+                                         Just (p',p2') -> Just
(p2',((p',Just False,n):e'))
+                                         Nothing -> Just (p,((p2,Just
True,-1):e'))
+                         Nothing -> Nothing

The InFirst patch that depends on and InMiddle patch gets tagged -1. The
actual intention is to return InFirst patch and all InMiddle that depend on
it. Note: InFirst and InMiddle terminology is from the pristine, I just got
used to thinking about the selection that way. Here Just True corresponds
to InFirst, Nothing to InMiddle.


pull_first is only used by pull_firsts


+pull_firsts :: EasyPC -> ([Patch], EasyPC)
+pull_firsts e = case pull_first e of
+                Nothing -> ([],e)
+                Just (p,e') -> case pull_firsts e' of
+                               (ps,e'') -> (p:ps,e'')

All InFirst and dependant on them InMiddle patches are included in
the first field of tha pair. It has no tag information, ergo
those -1s get forgotten.


> It sounds like we could replace negTag with forgetTag restoring the -1
> behaviour (depending on whether Ian chimes in to point out that it
> actually is meaningful).

Just not change the tag at all. The negation serves no purpose.

--
Cheers,
Kamil


More information about the darcs-users mailing list