在 Mercurial 中查找一行代码的作者

发布于 2024-08-21 08:56:07 字数 67 浏览 6 评论 0原文

如何找出谁负责特定的代码行?我知道行号和文件名,但我希望 Mercurial 告诉我该特定代码行的作者。有这样的命令吗?

How do I find out who is responsible for a specific line of code? I know the linenumber and the filename but I would like Mercurial to tell me the author(s) of that specific line of code. Is there a command for that?

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

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

发布评论

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

评论(8

鱼窥荷 2024-08-28 08:56:07

在命令行上,您需要使用 hg annotate -u-u 可以与 -n 组合来获取本地修订号,这可能有用)。检查 hg help anno 了解更多选项。

On the command-line, you'd want to use hg annotate -u (-u can be combined with -n to get the local revision number, which might come in useful). Check hg help anno for more options.

以往的大感动 2024-08-28 08:56:07

我是 "svnblame" 的粉丝,所以我在我的 ~/.hgrc 中添加了:

[alias]
blame = annotate --user --number

这样我就可以输入 "hgblame"代码>;-)

I was a fan of "svn blame", so I've added to my ~/.hgrc:

[alias]
blame = annotate --user --number

so I can just type "hg blame" ;-)

梦途 2024-08-28 08:56:07

如果您使用 TortoiseHG

hgtk annotate <filename>

或者在日志中找到该文件,右键单击它并选择“注释文件”

If you are using TortoiseHG

hgtk annotate <filename>

Or by finding the file in the log, rightclicking it and selecting "Annotate file"

饮惑 2024-08-28 08:56:07

我在 Tortoise Workbench 中寻找这个很久了;感谢@artemb 和@Steve Pitchers 为我指明了正确的方向。我还是花了一段时间才发现它。

在此处输入图像描述

I looked for this for ages in Tortoise Workbench; thanks to @artemb and @Steve Pitchers for pointing me in the right direction. Still took me a while to spot it.

enter image description here

寂寞陪衬 2024-08-28 08:56:07

在 tortoisehg 注释窗口中,有一个新的上下文菜单可以启用此功能。

请参阅https://bitbucket.org/tortoisehg/thg/问题/1861/annotate-window-annotate-with-authors
输入图像描述这里

In tortoisehg annotate window, there is a new context menu to enable this.

see https://bitbucket.org/tortoisehg/thg/issues/1861/annotate-window-annotate-with-authors
enter image description here

空‖城人不在 2024-08-28 08:56:07

在命令行上,您可以使用 hgblame 或 hgannotate。

$ hg blame -u -c -l Filename

-u --user                list the author (long with -v)
-c --changeset           list the changeset
-l --line-number         show line number at the first appearance

on the command line , you can use either hg blame or hg annotate.

$ hg blame -u -c -l Filename

-u --user                list the author (long with -v)
-c --changeset           list the changeset
-l --line-number         show line number at the first appearance
何时共饮酒 2024-08-28 08:56:07

您还可以尝试:

hg blame <file name> | grep -A10 -B10 "<piece of code from the line of interest>"

它会显示谁对该行进行了更改,包括您感兴趣的行上方 10 行和下方 10 行。

You can also try:

hg blame <file name> | grep -A10 -B10 "<piece of code from the line of interest>"

It will show who made the change to the line, including 10 lines above and 10 lines below the line you are interested in.

酷遇一生 2024-08-28 08:56:07

hg Blame <文件名>; | grep -A10 -B10 "<感兴趣行的一段代码>

上面的命令将为整个文件执行blame并返回blame内容。这样,grep命令就会返回所需的blame行。但是,我的文件大小较大(例如:80,000 行)。要获取单行的作者详细信息,此命令会检索整个 80,000 行的责备内容并 grep 所需的行,这是否可行

?分钟获取 80,000 行文件中第 20 行的作者姓名是否有任何标志或其他命令来获取给定行的带注释内容

hg blame <file name> | grep -A10 -B10 "<piece of code from the line of interest>

The above command will execute blame for the entire file and return the blame content. With that, grep command returns the desired blame line. But, my file size is bigger(Eg: 80,000 lines). To get the author details for a single line, this command retrieves blame content for the whole 80,000 lines and greps the desired line. Is this feasible?

For your information, It takes around 5 minutes to get the author name of line 20 in file having 80,000 lines. Is there any flag or other command to get the annotated content of given line.

Example : git blame --line-porcelain -L 10,20 --

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