bph
bph

Reputation: 11258

Fixing file rename mistake with mercuial

I have a situation where I renamed a few files I was tracking in a mercurial repo without using hg rename command (just doing it via the file system).

This occured several revisions ago

Now I want to return to a revision prior to the file renames, fix a bug, and then rebuild that old revision

problem i have is that i am getting error messages along the lines of:

remote changed file.txt which local deleted

use (c)hanged version or leave (d)eleted?

Is there a way I can fix the mistake I made when renaming the files all those revisions ago?

Upvotes: 0

Views: 236

Answers (1)

planetmaker
planetmaker

Reputation: 6044

Depends on whether you committed the deletion of the files, but I assume you didn't and it doesn't seem so.

Then you can simply revert them in order to restore them to your working dir: hg revert file.txt. After that you can update to the previous revision without this question popping up. Alternatively just update to the previous revision you want to fix and accept the (c)changed version from remote.

If you want the rename to be permanent and also tracked by the repository, then commit that rename. Use hg addremove, possibly check with --dry-run first what it does so that no unwanted changes are added and commit the renaming of the files. Then go and update to the old revision and do whatever changes you want to commit there.

Upvotes: 1

Related Questions