Rob N
Rob N

Reputation: 16409

How can you see the previous name of a renamed file in Mercurial?

I want to reconstruct the entire history of a given file, across renames. I know that the follow flag to hg log will show me revisions in which the file, under it's previous name, was modified. But how can I see the previous name? A -v to hg log will show file names in each revision, but if there are enough names I won't be able to deduce which one it was.

Upvotes: 1

Views: 926

Answers (2)

Lazy Badger
Lazy Badger

Reputation: 97282

Perform in cycle log by below example

hg log -r "adds(Seeker.txt)" --template "{file_copies}"

Seeker.txt (Искатель.txt)

Output (as Lasse wrote) is "NewName (Oldname)"

Upvotes: 6

Lasse V. Karlsen
Lasse V. Karlsen

Reputation: 391326

You can use the following two extra flags:

-v -C

I tested this in a repository, adding test1.txt and test2.txt, and then in the same commit I renamed them to test3.txt and test4.txt respectively, and this is what the log looked like if I asked for the log of test3.txt:

[D:\Temp\hg] :hg log test3.txt -v -C -f  
changeset:   1:54dac6d79938
tag:         tip
user:        Lasse V. Karlsen <[email protected]>
date:        Mon Oct 31 08:10:36 2011 +0100
files:       test1.txt test2.txt test3.txt test4.txt
copies:      test3.txt (test1.txt) test4.txt (test2.txt)
description:
renamed

changeset:   0:89213dc6f36f
user:        Lasse V. Karlsen <[email protected]>
date:        Mon Oct 31 08:10:25 2011 +0100
files:       test1.txt test2.txt
description:
initial

Granted, it isn't super-easy to spot the files, but you can see it.

Upvotes: 1

Related Questions