I need help in understanding hg log --follow.
$ hg log --help
...
-f --follow follow changeset history, or file history across
copies and renames
When I specify -f, the log output includes all the commits. I expected it to return commits related to the file changed in the given revision. Is this the intended behaviour of the -f flag. If so, what is its use case?
/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
You have to read docs more fully and carefully (I never used -f
without filename, thus - read this related para first time too)
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 is the ancestor of 2 in terms of DAG, OK. If you want to see and understand real purpose of -f
, you have just compare output of (for your test-case)
hg log barfoo
vs hg log -f barfoo