Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why 'hg mv' (mercurial) doesn't move a file's history by default?

I know how to do it, I just can't understand why hg mv doesn't move the file's history as well by default.

It really seems silly to be obligated me to run hg log --follow before hg mv. This remembers me the times with cvs when you needed to remove and add a file using two different operations and losing history in the same way.

IMHO, if I were just using builtin mv that would be ok to lose history, but I'm using hg mv, and, thinking about the repository itself, it doesn't make sense to lose the history by default. There should be hg mv --no-follow and not the other way round.

This isn't intuitive. Anyone here has a sane explanation about this behavior? Is this an error by design, or there's really a good reason for it? Is it possible to do this --follow by default someway when using hg mv?

like image 902
Somebody still uses you MS-DOS Avatar asked Mar 10 '11 19:03

Somebody still uses you MS-DOS


People also ask

How to untrack files in hg?

If you see the help for hg rm --help : hg remove [OPTION]... FILE... Schedule the indicated files for removal from the current branch. This command schedules the files to be removed at the next commit.


2 Answers

You can can change the default behaviour of log: in your ~/.hgrc (or somewhere/Mercurial.ini), add

[alias]  log = log -f  

I've read the appearance of the log is for speed reason. Move isn't truly a "first level" operation in Mercurial. It's a copy + delete (this compared to Bazaar where the move/rename is a "first level" operation but that doesn't have a copy with history preservation).

like image 118
xanatos Avatar answered Oct 09 '22 05:10

xanatos


You don't know how to do it. hg log --follow affects how the log is displayed, not how the actual move is done. By default, the history of the filename is displayed. --follow follows renames and copies. This fits with how Mercurial is internally implemented.

There is no reason whatsoever to run hg log --follow before hg mv.

like image 43
Matthew Flaschen Avatar answered Oct 09 '22 07:10

Matthew Flaschen