Here you are, sir... Reinier
> [Simpler types for changes --summary. > Eric Kow <[email protected]>**20090818213946 > Ignore-this: 22fdc7984753eedf3d35ff88762a2eb2 > ] hunk ./src/Darcs/Patch/Viewing.hs 147 > -- | High-level representation of a piece of patch summary > -data SummChunk = SummChunk FileName SummDetail ConflictState > +data SummChunk = SummChunk SummDetail ConflictState > deriving (Ord, Eq) > > hunk ./src/Darcs/Patch/Viewing.hs 150 > -data SummDetail = SummAddDir > - | SummRmDir > - | SummFile SummOp Int Int Int > - | SummMv FileName > +data SummDetail = SummAddDir FileName > + | SummRmDir FileName > + | SummFile SummOp FileName Int Int Int > + | SummMv FileName FileName > | SummNone > deriving (Ord, Eq) > > hunk ./src/Darcs/Patch/Viewing.hs 163 > genSummary p > = combine $ concatMap s2 p > where s2 :: IsConflictedPrim -> [SummChunk] > - s2 (IsC c x) = map (\(f,d) -> SummChunk f d c) $ s x > - s :: Prim C(x y) -> [(FileName,SummDetail)] > - s (FP f (Hunk _ o n)) = [(f,SummFile SummMod (length o) (length n) 0)] > - s (FP f (Binary _ _)) = [(f,SummNone)] > - s (FP f AddFile) = [(f,SummFile SummAdd 0 0 0)] > - s (FP f RmFile) = [(f,SummFile SummRm 0 0 0)] > - s (FP f (TokReplace _ _ _)) = [(f,SummFile SummMod 0 0 1)] > - s (DP d AddDir) = [(d,SummAddDir)] > - s (DP d RmDir) = [(d,SummRmDir)] > + s2 (IsC c x) = map (\d -> SummChunk d c) $ s x > + s :: Prim C(x y) -> [SummDetail] > + s (FP f (Hunk _ o n)) = [SummFile SummMod f (length o) (length n) 0] > + s (FP f (Binary _ _)) = [SummFile SummMod f 0 0 0] > + s (FP f AddFile) = [SummFile SummAdd f 0 0 0] > + s (FP f RmFile) = [SummFile SummRm f 0 0 0] > + s (FP f (TokReplace _ _ _)) = [SummFile SummMod f 0 0 1] > + s (DP d AddDir) = [SummAddDir d] > + s (DP d RmDir) = [SummRmDir d] > s (Split xs) = concat $ mapFL s xs > hunk ./src/Darcs/Patch/Viewing.hs 173 > - s (Move f1 f2) = [(f1,SummMv f2)] > - s (ChangePref _ _ _) = [(fp2fn "",SummNone)] > - s Identity = [(fp2fn "",SummNone)] > - combine (x1@(SummChunk f1 d1 c1) : x2@(SummChunk f2 d2 c2) : ss) > - | f1 == f2 = case combineDetail d1 d2 of > - Nothing -> x1 : combine (x2:ss) > - Just d3 -> combine $ SummChunk f1 d3 (combineConflitStates c1 c2) : ss > + s (Move f1 f2) = [SummMv f1 f2] > + s (ChangePref _ _ _) = [SummNone] > + s Identity = [SummNone] > + combine (x1@(SummChunk d1 c1) : x2@(SummChunk d2 c2) : ss) > + = case combineDetail d1 d2 of > + Nothing -> x1 : combine (x2:ss) > + Just d3 -> combine $ SummChunk d3 (combineConflitStates c1 c2) : ss Smart thing, at least for the readability of this bit of code, to move the FileName argument into the SummDetail constructor. Maybe you could turn the case statement into a guard so the Nothing case will be handled by the other clause for combine? > hunk ./src/Darcs/Patch/Viewing.hs 183 > - combineDetail (SummFile o1 r1 a1 x1) (SummFile o2 r2 a2 x2) = > + combineDetail (SummFile o1 f1 r1 a1 x1) (SummFile o2 f2 r2 a2 x2) | f1 == f2 = > do o3 <- combineOp o1 o2 > hunk ./src/Darcs/Patch/Viewing.hs 185 > - return $ SummFile o3 (r1 + r2) (a1 + a2) (x1 + x2) > + return $ SummFile o3 f1 (r1 + r2) (a1 + a2) (x1 + x2) Move the filename equality check down in the call stack, because it is deeper in the data structure now. OK. > hunk ./src/Darcs/Patch/Viewing.hs 204 > combineOp SummMod SummMod = Just SummMod > > summChunkToXML :: SummChunk -> Doc > -summChunkToXML (SummChunk f chunk c) = > - case chunk of > - SummRmDir -> xconf c "remove_directory" (xfn f) > - SummAddDir -> xconf c "add_directory" (xfn f) > - SummFile SummRm _ _ _ -> xconf c "remove_file" (xfn f) > - SummFile SummAdd _ _ _ -> xconf c "add_file" (xfn f) > - SummFile SummMod r a x -> xconf c "modify_file" $ xfn f <> xrm r <> xad a <> xrp x > - SummMv f2 -> text "<move from=\"" <> xfn f > - <> text "\" to=\"" <> xfn f2 <> text"\"/>" > +summChunkToXML (SummChunk detail c) = > + case detail of > + SummRmDir f -> xconf c "remove_directory" (xfn f) > + SummAddDir f -> xconf c "add_directory" (xfn f) > + SummFile SummRm f _ _ _ -> xconf c "remove_file" (xfn f) > + SummFile SummAdd f _ _ _ -> xconf c "add_file" (xfn f) > + SummFile SummMod f r a x -> xconf c "modify_file" $ xfn f <> xrm r <> xad a <> xrp x > + SummMv f1 f2 -> text "<move from=\"" <> xfn f1 > + <> text "\" to=\"" <> xfn f2 <> text"\"/>" > hunk ./src/Darcs/Patch/Viewing.hs 228 > summChunkToLine :: SummChunk -> Doc > -summChunkToLine (SummChunk f chunk c) = > - case chunk of > - SummRmDir -> lconf c "R" $ text (fn2fp f) <> text "/" > - SummAddDir -> lconf c "A" $ text (fn2fp f) <> text "/" > - SummFile SummRm _ _ _ -> lconf c "R" $ text (fn2fp f) > - SummFile SummAdd _ _ _ -> lconf c "A" $ text (fn2fp f) > - SummFile SummMod r a x -> lconf c "M" $ text (fn2fp f) <+> rm r <+> ad a <+> rp x > - SummMv f2 -> text " " <> text (fn2fp f) > - <> text " -> " <> text (fn2fp f2) > +summChunkToLine (SummChunk detail c) = > + case detail of > + SummRmDir f -> lconf c "R" $ text (fn2fp f) <> text "/" > + SummAddDir f -> lconf c "A" $ text (fn2fp f) <> text "/" > + SummFile SummRm f _ _ _ -> lconf c "R" $ text (fn2fp f) > + SummFile SummAdd f _ _ _ -> lconf c "A" $ text (fn2fp f) > + SummFile SummMod f r a x -> lconf c "M" $ text (fn2fp f) <+> rm r <+> ad a <+> rp x > + SummMv f1 f2 -> text " " <> text (fn2fp f1) > + <> text " -> " <> text (fn2fp f2) Nothing surprising. > [Cut unused imports in Darcs.Patch.Viewing. > Eric Kow <[email protected]>**20090818214432 > Ignore-this: f83f5ce55279a5b96a14770dbcb7dd0b > ] hunk ./src/Darcs/Patch/Viewing.hs 26 > -import Data.List ( sort ) > hunk ./src/Darcs/Patch/Viewing.hs 30 > -import Darcs.Patch.FileName ( FileName, fp2fn, fn2fp ) > +import Darcs.Patch.FileName ( FileName, fn2fp ) Nothing surprising. > [Rename xml_summary to xmlSummary and summarize to plainSummary. > Eric Kow <[email protected]>**20090818220119 > Ignore-this: b1e29f45f0599a406ffb6496acac2488 > ] replace ./src/Darcs/Arguments.lhs [A-Za-z_0-9] xml_summary xmlSummary > replace ./src/Darcs/Commands/Annotate.lhs [A-Za-z_0-9] xml_summary xmlSummary > replace ./src/Darcs/Commands/Changes.lhs [A-Za-z_0-9] xml_summary xmlSummary > replace ./src/Darcs/Commands/WhatsNew.lhs [A-Za-z_0-9] summarize plainSummary > replace ./src/Darcs/Patch.lhs [A-Za-z_0-9] summarize plainSummary > replace ./src/Darcs/Patch.lhs [A-Za-z_0-9] xml_summary xmlSummary > replace ./src/Darcs/Patch/Viewing.hs [A-Za-z_0-9] summarize plainSummary > replace ./src/Darcs/Patch/Viewing.hs [A-Za-z_0-9] xml_summary xmlSummary Are replace patches actually useful, and not some historical curiosity? I used to be somewhat afraid of them for some reason. Will it do the right thing if someone later adds a comment 'this used to be called xml_summary', and the comment-adding patch and the replace patch are commuted back and forth? But even if replace patches are deprecated, it would be good dogfood.
signature.asc
Description: This is a digitally signed message part.
_______________________________________________ darcs-users mailing list [email protected] http://lists.osuosl.org/mailman/listinfo/darcs-users
