New submission from Ben Franksen <[email protected]>: Not yet for screened.
2 patches for repository https://darcs.net/screened: patch 2159739d094e27a667914f1ca38b06c0517cf18c Author: Ben Franksen <[email protected]> Date: Fri Nov 1 15:19:27 CET 2024 * lower the upper bound for http-client-tls Otherwise ghc-9.8 cannot build http-client-tls. patch aee31c5c5579e8d277f75182aec9d17cf35f8a78 Author: Ben Franksen <[email protected]> Date: Mon Nov 4 19:24:44 CET 2024 * WIP resolve issue2732: generate XML using the xml package This patch is supposed to replace all the manually generated XML with uses of the xml package. ---------- files: lower-the-upper-bound-for-http_client_tls.dpatch, patch-preview.txt messages: 24093 nosy: bfrk status: needs-screening title: lower the upper bound for http-client-tls (and 1 more) __________________________________ Darcs bug tracker <[email protected]> <https://bugs.darcs.net/patch2425> __________________________________
[lower the upper bound for http-client-tls Ben Franksen <[email protected]>**20241101141927 Ignore-this: a44fb285753a2332a35164219ccc3f3320cb9ec80233ed47cb5445b9b79e89375d8efc1e5b0ba437 Otherwise ghc-9.8 cannot build http-client-tls. ] hunk ./darcs.cabal 465 - http-client-tls >= 0.3.5 && < 0.4, + http-client-tls >= 0.3.5 && < 0.3.6.4, [WIP resolve issue2732: generate XML using the xml package Ben Franksen <[email protected]>**20241104182444 Ignore-this: 29d45fb01c8e10b94f59d8f08b095c86fc0f8f92b7056ef2ebc27dc8f57e63dc01cac8560d5df9bf This patch is supposed to replace all the manually generated XML with uses of the xml package. ] hunk ./darcs.cabal 452 + xml >= 1.3.14 && < 1.4, hunk ./src/Darcs/Patch/Info.hs 60 - , unlinesPS hunk ./src/Darcs/Patch/Info.hs 69 -import qualified Data.ByteString as B (length, splitAt, null - ,isPrefixOf, tail, concat - ,empty, head, cons, append +import qualified Data.ByteString as B (length, splitAt + ,isPrefixOf, concat hunk ./src/Darcs/Patch/Info.hs 73 - ( index, head, notElem, all, unpack, pack ) + ( index, notElem, all, unpack, pack ) hunk ./src/Darcs/Patch/Info.hs 77 +import qualified Text.XML.Light as XML hunk ./src/Darcs/Patch/Info.hs 80 - empty, ($$), (<+>), vcat, text, cyanText, blueText, prefix ) + empty, ($$), (<+>), vcat, text, cyanText, blueText ) hunk ./src/Darcs/Patch/Info.hs 319 -toXml :: PatchInfo -> Doc +toXml :: PatchInfo -> XML.Element hunk ./src/Darcs/Patch/Info.hs 322 -toXmlShort :: PatchInfo -> Doc +toXmlShort :: PatchInfo -> XML.Element hunk ./src/Darcs/Patch/Info.hs 325 -toXml' :: Bool -> PatchInfo -> Doc +toXml' :: Bool -> PatchInfo -> XML.Element hunk ./src/Darcs/Patch/Info.hs 327 - text "<patch" - <+> text "author='" <> escapeXMLByteString (_piAuthor pi) <> text "'" - <+> text "date='" <> escapeXMLByteString (_piDate pi) <> text "'" - <+> text "local_date='" <> escapeXML (friendlyD $ _piDate pi) <> text "'" - <+> text "inverted='" <> text (show $ _piLegacyIsInverted pi) <> text "'" - <+> text "hash='" <> text (show $ makePatchname pi) <> text "'>" - $$ indent abstract - $$ text "</patch>" - where - indent = prefix " " - name = text "<name>" <> escapeXMLByteString (_piName pi) <> text "</name>" - abstract | includeComments = name $$ commentsAsXml (_piLog pi) - | otherwise = name - -commentsAsXml :: [B.ByteString] -> Doc -commentsAsXml comments - | B.length comments' > 0 = text "<comment>" - <> escapeXMLByteString comments' - <> text "</comment>" - | otherwise = empty - where comments' = unlinesPS comments + XML.unode "patch" + ( [ XML.Attr (XML.unqual "author") (piAuthor pi) + , XML.Attr (XML.unqual "date") (piDateString pi) + , XML.Attr (XML.unqual "local_date") (friendlyD $ _piDate pi) + , XML.Attr (XML.unqual "inverted") (show $ _piLegacyIsInverted pi) + , XML.Attr (XML.unqual "hash") (show $ makePatchname pi) + ] + , [ XML.unode "name" $ piName pi ] ++ comments + ) + where + -- note that this is supposed to list junk as well, which is why piLog is not + -- appropriate here + comments + | includeComments = map (XML.unode "comment") (map metadataToString $ _piLog pi) + | otherwise = [] hunk ./src/Darcs/Patch/Info.hs 349 --- Escape XML characters in a UTF-8 encoded ByteString, and turn it into a Doc. --- The data will be in the Doc as a bytestring. -escapeXMLByteString :: B.ByteString -> Doc -escapeXMLByteString = packedString . bstrReplace '\'' "'" - . bstrReplace '"' """ - . bstrReplace '>' ">" - . bstrReplace '<' "<" - . bstrReplace '&' "&" - hunk ./src/Darcs/Patch/Info.hs 355 -bstrReplace :: Char -> String -> B.ByteString -> B.ByteString -bstrReplace c s bs | B.null bs = B.empty - | otherwise = if BC.head bs == c - then B.append (BC.pack s) - (bstrReplace c s (B.tail bs)) - else B.cons (B.head bs) - (bstrReplace c s (B.tail bs)) - hunk ./src/Darcs/Patch/Summary.hs 17 +import qualified Text.XML.Light as XML hunk ./src/Darcs/Patch/Summary.hs 79 -xmlSummary :: (Summary p, PrimDetails (PrimOf p)) => p wX wY -> Doc -xmlSummary p = text "<summary>" - $$ (vcat . map summChunkToXML . genSummary . conflictedEffect $ p) - $$ text "</summary>" - --- Yuck duplicated code below... -escapeXML :: String -> Doc -escapeXML = text . strReplace '\'' "'" . strReplace '"' """ . - strReplace '>' ">" . strReplace '<' "<" . strReplace '&' "&" - -strReplace :: Char -> String -> String -> String -strReplace _ _ [] = [] -strReplace x y (z:zs) - | x == z = y ++ strReplace x y zs - | otherwise = z : strReplace x y zs --- end yuck duplicated code. +xmlSummary :: (Summary p, PrimDetails (PrimOf p)) => p wX wY -> XML.Element +xmlSummary p = XML.unode "summary" (catMaybes . map summChunkToXML . genSummary . conflictedEffect $ p) hunk ./src/Darcs/Patch/Summary.hs 118 -summChunkToXML :: SummChunk -> Doc +summChunkToXML :: SummChunk -> Maybe XML.Element hunk ./src/Darcs/Patch/Summary.hs 120 - 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"\"/>" - SummNone -> empty - where - xconf Okay t x = text ('<':t++">") $$ x $$ text ("</"++t++">") - xconf Conflicted t x = text ('<':t++" conflict='true'>") $$ x $$ text ("</"++t++">") - xconf Duplicated t x = text ('<':t++" duplicate='true'>") $$ x $$ text ("</"++t++">") - xfn = escapeXML . anchorPath "" - -- - xad 0 = empty - xad a = text "<added_lines num='" <> text (show a) <> text "'/>" - xrm 0 = empty - xrm a = text "<removed_lines num='" <> text (show a) <> text "'/>" - xrp 0 = empty - xrp a = text "<replaced_tokens num='" <> text (show a) <> text "'/>" + case detail of + SummRmDir f -> Just $ xconf c "remove_directory" [] [cdata (xfn f)] + SummAddDir f -> Just $ xconf c "add_directory" [] [cdata (xfn f)] + SummFile SummRm f _ _ _ -> Just $ xconf c "remove_file" [] [cdata (xfn f)] + SummFile SummAdd f _ _ _ -> Just $ xconf c "add_file" [] [cdata (xfn f)] + SummFile SummMod f r a x -> + Just $ xconf c "modify_file" [] ([cdata (xfn f)] <> xrm r <> xad a <> xrp x) + SummMv f1 f2 -> + Just $ + xconf c "move" + [XML.Attr (XML.unqual "from") (xfn f1), XML.Attr (XML.unqual "to") (xfn f2)] [] + SummNone -> Nothing + where + xconf :: ConflictState -> String -> [XML.Attr] -> [XML.Content] -> XML.Element + xconf Okay t as cs = XML.unode t (as, cs) + xconf Conflicted t as cs = + XML.unode t (XML.Attr (XML.unqual "conflict") "true":as, cs) + xconf Duplicated t as cs = + XML.unode t (XML.Attr (XML.unqual "suplicate") "true":as, cs) + xfn = anchorPath "" + cdata s = XML.Text (XML.blank_cdata {XML.cdData = s}) + xad 0 = [] + xad a = [XML.Elem $ XML.unode "added_lines" (XML.Attr (XML.unqual "num=") (show a))] + xrm 0 = [] + xrm a = [XML.Elem $ XML.unode "removed_lines" (XML.Attr (XML.unqual "num=") (show a))] + xrp 0 = [] + xrp a = [XML.Elem $ XML.unode "replaced_tokens" (XML.Attr (XML.unqual "num=") (show a))] hunk ./src/Darcs/UI/Commands/Log.hs 35 +import qualified Text.XML.Light as XML hunk ./src/Darcs/UI/Commands/Log.hs 66 -import Darcs.Patch.Info ( toXml, toXmlShort, showPatchInfo, displayPatchInfo, escapeXML, PatchInfo ) +import Darcs.Patch.Info ( toXml, toXmlShort, showPatchInfo, displayPatchInfo, PatchInfo ) hunk ./src/Darcs/UI/Commands/Log.hs 96 + , fromXml hunk ./src/Darcs/UI/Commands/Log.hs 98 - , insertBeforeLastline hunk ./src/Darcs/UI/Commands/Log.hs 101 - , vcat hunk ./src/Darcs/UI/Commands/Log.hs 376 - | hasXmlOutput opts = xml_changelog + | hasXmlOutput opts = fromXml xml_changelog hunk ./src/Darcs/UI/Commands/Log.hs 390 - xml_changelog = vcat - [ text "<changelog>" - , vcat xml_created_as - , vcat xml_changes - , text "</changelog>" - ] - - xml_with_summary :: Sealed2 (PatchInfoAndG p) -> Doc + xml_changelog = XML.unode "changelog" (xml_created_as ++ xml_changes) + + xml_with_summary :: Sealed2 (PatchInfoAndG p) -> XML.Element hunk ./src/Darcs/UI/Commands/Log.hs 394 - let - deps = getdeps p - xmlDependencies = - text "<explicit_dependencies>" - $$ vcat (map (indent . toXmlShort) deps) - $$ text "</explicit_dependencies>" - summary | deps == [] = indent $ xmlSummary p - | otherwise = indent $ xmlDependencies $$ xmlSummary p - in - insertBeforeLastline (toXml $ info hp) summary + let + deps = getdeps p + xmlDeps = XML.unode "explicit_dependencies" (map toXmlShort deps) + summary | null deps = [xmlSummary p] + | otherwise = [xmlDeps] ++ [xmlSummary p] + xml_info = toXml $ info hp + in + xml_info { XML.elContent = XML.elContent xml_info ++ map XML.Elem summary } hunk ./src/Darcs/UI/Commands/Log.hs 404 + xml_changes :: [XML.Element] hunk ./src/Darcs/UI/Commands/Log.hs 409 + xml_created_as :: [XML.Element] hunk ./src/Darcs/UI/Commands/Log.hs 411 - create :: (AnchoredPath, AnchoredPath) -> Doc + create :: (AnchoredPath, AnchoredPath) -> XML.Element hunk ./src/Darcs/UI/Commands/Log.hs 455 -createdAsXml :: PatchInfo -> (AnchoredPath, AnchoredPath) -> Doc +createdAsXml :: PatchInfo -> (AnchoredPath, AnchoredPath) -> XML.Element hunk ./src/Darcs/UI/Commands/Log.hs 457 - text "<created_as current_name='" - <> escapeXML (displayPath current) - <> text "' original_name='" - <> escapeXML (displayPath createdAs) - <> text "'>" - $$ toXml pinfo - $$ text "</created_as>" + XML.unode "created_as" + ( [ XML.Attr (XML.unqual "current_name") (displayPath current) + , XML.Attr (XML.unqual "original_name") (displayPath createdAs) + ] + , toXml pinfo + ) hunk ./src/Darcs/UI/Commands/Util.hs 46 +import qualified Text.XML.Light as XML + hunk ./src/Darcs/UI/Commands/Util.hs 96 - ( Doc, formatWords, ($+$), text, (<+>), hsep, ($$), vcat, vsep - , putDocLn, insertBeforeLastline, prefix + ( Doc, formatWords, ($+$), text, (<+>), hsep, ($$), vsep + , putDocLn, fromXml hunk ./src/Darcs/UI/Commands/Util.hs 152 - put_mode = if x == YesXml - then text "<patches>" $$ - vcat (mapFL (indent . xml_info s) patches) $$ - text "</patches>" - else vsep $ mapFL (showFriendly v s) patches + put_mode = + if x == YesXml + then + fromXml $ XML.unode "patches" $ mapFL (xml_info s) patches + else vsep $ mapFL (showFriendly v s) patches hunk ./src/Darcs/UI/Commands/Util.hs 160 - xml_info YesSummary = xml_with_summary - xml_info NoSummary = toXml . info - - xml_with_summary hp - | Just p <- hopefullyM hp = insertBeforeLastline (toXml $ info hp) - (indent $ xmlSummary p) - xml_with_summary hp = toXml (info hp) - - indent = prefix " " + xml_info YesSummary hp + | Just p <- hopefullyM hp = + let el = toXml (info hp) + in el { XML.elContent = XML.elContent el ++ [XML.Elem (xmlSummary p)] } + xml_info _ hp = toXml (info hp) hunk ./src/Darcs/UI/Commands.hs 61 +import qualified Text.XML.Light as XML hunk ./src/Darcs/UI/Commands.hs 101 - ( Doc, text, (<+>), ($$), ($+$), hsep, vcat + ( Doc, text, (<+>), ($+$), hsep hunk ./src/Darcs/UI/Commands.hs 316 - setEnvCautiously "DARCS_PATCHES_XML" . renderString $ - text "<patches>" $$ - vcat (mapFL (toXml . info) ps) $$ - text "</patches>" + setEnvCautiously + "DARCS_PATCHES_XML" $ + XML.ppElement $ XML.unode "patches" $ mapFL (toXml . info) ps hunk ./src/Darcs/Util/Printer.hs 25 - , insertBeforeLastline hunk ./src/Darcs/Util/Printer.hs 27 + , fromXml hunk ./src/Darcs/Util/Printer.hs 63 +import qualified Text.XML.Light as XML hunk ./src/Darcs/Util/Printer.hs 278 --- TODO try to find another way to do this, it's rather a violation --- of the Doc abstraction -insertBeforeLastline :: Doc -> Doc -> Doc -insertBeforeLastline a b = - case reverse $ map packedString $ linesPS $ renderPS a of - (ll:ls) -> vcat (reverse ls) $$ b $$ ll - [] -> - error "empty Doc given as first argument of Printer.insert_before_last_line" - hunk ./src/Darcs/Util/Printer.hs 529 + +fromXml :: XML.Element -> Doc +fromXml = text . XML.ppElement hunk ./tests/clone.sh 97 -firsthash=`darcs log --xml | grep 'hash=' | sed -e "s/.*hash='//" -e "s/'>//"` +firsthash=$(darcs log --xml | grep 'hash=' | sed -E -e 's/.*hash="([^"]+)".*/\1/') hunk ./tests/issue2136-log_created_as_for_multiple_files.sh 72 - echo "$1" | grep "<created_as current_name='\./$2' original_name='\./$3'>" -C2 | tail -1 | grep "<name>$4</name>" + echo "$1" | grep "<created_as current_name=\"\./$2\" original_name=\"\./$3\">" -C2 | tail -1 | grep "<name>$4</name>" hunk ./tests/issue2136-log_created_as_for_multiple_files.sh 86 -echo "$xmlLog" | not grep "<created_as[^>]*'\./f6'" +echo "$xmlLog" | not grep '<created_as[^>]*"\./f6"' hunk ./tests/legacy-inverted.sh 26 -darcs changes --xml | grep "inverted='True'" +darcs changes --xml | grep "inverted=\"True\"" hunk ./tests/legacy-inverted.sh 33 -darcs changes --xml | not grep "inverted='True'" +darcs changes --xml | not grep "inverted=\"True\"" hunk ./tests/match.sh 60 -hash=`grep hash log | sed -e "s/.*hash='//" -e "s/'.*//"` +hash=$(grep hash log | sed -E -e 's/.*hash="([^"]+)".*/\1/') hunk ./tests/pull.sh 331 -firsthash=`darcs log --xml | grep 'hash=' | sed -e "s/.*hash='//" -e "s/'>//"` +firsthash=`darcs log --xml | grep 'hash=' | sed -E -e 's/.*hash="([^"]+)".*/\1/'` hunk ./tests/rename_shouldnt_affect_prefixes.sh 44 -grep "original_name='./a'" < changes.xml +grep 'original_name="./a"' < changes.xml
lower-the-upper-bound-for-http_client_tls.dpatch
Description: application/darcs-patch
_______________________________________________ darcs-devel mailing list [email protected] https://lists.darcs.net/mailman/listinfo/darcs-devel
