搜索“TODO”仅在特定 Mercurial 变更集中发生更改的文件中?

发布于 2024-11-18 21:02:53 字数 221 浏览 0 评论 0原文

我正在一个已经有很多“TODO”注释的代码库中工作,在推送我的变更集之前,我想确保我没有在其中留下任何 TODO 注释(而不是实际做)它,或将其添加到新功能数据库并删除注释)。

目前我只是在每个评论中使用“TODO:Wilka”,因此很容易搜索。但是,使用 Mercurial 有没有一种方法可以让我仅在变更集集合中已更改的文件中搜索“TODO”?理想情况下,它只会搜索实际已更改的行 - 但即使只是文件也很好。

I'm working in a code base that already has a lot of "TODO" comments, and before I push my changeset(s) I want to make sure I haven't left any of my TODO comments in there (rather than actually doing it, or adding it to the new-feature database and removing the comment).

At the moment I'm just using "TODO: Wilka" in each of the comments, so it's easy to search for. But is there a way with Mercurial I can search for "TODO" only in the files that have changed in a collection of changesets? Ideally, it would only search the lines that have actually changed - but even just the files would be good.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

穿透光 2024-11-25 21:02:53

要搜索一组特定的修订,您可以执行以下操作:

hg grep -r 0:3 "\bTODO:"

to search a specific set of revisions you could do:

hg grep -r 0:3 "\bTODO:"
把时间冻结 2024-11-25 21:02:53

通过管道传输到 grep 的所需修订版本之间的差异,仅使用 grep 编辑搜索修改后的文件

hg diff -r 100:105 | grep TODO


正如评论中提到的,这是假设安装了 grep (所以非 Windows 环境)
@谢谢 Tim,如果使用 Windoes,请使用 findstr 而不是 grep

Diff between wanted revisions piped to the grep, only modified files file be searched with the grep

hg diff -r 100:105 | grep TODO

EDIT:
As mentioned in the comments, this is presumes that grep is installed (so non Windows enviroment)
@thanks Tim, if using Windoes, use findstr instead of the grep

也只是曾经 2024-11-25 21:02:53

自动方式是通过 Mercurial 提交挂钩示例可能会有所帮助,checkfiles 扩展名 由 Mercurial 开发人员引用

根据我的经验,提交钩子是一个混合包,通常可以做你想做的事情,但当你真的想提交一个 TODO 时,它会令人厌烦。 搁置扩展尝试解决此问题,但解决办法可能比问题本身更糟糕。

我还没有探索像 hg com --but-ignore-my-TODO-hook 之类的东西的可能性,这可能很漂亮。

The automated way is via Mercurial commit hooks. The examples may be helpful as might the checkfiles extension referred to by mercurial developers.

In my experience, commit hooks are a mixed bag and often do what you want but are irksome when you really want to commit a TODO. The Shelve extension attempts to work around this, but the cure can be worse than the problem.

I haven't explored the possibility of something like hg com --but-ignore-my-TODO-hook which could be nifty.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文