mirror of
https://code.sup39.dev/repos/Wqawg
synced 2024-12-31 06:14:50 +09:00
Plan for parsing Darcs patch for patch view
This commit is contained in:
parent
5a7811b067
commit
c8b085fbc8
3 changed files with 45 additions and 1 deletions
|
@ -18,6 +18,7 @@ module Vervis.Darcs
|
||||||
, readWikiView
|
, readWikiView
|
||||||
, readChangesView
|
, readChangesView
|
||||||
, lastChange
|
, lastChange
|
||||||
|
, readPatch
|
||||||
)
|
)
|
||||||
where
|
where
|
||||||
|
|
||||||
|
@ -55,6 +56,7 @@ import Data.Text.UTF8.Local (decodeStrict)
|
||||||
import Data.Time.Clock.Local ()
|
import Data.Time.Clock.Local ()
|
||||||
import Vervis.Changes
|
import Vervis.Changes
|
||||||
import Vervis.Foundation (Widget)
|
import Vervis.Foundation (Widget)
|
||||||
|
import Vervis.Patch
|
||||||
import Vervis.Readme
|
import Vervis.Readme
|
||||||
import Vervis.SourceTree
|
import Vervis.SourceTree
|
||||||
import Vervis.Wiki (WikiView (..))
|
import Vervis.Wiki (WikiView (..))
|
||||||
|
@ -218,3 +220,41 @@ lastChange path now = fmap maybeRight $ runExceptT $ do
|
||||||
intervalToEventTime $
|
intervalToEventTime $
|
||||||
FriendlyConvert $
|
FriendlyConvert $
|
||||||
now `diffUTCTime` piTime pi
|
now `diffUTCTime` piTime pi
|
||||||
|
|
||||||
|
-- TODO
|
||||||
|
readPatch :: FilePath -> Text -> IO (Maybe Patch)
|
||||||
|
readPatch path hash = error "Not implemented"
|
||||||
|
-- I'm not sure what's the fastest way to find a patch file given its info
|
||||||
|
-- hash, maybe Darcs keeps some cache or something. But assuming there are
|
||||||
|
-- no tricks like that, here's an idea how to grab the patch:
|
||||||
|
--
|
||||||
|
-- (1) Start going over the whole inventory, whose order is from latest to
|
||||||
|
-- oldest, looking for a patch with the given hash.
|
||||||
|
-- (2) Once found, determine the patch filename from its size and content
|
||||||
|
-- hash
|
||||||
|
-- (3) Run the patch parser on that file, through a zlib decompressor
|
||||||
|
-- though (check how I did that for the inventories parser)
|
||||||
|
--
|
||||||
|
-- TODO idea: Use hints to speed up finding the patch! In the repo history
|
||||||
|
-- log page, embed hints into the hyperlinks to the patches, and in the
|
||||||
|
-- patch page handler, use the hint to figure out the patch location.
|
||||||
|
-- Actually, since the inventory file contains patch content hashes, I can
|
||||||
|
-- use that as a hint and skip the whole step of looking for the patch!
|
||||||
|
--
|
||||||
|
-- TODO maybe start by finding the patch hash in patch_ids and use the
|
||||||
|
-- position as a hint to its location in the inventories
|
||||||
|
--
|
||||||
|
-- TODO maybe I can figure out from darcs source code how a given patch
|
||||||
|
-- hash is found? Just in case there's a faster way
|
||||||
|
--
|
||||||
|
-- TODO find out what's the index and patch_index files under _darcs and
|
||||||
|
-- maybe other files there, possibly there's a way to patch the info hash
|
||||||
|
-- with the content hash.
|
||||||
|
--
|
||||||
|
-- UPDATE: I read about index and patch_index, looks like they won't help.
|
||||||
|
-- But possibly the global cache system will? However interesting note:
|
||||||
|
-- Vervis on my laptop has a patch_index, but on the server it doesn't.
|
||||||
|
-- Probably because `darcs log` never runs on the server since I parse
|
||||||
|
-- patches manually. If I end up using the patch index for something, it
|
||||||
|
-- may be a good idea to trigger its generation, so that it's available
|
||||||
|
-- when people browser repo pages.
|
||||||
|
|
|
@ -263,7 +263,7 @@ getRepoPatchR :: ShrIdent -> RpIdent -> Text -> Handler Html
|
||||||
getRepoPatchR shr rp ref = do
|
getRepoPatchR shr rp ref = do
|
||||||
repository <- runDB $ selectRepo shr rp
|
repository <- runDB $ selectRepo shr rp
|
||||||
case repoVcs repository of
|
case repoVcs repository of
|
||||||
VCSDarcs -> error "Not implemented yet" -- getDarcsPatch shr rp ref
|
VCSDarcs -> getDarcsPatch shr rp ref
|
||||||
VCSGit -> getGitPatch shr rp ref
|
VCSGit -> getGitPatch shr rp ref
|
||||||
|
|
||||||
getRepoDevsR :: ShrIdent -> RpIdent -> Handler Html
|
getRepoDevsR :: ShrIdent -> RpIdent -> Handler Html
|
||||||
|
|
|
@ -18,6 +18,7 @@ module Vervis.Handler.Repo.Darcs
|
||||||
, getDarcsRepoHeadChanges
|
, getDarcsRepoHeadChanges
|
||||||
, getDarcsRepoChanges
|
, getDarcsRepoChanges
|
||||||
, getDarcsDownloadR
|
, getDarcsDownloadR
|
||||||
|
, getDarcsPatch
|
||||||
)
|
)
|
||||||
where
|
where
|
||||||
|
|
||||||
|
@ -106,3 +107,6 @@ getDarcsDownloadR shar repo dir = do
|
||||||
if exists
|
if exists
|
||||||
then sendFile typeOctet filePath
|
then sendFile typeOctet filePath
|
||||||
else notFound
|
else notFound
|
||||||
|
|
||||||
|
getDarcsPatch :: ShrIdent -> RpIdent -> Text -> Handler Html
|
||||||
|
getDarcsPatch shr rp ref = error "Not implemented"
|
||||||
|
|
Loading…
Reference in a new issue