- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想编写一个 Haskell 程序来查询有关 darcs 存储库的信息。我宁愿直接使用 darcs 库,而不是调用 darcs 可执行文件并解析结果。是said to be “很多工作正在进行中”和“缺乏稳定的 API”,但似乎可用。
我想我可以通过研究 darcsden 源代码来回答我的问题,例如,从 this module 开始,但我认为,如果有知识渊博的人提供评论介绍来补充这样的研究,这不仅对我有帮助。
所以,这里有一个具体的例子。
如何为给定文件计算影响它的最新补丁以及补丁的日期、作者和名称?如果您解释解决方案中使用的关键库函数,这将非常有用。
编辑:
这里有一些对不熟悉 darcs 源代码的人可能不明显的评论。我是从 Jason Dagit's master thesis 那里学到的并希望他们有助于理解 Ganesh 给出的答案。
在 Darcs 中,补丁有一个前后上下文,表示应用补丁之前和之后存储库的状态。在源代码中,这些上下文是在补丁类型上使用幻像类型建模的。这些幻像类型称为见证人和 seal2
用于摆脱它们。
在补丁列表中,只有第一个前上下文和最后一个后上下文在类型中表示。所有其他上下文都使用存在类型隐藏。 Darcs 定义了前向列表(称为 FL)和反向列表(称为 RL)。反向列表以反向(按时间顺序)顺序存储补丁(由 darcs 完成的模补丁重新排序)。反向列表可用于访问头部位置的最新补丁。所有名称中带有 RL 的函数都会创建或操作此类反向列表。
最佳答案
-- This works with darcs 2.9.5 (a tag in the development repo
-- at http://darcs.net/screened).
--
-- It should work with darcs 2.8.2 with the following changes:
-- - some minor namespace changes
-- - change withRepositoryDirectory to pass [] instead of YesUseCache
-- - comment out the line below that uses the "patch index"
import Control.Applicative ( (<$>) )
import Darcs.Patch.Info ( PatchInfo )
import Darcs.Patch.Inspect ( listTouchedFiles )
import Darcs.Patch.PatchInfoAnd ( info )
import Darcs.Patch.Set ( newset2RL )
import Darcs.Patch.Witnesses.Ordered ( mapRL )
import Darcs.Patch.Witnesses.Sealed ( seal2, unseal2 )
import Darcs.Repository
( withRepositoryDirectory, RepoJob(..), readRepo )
import Darcs.Repository.FileMod ( filterPatches )
import Darcs.Repository.Flags ( UseCache(..) )
import Data.Maybe ( listToMaybe )
getChange
:: FilePath -- ^repository directory
-> FilePath -- ^file path
-> IO (Maybe PatchInfo) -- ^patch metadata
getChange repoDir fileName =
-- Select the repository from repositoryDirectory.
--
-- The function parameter to 'RepoJob' needs to be polymorphic
-- in the underlying patch type (darcs-1 or darcs-2).
withRepositoryDirectory YesUseCache repoDir $ RepoJob $ \repo -> do
-- 'readRepo' gives us a PatchSet, a lazy witnessed list of all
-- the patches structured by "clean tags".
--
-- We use 'newset2RL' to get rid of the tag structure as we don't
-- need it, and 'mapRL seal2' to get rid of the witnesses which we
-- also don't need. The result is of type '[Sealed2 p]', where 'p'
-- is the underlying patch type of the repository we are reading
-- (either darcs-1 or darcs-2)
patches <- mapRL seal2 . newset2RL <$> readRepo repo
-- Use the recently introduced "patch index" to filter the list of
-- patches from the repo down to ones that just touch 'fileName'.
--
-- This step is optional: we can remove it and the result will be
-- the same, but substantially slower on large repositories where
-- the patch we want is far back in the repo.
patches <- filterPatches repo [fileName] patches
-- Use 'filter' and 'listToMaybe' to get the first patch that touches
-- 'fileName'.
--
-- The filter is superfluous in this simple case if the patch
-- index was used, but doesn't cost much if so.
--
-- Note that this doesn't track renames, so isn't suitable for
-- finding anything but the last patch that touched 'fileName'.
--
-- 'unseal2' is used to lift a function that works on witnessed
-- patches to one that works on "sealed" patches.
let wanted = unseal2 (\patch -> fileName `elem` listTouchedFiles patch)
let thepatch = listToMaybe . filter wanted $ patches
-- Finally, return the metadata of the patch.
--
-- Things get a little bit more complex if we want to deal
-- with the contents of the patch, because the specific
-- patch type isn't known statically - it might be
-- darcs-1 or darcs-2.
--
-- The best approach is to write a polymorphic function that
-- can accept any instance of 'RepoPatch'.
return (fmap (unseal2 info) thepatch)
关于haskell - 如何使用darcs库查询补丁信息?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12941793/
我正在尝试在站点列表中添加站点名称,以便在 publish:end:remote 上清除 HTML 缓存事件。 mysite 但是,它没有按预期工
我正在尝试使用不同目录中的多个文件制作补丁。我不想包含所有未提交的文件,因为我有很多不适用于补丁。 我知道这个命令可以使用特定文件创建补丁,唯一的问题是这是一个文件: svn diff -up ori
我经常使用 gnu-utils 补丁和差异。使用 git,我经常这样做: git diff 通常简单的更改会创建一个大补丁,因为唯一的更改是,例如,添加一个 if/else 循环,并且里面的所有内容都
我使用命令(从 ~ 执行)生成了一个 diff.txt 文件: diff -r /full/path/to/directory/A /full/path/to/directory/B > diff.t
我正在编写一个项目,我需要通过网络传输一组相似的图像。为了加快速度,我考虑过做大多数电影编解码器所做的事情。有关键帧,然后发送更改。 现在,我得到的是一组 BufferedImage,因此类似于文本文
我正在尝试将更改拆分为多个提交,但在手动编辑大块时我遇到了问题。 原始大块头: @@ -116,8 +116,8 @@ context context -
我想自动测试一组仍然干净利落地适用于(更新的)代码库的补丁。为此,我打算运行 patch -p 1 a echo b > b diff -Nu a b > p rm a b patch -p 1 <
我已经从一个模块中导入了一个类,但是当我尝试在没有模块作为前缀的情况下修补类名时,我得到一个类型错误: TypeError: Need a valid target to patch. You sup
最近我从 SVN 迁移到 git,我的团队已经开始在新的 git 存储库中工作。 后来我发现了一些转换问题,并从 SVN 制作了第二个 git repo,并进行了一些修复和历史重写。 现在我有了 SV
我正在尝试为我的应用程序创建一个补丁。实现描述的示例 here按预期工作。但是,每个版本的文件都存储在单独的目录中。 1.0 版文件在 c:sample\1.0 中,1.1 版文件在 c:sample
首先请原谅我的长文,但我会尽量详细。 我正在为一个开源项目 (DSpace) 进行开发。我没有对他们的 SVN 存储库的提交权限,所以我查看了源代码并一直使用 git 来管理我的版本控制。 在我的开发
有没有办法自动 merge (interdiff)2 个头分支和 1 个基分支之间的冲突? 我试图在补丁级别做这件事 版本A是我的基础 VersionB 是 VersionA 的分支 VersionB
我正在尝试申请 this修补到 MinGW 上的 GCC 以获取它 to compile GDC 2 ,但我不知道如何。 (我对 GCC 的内部结构还很陌生,甚至对一般的 *nix 工具也很陌生。)我
我对软件开发很陌生,所以这无疑是一个非常基本的问题。我得到了一个开源项目的 mercurial repo。我复制了它并做了一些工作。 promise 。工作更多,然后进行了第二次提交。所以我的树看起来
我想对这个错误 ( http://code.djangoproject.com/ticket/13095 ) 应用补丁,但我以前从未做过,也不知道从哪里开始。谁能给我指点教程? 最佳答案 在 Linu
我前段时间使用 p4 diff 生成了一个补丁。命令。 然而,现在我想应用它,我意识到没有办法在 Perforce 中应用补丁。 由于我没有使用 -du选项,补丁是那种晦涩难懂的 perforce 格
我可以使用 NSIS 的 Vpatch 生成从一个版本到另一个版本的补丁文件。假设我有 mydll.dll 版本 1,我有一个补丁可以将它更新到版本 2。然后我又有了一个新版本,因此我生成了另一个补丁
我有一个补丁,用 hg export 42 制作在另一个存储库中,修改文件 asd/fgh/foo/bar.c asd/fgh/foo/fish.h boo/hoo.txt 我需要将此补丁导入具有如下
我们有一个相当大的库,我们需要定期将其导入(然后修补)到我们的代码库中。 SVN Book 似乎推荐了一个“vendor branch”方案,我们保留了“vendor drops”的补丁版本。这会起作
我正在家里用 tensorflow 玩卷积神经网络(顺便说一句,我已经完成了 udacity 深度学习类(class),所以我有理论基础)。 运行卷积时,patch 的大小会产生什么影响?当图像变大/
我是一名优秀的程序员,十分优秀!