`hg log --follow -r N` 列出所有修订而不是列出 rev N

`hg log --follow -r N` lists all revisions instead of listing rev N

我需要帮助来理解 hg log --follow.

$ hg log --help
...
 -f --follow              follow changeset history, or file history across
                          copies and renames

当我指定 -f 时,日志输出包括所有提交。我预计它会 return 提交与给定修订中更改的文件相关的内容。 这是 -f 标志的预期行为吗?如果是这样,它的用例是什么?

/tmp:$ hg --version
Mercurial Distributed SCM (version 4.5.3)
/tmp:$ mkdir hg-f
/tmp:$ cd hg-f
/tmp/hg-f:$ hg init
/tmp/hg-f:$ touch file0
/tmp/hg-f:$ hg add file0
/tmp/hg-f:$ hg commit -m 'file0 added'
/tmp/hg-f:$ touch foobar
/tmp/hg-f:$ hg add foobar
/tmp/hg-f:$ hg commit -m 'added foobar'
/tmp/hg-f:$ hg mv foobar barfoo
/tmp/hg-f:$ hg commit -m 'moved foobar'
/tmp/hg-f:$ hg log -v -r 2
changeset:   2:492bd607810c
tag:         tip
user:        'notalex'
date:        Tue Apr 16 09:10:25 2019 +0530
files:       barfoo foobar
description:
moved foobar

/tmp/hg-f:$ hg log -v -f -r 2
changeset:   2:492bd607810c
tag:         tip
user:        'notalex'
date:        Tue Apr 16 09:10:25 2019 +0530
files:       barfoo foobar
description:
moved foobar

changeset:   1:adfd98042078
user:        'notalex'
date:        Tue Apr 16 09:10:14 2019 +0530
files:       foobar
description:
added foobar

changeset:   0:64e5211bd019
user:        'notalex'
date:        Tue Apr 16 09:09:53 2019 +0530
files:       file0
description:
file0 added

你必须更全面、更仔细地阅读 docs(我从未使用过没有文件名的 -f,因此 - 也是第一次阅读此相关段落)

File history is shown without following rename or copy history of files. Use -f/--follow with a filename to follow history across renames and copies. --follow without a filename will only show ancestors of the starting revision.

0 2 在 DAG 方面的祖先,OK。如果您想查看和理解 -f 的真正目的,您只需比较(对于您的测试用例)

的输出

hg log barfoo 对比 hg log -f barfoo