Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mercurial: restore files

Tags:

mercurial

I'd like to restore a file that has been deleted in some commit, and restore it under a different name, so that it shares the history. In subversion, I'd do

svn cp src@REV dest

i.e. use peg revisions. What's the equivalent in Mercurial?

like image 362
Martin v. Löwis Avatar asked Jul 27 '10 16:07

Martin v. Löwis


1 Answers

I don't think Mercurial has a built-in way to do this. But I think you can get the same effect via:

hg up -C REV # Update to revision containing a copy of the file
<modify the file in question>
hg commit  # Create second head based on old revision
hg merge # Merge two heads into one
# Note: make sure to choose to have the file exist
hg commit
hg mv MYFILE MYNEWNAME

This will have the file keep all its old history, as best Mercurial can track it.

like image 115
Borealid Avatar answered Oct 29 '22 12:10

Borealid