Alain Linden
Alain Linden

Reputation: 21

How do I automatically preserve deletes while performing a merge with Mercurial?

I have a repository I will call 'subset' which was cloned from another repository I will call 'full'. I deleted many files in subset using 'hg rm'. I now need to pull changes to the files remaining in subset from full, but I don't want to restore any of the files I deleted. If I do a pull followed by a merge, the merge will interactively ask me for each deleted file that was changed in full if I want to use the changed file or leave it deleted. Is there any way to automatically leave all deleted files deleted and save myself a repetitive stress injury?

As a side note, one time fixes (like using hg convert on full?) won't fly because both the full and subset repositories are being actively worked on, at least for now.

Upvotes: 1

Views: 342

Answers (2)

Ry4an Brase
Ry4an Brase

Reputation: 78350

Actually, hg convert is still the right way to do this. Convert works in an iterative fashion, so it will bring across only the new change sets. Use a --filemap with a bunch of exclude lines, and just re-run the convert command with the same source and destination clones, and you can iteratively filter whenever you need to merge.

This is a very common pattern if, say, a fraction of your total project is released to a broader audience.

Upvotes: 1

Johannes Rudolph
Johannes Rudolph

Reputation: 35761

The easiest way to do this would be to rebase your removes on top of the modified files. This will work well as long as you didn't rename a lot of files.

See this answer for more details.

Upvotes: 1

Related Questions