35

I remember in SVN, I can rename a file from foo.txt to foo2.txt and all the history will follow (log file of foo2.txt will show all history of foo.txt as well). But on Mercurial, seems like that's not the case. When a hg rename is done, then hg log foo2.txt will not show any previous history of foo.txt? Is there a way around it?

nonopolarity
  • 146,324
  • 131
  • 460
  • 740

1 Answers1

41

Use hg log --follow foo2.txt or hg log -f foo2.txt (short form) to show you the entire history of the file before the hg rename

Niall C.
  • 10,878
  • 7
  • 69
  • 61
  • 1
    Also xanatos [described](http://stackoverflow.com/a/5264567/501399) how you can change the default `log` command behaviour to `--follow`. – vadipp Jan 16 '13 at 09:24
  • 1
    Sorry, but I don't really understand this answer. If I apply the `log` command BEFORE the `hg rename` then there is no `foo2.txt`. If I apply if after, there is no `foo.txt`, and `foo2.txt` has no history. Also how will mercurial "know" that the file `foo2.txt` is the new version of `foo.txt`? – mg30rg Mar 26 '14 at 09:55
  • 3
    @mg30rg the answer does not say that you should run `hg log -f` before you rename. It merely says that, `hg log -f` shows you the history before the file was renamed. – Grim Fandango May 21 '14 at 07:25