I need to remove a specific version of a versioned file in my repo, but I do not know how to do it.
I can view the file using hg cat –rev [version] [file-name], but I do not know to remove it.
Anyone know how to remove a specific file version?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Short answer: If your repo is public, it’s very hard. If it’s private, easier.
Long answer: Mercurial, being a changeset-oriented CVS, does not actually store file revisions. Instead, it stores changes between revisions (diffs).
In addition to that, every changeset id is calculated as a cryptographic hash based on the content of the revision. This means that if you altered a single changeset, every descendant changeset of it would be changed. This is the price of rewriting history in Mercurial.
Private repo
If the changeset you need to change was not pushed anywhere (or the repo itself is private), then you can alter history as you like.
If the changeset is a recent one, consider using Mercurial Queues: you can import the changesets into the queue, go to the changeset in question, undo the change to one particular file, then reapply the rest of the queue.
If the changeset was committed a long time ago, you might probably update to its parent, graft the offending changeset (you’ll probably have to stick in a dummy changeset to make it work), import it to MQ, modify it, then
rebase --detachthe rest of the ancestors on top of it.Public repo
You can do the same with the private repo, but remember the copy of the lineage will be created:
Even after you replace
A–DwithA'–D', everyone who pulled from your repo will still haveA–D! You’ll have to find a way to make them strip this lineage.